ROS Answers: Open Source Q&A Forum - RSS feedhttps://answers.ros.org/questions/Open source question and answer forum written in Python and DjangoenROS Answers is licensed under Creative Commons Attribution 3.0Mon, 28 Aug 2017 03:10:32 -0500Calculating distance using linear velocity and time.https://answers.ros.org/question/269691/calculating-distance-using-linear-velocity-and-time/ The general simplest approach in ROS is to calculate the distance by multiplying the time elapsed with the linear velocity. As can be seen from this link http://wiki.ros.org/turtlesim/Tutorials/Moving%20in%20a%20Straight%20Line
Since, i am a beginner in ROS i tried the approach used in games. Which is adding the velocity every time to a current_distance variable initialized to zero. But this approach doesn't work well. Code here https://pastebin.com/c0dJB4XQ
if i want to travel 5 meters in the first method, i will have to enter 50,000 meters to travel the same distance on the screen. I don't seem to figure out this anomaly.
I used turtlesim for my practice and learning.Sun, 27 Aug 2017 21:44:54 -0500https://answers.ros.org/question/269691/calculating-distance-using-linear-velocity-and-time/Answer by ufr3c_tjc for <p> The general simplest approach in ROS is to calculate the distance by multiplying the time elapsed with the linear velocity. As can be seen from this link <a rel="nofollow" href="http://wiki.ros.org/turtlesim/Tutorials/Moving%20in%20a%20Straight%20Line">http://wiki.ros.org/turtlesim/Tutoria...</a></p>
<p> Since, i am a beginner in ROS i tried the approach used in games. Which is adding the velocity every time to a current_distance variable initialized to zero. But this approach doesn't work well. Code here <a rel="nofollow" href="https://pastebin.com/c0dJB4XQ">https://pastebin.com/c0dJB4XQ</a></p>
<p>if i want to travel 5 meters in the first method, i will have to enter 50,000 meters to travel the same distance on the screen. I don't seem to figure out this anomaly.</p>
<p>I used turtlesim for my practice and learning.</p>
https://answers.ros.org/question/269691/calculating-distance-using-linear-velocity-and-time/?answer=269693#post-id-269693You have to enter 50,000 because you are running a while loop which adds the current velocity to a "distance", publishes a command, and then immediately repeats, with no delay. The while loop will run as fast as it can, repeating `distance/linearVel` times (ie, 100,000 times) and then exiting, no matter how far the turtle actually traveled. It just so happened that 50,000 was the magic number for you, and it has no real relationship to the desired 5 metres.
I don't know where your idea came from to take time out of the equation, but please forget it. Distance is always speed integrated over time. Never use anything else. Sun, 27 Aug 2017 22:34:43 -0500https://answers.ros.org/question/269691/calculating-distance-using-linear-velocity-and-time/?answer=269693#post-id-269693Comment by sandhan26 for <p>You have to enter 50,000 because you are running a while loop which adds the current velocity to a "distance", publishes a command, and then immediately repeats, with no delay. The while loop will run as fast as it can, repeating <code>distance/linearVel</code> times (ie, 100,000 times) and then exiting, no matter how far the turtle actually traveled. It just so happened that 50,000 was the magic number for you, and it has no real relationship to the desired 5 metres.</p>
<p>I don't know where your idea came from to take time out of the equation, but please forget it. Distance is always speed integrated over time. Never use anything else. </p>
https://answers.ros.org/question/269691/calculating-distance-using-linear-velocity-and-time/?comment=269704#post-id-269704I think i got your point. Thanks.Mon, 28 Aug 2017 03:10:32 -0500https://answers.ros.org/question/269691/calculating-distance-using-linear-velocity-and-time/?comment=269704#post-id-269704