|
@@ -174,7 +174,7 @@ void goForward()
|
|
distSrvClient.call(distSrv); //通过服务调用来获取测距值
|
|
distSrvClient.call(distSrv); //通过服务调用来获取测距值
|
|
front_dist = distSrv.response.front_dist; //记录当前测距值,防止撞墙
|
|
front_dist = distSrv.response.front_dist; //记录当前测距值,防止撞墙
|
|
ROS_INFO("Front dist:%f", front_dist);
|
|
ROS_INFO("Front dist:%f", front_dist);
|
|
- while((dist<check_dist)&&(front_dist>tolerance_dist*3.0)&&(ros::ok()))
|
|
|
|
|
|
+ while((dist<check_dist)&&(front_dist>tolerance_dist*4.0)&&(ros::ok()))
|
|
{
|
|
{
|
|
ROS_INFO("Go forward, dist:%f", dist);
|
|
ROS_INFO("Go forward, dist:%f", dist);
|
|
publishTwistCmd(linear_x_speed, 0, 0);
|
|
publishTwistCmd(linear_x_speed, 0, 0);
|
|
@@ -337,7 +337,7 @@ void horizMoveMiddle(float tolerance)
|
|
* 会错.这里的走迷宫策略是左转优先,中间是直行,最后是右转.
|
|
* 会错.这里的走迷宫策略是左转优先,中间是直行,最后是右转.
|
|
**************************************************************************/
|
|
**************************************************************************/
|
|
void checkInfraredDist(float infrared_f,float infrared_l,float infrared_r,
|
|
void checkInfraredDist(float infrared_f,float infrared_l,float infrared_r,
|
|
- float tolerance)
|
|
|
|
|
|
+ float tolerance, float warn_distance)
|
|
{
|
|
{
|
|
static int flag = 0;
|
|
static int flag = 0;
|
|
|
|
|
|
@@ -387,7 +387,7 @@ void infrared_callback(const ros_arduino_msgs::InfraredSensors::ConstPtr& msg)
|
|
right_dist = msg->right_dist;
|
|
right_dist = msg->right_dist;
|
|
|
|
|
|
//根据三个传感器反馈的测距值开始移动
|
|
//根据三个传感器反馈的测距值开始移动
|
|
- checkInfraredDist(front_dist, left_dist, right_dist, tolerance_dist);
|
|
|
|
|
|
+ checkInfraredDist(front_dist, left_dist, right_dist, tolerance_dist, warn_dist);
|
|
yawUpdate(start_yaw_data); //移动完成后开始更新yaw值
|
|
yawUpdate(start_yaw_data); //移动完成后开始更新yaw值
|
|
}
|
|
}
|
|
|
|
|