Ask Your Question
2

Macro for nodes in launch file

asked 2017-01-18 09:26:49 -0500

snekbot gravatar image

I'm trying to use the PID package to control the joints of a snake robot. Since each node will be single controller, I need to start several nodes to control all the joints. The pid nodes have several parameters, so I hope to be able to write some form of macro that can make my launch file more compact and manageable. I found out that launch files are written in XML and not Xacro, so I can't use macros like you can for the URDF files. Does anyone know a clever way to do this?

edit retag flag offensive close merge delete

Comments

launch files are written in XML and not Xacro, so I can't use macros like you can for the URDF files

This is incorrect. xacro should be able to generate any xml format, and xacro is also in xml format.

130s gravatar image 130s  ( 2021-01-07 01:36:30 -0500 )edit

Specifically for include-ing a .launch file so this isn't exactly for node, but #q229489 is a good option that doesn't require customization (i.e. needed functionality is in the library).

130s gravatar image 130s  ( 2021-01-07 01:42:35 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2017-01-19 22:28:06 -0500

Thomas D gravatar image

I don't know of a way to have macros or for loops in launch files.

One option is to have a separate yaml file for each controller that contains the parameter values for a single controller. In your launch file you would have to list out each <node> separately but you could have something like this that uses the rosparam tag:

<node pkg="pid" type="controller" name="pid1">
  <rosparam command="load" file="$(arg your_package)/config/pid1.yaml"/>
</node>

Repeat that block N times and have N yaml files. The pid1.yaml file would look like (follow the link above for more examples):

Kp: 1.0
Ki: 0.1
Kd: 0.2
upper_limit: 5.0
lower_limit: 0.2
windup_limit: 10.0
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-01-18 09:26:49 -0500

Seen: 362 times

Last updated: Jan 19 '17