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

Calling a rosservice with args from a launch file

asked 2022-02-16 10:22:59 -0600

Benjamin C gravatar image

updated 2022-02-23 03:26:09 -0600

Hello there ! Hope u are doing well,

I'm trying to call a rosservice directly from a launch file, i used this questions to write my own node and it turned out like that:

<node pkg="rosservice" type="rosservice" name="chg_ctrl" args="call --wait /controller_manager/switch_controller 
    start_controllers:[joint_group_vel_controller]
    stop_controllers:[scaled_pos_joint_traj_controller]
    strictness:1
    start_asap:false
    timeout:0.0" />

It is almost working because i get this message:

ERROR: Incompatible arguments to call service:
Field [start_controllers] must be a list or tuple instead of: str
Provided arguments are:
 * start_controllers:[joint_group_vel_controller] (type str)
 * stop_controllers:[scaled_pos_joint_traj_controller] (type str)
 * strictness:1 (type str)
 * start_asap:false (type str)
 * timeout:0.0 (type str)

Service arguments are: [start_controllers stop_controllers strictness start_asap timeout]

I tried a couple of things and I can't get rid of this error, did anyone already tried someting like that ?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2022-02-19 02:31:43 -0600

miura gravatar image

updated 2022-02-23 16:46:11 -0600

I think the following method of using &quot; to represent double quotation marks will work well.

<node pkg="rosservice" type="rosservice" name="chg_ctrl" args="call --wait /controller_manager/switch_controller 
    &quot;{ start_controllers: [joint_group_vel_controller],
    stop_controllers: [scaled_pos_joint_traj_controller],
    strictness: 1,
    start_asap: false,
    timeout: 0.0 }&quot;" />
edit flag offensive delete link more

Comments

HI Miura, thank you for your suggestion ! Using your code it definitely improved the result but not quite enough:

ERROR: Incompatible arguments to call service:
No field name [strictnes:1]
Provided arguments are:
 * {'start_controllers': ['joint_group_vel_controller'], 'stop_controllers': ['scaled_pos_joint_traj_controller'], 'strictnes:1': None, 'start_asap:false': None, 'timeout:0.0': None} (type dict)
Benjamin C gravatar image Benjamin C  ( 2022-02-21 03:31:49 -0600 )edit

Thank you for trying. You may need a space after the colon. I have updated the answer.

miura gravatar image miura  ( 2022-02-21 10:56:37 -0600 )edit

And now it does work !!! Thank you very much ! Could you just edit your answer to add the missing "s" at strictnes: 1 please ? Have a great day !

Benjamin C gravatar image Benjamin C  ( 2022-02-23 03:23:36 -0600 )edit

Congratulations! The missing "s" has been added. Thanks for pointing it out.

miura gravatar image miura  ( 2022-02-23 16:47:04 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2022-02-16 10:22:59 -0600

Seen: 298 times

Last updated: Feb 23 '22