stdr-simulator-ros-pkg / stdr_simulator

A simple, flexible and scalable 2D multi-robot simulator.
http://stdr-simulator-ros-pkg.github.io/
GNU General Public License v3.0
96 stars 66 forks source link

How to understand the obstacle avoidance function? #187

Closed libing64 closed 8 years ago

libing64 commented 8 years ago

The obstacle avoidance method in stdr_sample seems very simple, is there any paper talking about this method?

void ObstacleAvoidance::callback(const sensormsgs::LaserScan& msg) { scan = msg; float linear = 0, rotational = 0; for(unsigned int i = 0 ; i < scan_.ranges.size() ; i++) { float realdist = scan.ranges[i]; linear -= cos(scan_.anglemin + i * scan.angle_increment) / (1.0 + real_dist * realdist); rotational -= sin(scan.anglemin + i * scan.angle_increment) / (1.0 + real_dist * real_dist); } geometry_msgs::Twist cmd;

linear /= scan_.ranges.size();
rotational /= scan_.ranges.size();

//~ ROS_ERROR("%f %f",linear,rotational);

if(linear > 0.3)
{
  linear = 0.3;
}
else if(linear < -0.3)
{
  linear = -0.3;
}

cmd.linear.x = 0.3 + linear;
cmd.angular.z = rotational;
cmd_vel_pub_.publish(cmd);

} }

etsardou commented 8 years ago

Hey, it seems simple because it is simple! This was created in order to showcase how you can use the topics of STDR to do something autonomous, and not to actually perform robust obstacle avoidance. The method followed tries to produce a linear and a rotational velocity according to these rules:

In both cases, the rays measurements are taken into consideration, so as for the closer obstacles to have a larger effect in the avoidance.

libing64 commented 8 years ago

@etsardou Great thanks.