Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ExecuteProcess cmd parameter treatment 'The passed value needs to be a dictionary in YAML format' #382

Closed
ddengster opened this issue Feb 17, 2020 · 4 comments

Comments

@ddengster
Copy link

Bug report

Steps to reproduce issue

ros2 launch mypkgname mylaunchfile.launch.py


import launch
import launch.actions 
import launch.substitutions 
import launch_ros.actions
import os

from launch_ros.actions import Node

def generate_launch_description():
  
  return launch.LaunchDescription([
    launch.actions.ExecuteProcess(
      name='fake_joint_calibration',
      cmd = ['ros2', 'topic', 'pub', '/calibrated', 'std_msgs/Bool', '"data: 1"'],
      output = 'screen',
      shell='True'
      )
  ])

Expected behavior

The same as running the following on the cmdline

ros2 topic pub /calibrated std_msgs/Bool "data: 1"

Output:

publisher: beginning loop
publishing #1: std_msgs.msg.Bool(data=True)

publishing #2: std_msgs.msg.Bool(data=True)

...

Actual behavior

Output gives:

[fake_joint_calibration-1] The passed value needs to be a dictionary in YAML format

Additional information

I'd also like to know how the cmd parameters work; I've had other related weirdness with my parameters being treated like yaml. Why is that so and is there a workaround for this?

@ivanpauno
Copy link
Member

ros2 topic pub expects the value to be a dictionary in yaml format:

def generate_launch_description():
  
  return launch.LaunchDescription([
    launch.actions.ExecuteProcess(
      name='fake_joint_calibration',
      cmd = ['ros2', 'topic', 'pub', '/calibrated', 'std_msgs/Bool', '"{data: True}"'],
      output = 'screen',
      shell='True'
      )
  ])

That should work.

Closing, as it's unrelated to launch.

@jeremy-shannon
Copy link

Hi, I know this topic is closed but I was having the same problem and this is the only place I found anything about it whatsoever. I think it's worth noting for anyone else who might come along that I tried your suggestion:

def generate_launch_description():
  
  return launch.LaunchDescription([
    launch.actions.ExecuteProcess(
      name='fake_joint_calibration',
      cmd = ['ros2', 'topic', 'pub', '/calibrated', 'std_msgs/Bool', '"{data: True}"'],
      output = 'screen',
      shell='True'
      )
  ])

...and still got the 'The passed value needs to be a dictionary in YAML format' error. But changing the 'cmd' line to the following (i.e. removing the double quotes) ended up working:

cmd = ['ros2', 'topic', 'pub', '/calibrated', 'std_msgs/Bool', '{data: True}'],

@asymingt
Copy link

Thank you @jeremy-shannon -- I spent about an hour trying to work this out, trying various combinations of yaml.dump(), single and double quotations! It was your observation that helped get my code working.

@jeremy-shannon
Copy link

@asymingt

Thank you @jeremy-shannon -- I spent about an hour trying to work this out, trying various combinations of yaml.dump(), single and double quotations! It was your observation that helped get my code working.

Nice! I’m glad to hear it helped. 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants