Trying to turn to a specified angle. [closed]

asked 2018-02-19 11:52:03 -0500

atom12 gravatar image

updated 2018-02-19 11:55:49 -0500

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;
        twist.angular.z = angSpeed;
        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);
    }while(current_angle < relative_angle) ;
        twist.angular.z =0;
edit retag flag offensive reopen merge delete

Closed for the following reason duplicate question by atom12
close date 2018-02-19 14:52:31.901334