#define Vcomf 0.2;
float ang = 0.75634; // ang and dis are calculated from another function, I can sure ang has value not empty.
float dis = 13.2353;
void Avoid::global_control() {
get_obstacle_info();
if (ang > 0) {
ROS_INFO("Start turn left");
vel.angular.z = 0.1;
float time = ang / vel.angular.z;
ROS_INFO("time to totate: %f", time);
pub.publish(vel);
ros::Duration(time).sleep();
ROS_INFO("Rotate finish");
} else {
ROS_INFO("Start turn right");
vel.angular.z = -0.1;
float time = ang / vel.angular.z;
ROS_INFO("time to totate: %f", time);
pub.publish(vel);
ros::Duration(time).sleep();
ROS_INFO("Rotate finish");
}
ROS_INFO("Start move forward");
vel.linear.x = Vcomf;
vel.angular.z = 0;
pub.publish(vel);
// ros::Duration(dis / vel.linear.x).sleep();
// vel.linear.x = 0;
// pub.publish(vel);
}
I create the code like this, and try to make the robot rotate for a specified time then move straight.However, the robot didn’t rotate but stop for a specified time them move forward. Could any one help me with this problem?