1
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ If this worked can u provide me with the script please? $\endgroup$ Commented Oct 17, 2020 at 15:35

2 Answers 2

1
$\begingroup$

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.

$\endgroup$
5
  • $\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$
    – Anonymous
    Commented Oct 14, 2020 at 17:25
  • $\begingroup$ @Anonymous - Numerically integrate your speed. $\endgroup$
    – Chuck
    Commented 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$
    – Sankeerth
    Commented Oct 15, 2020 at 6:19
  • $\begingroup$ Got this! And what about the maximum value being the circumference? $\endgroup$
    – Anonymous
    Commented 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$
    – Sankeerth
    Commented Oct 16, 2020 at 6:16
0
$\begingroup$
$ 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.

$\endgroup$
3
  • $\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$
    – Anonymous
    Commented 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
    Commented Oct 14, 2020 at 13:01
  • $\begingroup$ I have to stop the turtle by tracking the distance. $\endgroup$
    – Anonymous
    Commented Oct 14, 2020 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.