Trying to turn to a specified angle. [closed]
So I am trying to turn to a angle to face a goal I have the code working but the angle count resets at 90 and the robot never stops why? Why does it not count the full 360 degrees? why does it not stop at around 90 degrees? Simple piece of code that stops at x degrees/radians? This all taken from online tutorials so I dont get why its not doing what it says it should.
geometry_msgs::Twist twist;
double angSpeed = 0.3;
double t0 = ros::Time::now().toSec();
double current_angle = 0.0;
double relative_angle = M_PI/2;
do{
twist.angular.z = angSpeed;
vel.publish(twist);
double t1 = ros::Time::now().toSec();
current_angle = angSpeed * (t1-t0);
ROS_INFO( "time:[%f],current_angle:[%f], relative_angle:[%f] " , t1-t0, current_angle * 57.29, relative_angle * 57.29);
ros::spinOnce();
loop_rate.sleep();
}while(current_angle < relative_angle) ;
twist.angular.z =0;
vel.publish(twist);