In ROS TURTLESIM, While moving the turtle in circle using the linear velocity and angular velocity , how do i track the distance so as to stop the turtle moving after one revolution ??
2 Answers
write a distance function with the maximum value being the circumference, use rospy's Time function to update distance and whenever the current_distance exceeds the circumference, publish a zero velocity msg to stop the turtle.
-
$\begingroup$ How do i use rospy's time to get the distance?? Rospy's time will only give the current time right? I am new to ROS, so please help me! And how do i use "/turtle1/pose" to get the distance and stop the turtle. $\endgroup$ Oct 14, 2020 at 17:25
-
$\begingroup$ @Anonymous - Numerically integrate your speed. $\endgroup$– Chuck ♦Oct 14, 2020 at 17:45
-
$\begingroup$ take initial time as t0 and present time as t1, speed = v, then your distance is v*(t1-t0) $\endgroup$ Oct 15, 2020 at 6:19
-
$\begingroup$ Got this! And what about the maximum value being the circumference? $\endgroup$ Oct 15, 2020 at 12:14
-
$\begingroup$ the maximum value of your distance should be circumference for your turtle to stop after 1 circle. $\endgroup$ Oct 16, 2020 at 6:16
$ rosmsg show turtlesim/Pose
Get the pose. How are you wanting to know if it did a complete revolution? You could check that the path length is equal to the circumference, or that the rotation angle is back to the start angle, or the horizontal x/y position is the same as the starting position.
-
$\begingroup$ Like i want to stop the turtle after one revolution. How do i stop the turtle at its position which is moving in a circle? $\endgroup$ Oct 13, 2020 at 18:42
-
$\begingroup$ @Anonymous - I don't understand the question. Your original question was how to track the distance, but now you seem to be asking how to stop the turtle. $\endgroup$– Chuck ♦Oct 14, 2020 at 13:01
-
$\begingroup$ I have to stop the turtle by tracking the distance. $\endgroup$ Oct 14, 2020 at 15:06