39 PRINT_ERR(
"No position model given in wander controller.");
52 printf(
"\nWander ctrl for robot %s:\n", robot->
pos->
Token() );
53 for(
int i=0; i<16; i++ )
56 snprintf( name, 32,
"ranger:%d", i );
58 printf(
" looking for a suitable ranger at \"%s:%s\" ... ", robot->
pos->
Token(), name );
61 if( laser && laser->GetSensors()[0].sample_count > 8 )
71 PRINT_ERR(
" Failed to find a ranger with more than 8 samples. Exit.");
86 const std::vector<meters_t> &scan = robot->
laser->
GetSensors()[0].ranges;
87 uint32_t sample_count = scan.size();
91 bool obstruction =
false;
97 double minright = 1e6;
99 for (uint32_t i = 0; i < sample_count; i++) {
101 printf(
"%.3f ", scan[i]);
103 if ((i > (sample_count / 3)) && (i < (sample_count - (sample_count / 3)))
106 puts(
" obstruction!");
116 if (i > sample_count / 2)
117 minleft = std::min(minleft, scan[i]);
119 minright = std::min(minright, scan[i]);
124 printf(
"minleft %.3f \n", minleft);
125 printf(
"minright %.3f\n ", minright);
128 if (obstruction || stop || (robot->
avoidcount > 0)) {
141 if (minleft < minright) {
144 printf(
"turning right %.2f\n", -
avoidturn);
148 printf(
"turning left %2f\n", +
avoidturn);
175 printf(
"Pose: [%.2f %.2f %.2f %.2f]\n", 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
const std::vector< Sensor > & GetSensors() const
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
static const double cruisespeed
static const double stopdist
Model * GetChild(const std::string &name) const
radians_t a
rotation about the z axis.
static const double avoidturn
const char * Token() const