$search
00001 /* 00002 * Navigator lane edge controller 00003 * 00004 * Copyright (C) 2007, 2010, Austin Robot Technology 00005 * 00006 * License: Modified BSD Software License Agreement 00007 * 00008 * $Id: lane_edge.cc 479 2010-08-27 01:16:11Z jack.oquin $ 00009 */ 00010 00011 #include "navigator_internal.h" 00012 #include "Controller.h" 00013 #include "course.h" 00014 #include "lane_edge.h" 00015 #include "safety.h" 00016 00017 LaneEdge::LaneEdge(Navigator *navptr, int _verbose): 00018 Controller(navptr, _verbose) 00019 { 00020 safety = new Safety(navptr, _verbose); 00021 } 00022 00023 LaneEdge::~LaneEdge() 00024 { 00025 delete safety; 00026 } 00027 00028 void LaneEdge::configure() 00029 { 00030 safety->configure(cf, section); 00031 } 00032 00033 // steer towards the edge of the lane 00034 // 00035 // entry: 00036 // offset_ratio = lane offset ratio: where 1.0 is the left edge 00037 // and -1.0 is the right edge. 00038 // exit: 00039 // pcmd adjusted to head for desired offset in the lane with 00040 // speed adjusted by the safety controller 00041 // returns: 00042 // safety controller result if this path taken 00043 // 00044 Controller::result_t LaneEdge::control(pilot_command_t &pcmd, 00045 float offset_ratio) 00046 { 00047 result_t result = OK; 00048 00049 // set heading with desired offset 00050 course->desired_heading(pcmd, offset_ratio); 00051 00052 // always run safety check on the output 00053 result = safety->control(pcmd); 00054 00055 trace("lane_edge controller", pcmd, result); 00056 return result; 00057 } 00058 00059 // reset all subordinate controllers 00060 void LaneEdge::reset(void) 00061 { 00062 trace_reset("LaneEdge"); 00063 safety->reset(); 00064 }