Get variables in urdf.xacro from the launch file

asked 2019-12-13 06:43:38 -0500

mervinhorst gravatar image

updated 2022-01-22 16:10:12 -0500

Evgeny gravatar image

The situation is as follows:

We, as a student project group, have a model of a car. This car has several sensors, including a gps sensor. The car has to be simulated in a real world location using gazebo and ros. Therefore the gps reference location has to be accurate compared to real life. So, looking at the spawning coordinates of the car should give the same location in f.i. google maps. We have achieved this in the urfd.xacro file of the car but the coordinates are hard coded. However, we would like to declare the coordinates in the launch files. The reason that we want to give the exact coordinated per different maps(worlds) that are launched from different launch file. Currently we have to change the coordinates in the urdf.xacro model every time we change the map.

So to conclude, we would like to set a variable in a launch file and use this value in the urdf.xacro file. Does somebody know how we can achieve this? Thank you very much in advance!

Kind regards,

Student project group from HAN Automotive

edit retag flag offensive close merge delete

Comments

You can probably do what you describe using the support for passing args to xacro, as documented in the Rospack commands section on wiki/xacro.

As you probably have other settings that would need to be easily changed, I'd perhaps recommend to use a proper .yaml file and import that into your .xacro. May be a bit more scalable.

gvdhoorn gravatar image gvdhoorn  ( 2019-12-16 04:00:10 -0500 )edit

Seems to have been cross-posted to Get variables in urdf.xacro from the launch file on Gazebo Answers.

gvdhoorn gravatar image gvdhoorn  ( 2019-12-17 09:33:32 -0500 )edit