17 { 90, 180, 180, 180 },
24 { -120, -180, 180, 180 },
25 { -90, -120, 180, 90 },
26 { -90, -90, 180, 180 },
27 { -90, -180, -90, -90 }
33 { -90, -90, 180, 180 },
34 { -90, -180, -90, -90 }
69 fiducial( (
ModelFiducial*)pos->GetUnusedModelOfType(
"fiducial" )),
127 double a_goal =
normalize( charger_bearing );
136 if( charger_range > 0.5 )
138 if( !ObstacleAvoid() )
149 if( charger_range < 0.08 )
176 const meters_t back_off_distance = 0.3;
177 const meters_t back_off_speed = -0.05;
180 if( charger_range < back_off_distance )
198 charger_range > back_off_distance )
204 bool obstruction =
false;
209 double minleft = 1e6;
210 double minright = 1e6;
213 const std::vector<meters_t>& scan = laser->
GetSensors()[0].ranges;
215 uint32_t sample_count = scan.size();
217 for (uint32_t i = 0; i < sample_count; i++)
219 if(
verbose ) printf(
"%.3f ", scan[i] );
221 if( (i > (sample_count/4))
222 && (i < (sample_count - (sample_count/4)))
225 if(
verbose ) puts(
" obstruction!" );
231 if(
verbose ) puts(
" stopping!" );
235 if( i > sample_count/2 )
236 minleft = std::min( minleft, scan[i] );
238 minright = std::min( minright, scan[i] );
244 printf(
"minleft %.3f \n", minleft );
245 printf(
"minright %.3f\n ", minright );
248 if( obstruction || stop || (avoidcount>0) )
250 if(
verbose ) printf(
"Avoid %d\n", avoidcount );
258 if(
verbose ) puts(
"Avoid START" );
261 if( minleft < minright )
284 if( ! ObstacleAvoid() )
286 if(
verbose ) puts(
"Cruise" );
295 int x = (pose.
x + 8) / 4;
296 int y = (pose.
y + 8) / 4;
329 double a_error =
normalize( a_goal - pose.
a );
344 switch( robot->
mode )
362 printf(
"unrecognized mode %u\n", robot->
mode );
389 hypot( -7-pose.
x, -7-pose.
y ) < 2.0 )
401 if( hypot( 7-pose.
x, 7-pose.
y ) < 1.0 )
428 std::vector<ModelFiducial::Fiducial>& fids = mod->
GetFiducials();
430 for(
unsigned int i = 0; i < fids.size(); i++ )
435 if( fids[i].
id == 2 )
void SetTurnSpeed(double a)
unsigned int GetFlagCount() const
The Stage library uses its own namespace.
std::vector< Fiducial > & GetFiducials()
static int LaserUpdate(ModelRanger *laser, Robot *robot)
static int PositionUpdate(ModelPosition *pos, Robot *robot)
void Init(int *argc, char **argv[])
const double minfrontdistance
int(* model_callback_t)(Model *mod, void *user)
int FiducialUpdate(ModelFiducial *fid, robot_t *robot)
double ProportionRemaining() const
static int FiducialUpdate(ModelFiducial *mod, Robot *robot)
Robot(ModelPosition *pos, Model *source, Model *sink)
double normalize(double a)
int LaserUpdate(Model *mod, robot_t *robot)
void AddCallback(callback_type_t type, model_callback_t cb, void *user)
int PositionUpdate(Model *mod, robot_t *robot)
void PushFlag(Flag *flag)
const std::vector< Sensor > & GetSensors() const
Model * GetModel(const std::string &name) const
PowerPack * FindPowerPack() const
radians_t a
rotation about the z axis.
const unsigned int payload