57 const std::vector<meters_t>& scan = robot->
laser->
GetSensors()[0].ranges;
58 uint32_t sample_count = scan.size();
59 if( sample_count < 1 )
62 bool obstruction =
false;
68 double minright = 1e6;
70 for (uint32_t i = 0; i < sample_count; i++)
73 if(
verbose ) printf(
"%.3f ", scan[i] );
75 if( (i > (sample_count/3))
76 && (i < (sample_count - (sample_count/3)))
79 if(
verbose ) puts(
" obstruction!" );
85 if(
verbose ) puts(
" stopping!" );
89 if( i > sample_count/2 )
90 minleft = std::min( minleft, scan[i] );
92 minright = std::min( minright, scan[i] );
98 printf(
"minleft %.3f \n", minleft );
99 printf(
"minright %.3f\n ", minright );
102 if( obstruction || stop || (robot->
avoidcount>0) )
112 if(
verbose ) puts(
"Avoid START" );
115 if( minleft < minright )
131 if(
verbose ) puts(
"Cruise" );
151 printf(
"Pose: [%.2f %.2f %.2f %.2f]\n",
152 pose.
x, pose.
y, pose.
z, pose.
a );
void SetTurnSpeed(double a)
The Stage library uses its own namespace.
static const int avoidduration
void Init(int *argc, char **argv[])
int(* model_callback_t)(Model *mod, void *user)
static const bool verbose
meters_t z
location in 3 axes
static const double minfrontdistance
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)
static const double avoidspeed
const std::vector< Sensor > & GetSensors() const
static const double cruisespeed
static const double stopdist
radians_t a
rotation about the z axis.
Model * GetChild(const std::string &name) const
static const double avoidturn