ROS TURTLESIM using PYTHON

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 ??

• If this worked can u provide me with the script please? – Phantom Boy Oct 17 '20 at 15:35

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.

• 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. – Anonymous Oct 14 '20 at 17:25
• @Anonymous - Numerically integrate your speed. – Chuck Oct 14 '20 at 17:45
• take initial time as t0 and present time as t1, speed = v, then your distance is v*(t1-t0) – Sankeerth Reddy Prodduturi Oct 15 '20 at 6:19
• Got this! And what about the maximum value being the circumference? – Anonymous Oct 15 '20 at 12:14
• the maximum value of your distance should be circumference for your turtle to stop after 1 circle. – Sankeerth Reddy Prodduturi Oct 16 '20 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.

• 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? – Anonymous Oct 13 '20 at 18:42
• @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. – Chuck Oct 14 '20 at 13:01
• I have to stop the turtle by tracking the distance. – Anonymous Oct 14 '20 at 15:06