ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

how to simulate track guided robots (railway vehicle)?

asked 2019-02-15 08:08:08 -0600

obernoob gravatar image

Hi all!

How can I make my robot/train follow an arbitrary path, e.g. a path or profile I generated to simply simulate or let's say "cheat" the track guidance?

Using a camera and image processing to detect the path and make the robot “follow” it is not railway-appropriate. At first I was hoping that I could define a virtual point of the robot/train that always lies on a static profile/curve (which will be the track axle) and then I just apply an unidirectional velocity to the robot/train. But I haven't found a way to do so in the past two months :(

Thank you in advance!

edit retag flag offensive close merge delete



I would recommend you post this over at Gazebo Answers. You don't write it anywhere, but I assume you're looking at doing this in Gazebo.

As a start: Limits of the Simulation.

Edit: I believe you already found that thread. ..

gvdhoorn gravatar image gvdhoorn  ( 2019-02-15 08:26:14 -0600 )edit

.. If so, then I'd still recommend posting on Gazebo Answers, as here on ROS Answers we address ROS issues and Gazebo is a stand-alone simulator (with a ROS integration available). Other simulators may be more appropriate or cut out for this sort of work though.

gvdhoorn gravatar image gvdhoorn  ( 2019-02-15 08:27:55 -0600 )edit

Hi, i am doing the same project (Master thesis) now, it would be great, if we can share somethings together... thanks! email:

myrotrac gravatar image myrotrac  ( 2019-02-20 09:08:08 -0600 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-02-15 11:53:01 -0600

lucasw gravatar image

updated 2019-02-15 11:57:19 -0600

There is probably existing software meant for autonomous cars rather than rail vehicles, but that model streets as series of waypoints that could also represent rails (with many branches at every intersection and extra allowances for lane switching). They could probably be shoehorned for this purpose but I suspect they are complex to get up and running and contain a lot of unwanted code that is hard to separate out from just the street/rail part. Duckietown may be more user friendly than Autoware, for example?

You could put together something simple in a python node that subscribes to a velocity and publishes a tf and messages with the track in them that allow visualization in rviz. The simplest starting point is a track with no branches/switches, so the node could have an array of key point locations (ideally it would have a subscription or a service to add the locations or an entire track in one message, possibly involving a custom message).

Another simplification would be to have straight lines between key points, later that could be replaced with splines for gentle curves.

The position of the rail vehicle is a tf (multiple segments in a train could be added later), which could have a complex 3D model hanging off it in rviz, or a simple Marker cube.

The velocity message could be a regular float, and inside an update loop in your node you would integrate the velocity every update step and track where between two keypoints the vehicle is, and if to advance it to the next set of keypoints once it has moved past one.

The track visualization could be an rviz Marker of type line strip, or a Path.

Integration with a heavy weight simulator like Gazebo could be added later, maybe the position of the vehicle would be set directly every time step from the tf output from this node (though that may not play nice physically with a regular simulated objected that it collides with).

edit flag offensive delete link more


Hey, thanks it helped me a lot, i just wrote a py to control the rail vehicle, i got the skid drive controller, but i can only let the vehicle follow a circle by using linear.x and angular.z), how should i control it with the tf? thanks!

myrotrac gravatar image myrotrac  ( 2019-02-20 09:12:11 -0600 )edit

Set the xyz of the vehicle directly with a tf broadcaster - instead of subscribing to a Pose in the linked example, subscribe to the linear velocity, and update the tf from a timer callback.

lucasw gravatar image lucasw  ( 2019-02-21 08:22:39 -0600 )edit

Thanks! i tried it, but i don't know how i can replace it with my robot... but i'll try it again.. another question: i set the velocity in py like 10m/s, but in gazebo, the robot does't run with 10m/s. is that because of the skid drive controller? so the velocity's set with per wheel not thewholecar

myrotrac gravatar image myrotrac  ( 2019-02-21 09:31:42 -0600 )edit

thx a lot! i set a constant radius about 200m, and w = v/r so i can get the w, so in this case the robot should run along a circle. but the robot runs 95% along the circle, and the radius is about a quarter of the radius (200m)... do you know why? thank you so much!

myrotrac gravatar image myrotrac  ( 2019-02-21 09:34:50 -0600 )edit

The setting of tf directly approach needs to be integrated with gazebo, there may be other questions addressing that. I don't know about the diff drive with gazebo.

lucasw gravatar image lucasw  ( 2019-02-21 10:45:11 -0600 )edit

Question Tools



Asked: 2019-02-15 08:08:08 -0600

Seen: 929 times

Last updated: Feb 15 '19