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

Ros 2 command line service call with array of custom msg

asked 2018-09-26 04:10:45 -0600

Marc Testier gravatar image


I'm using ROS 2 Bouncy on Ubuntu 18 and I'm trying to call a service from command line. I can't seem to formulate a good srv while using the command line and get an error : Failed to populate field 'array': The 'array' field must be a set or sequence and each value of type 'LiftId'

The command I'm using is :

ros2 service call /get_lift_info_array kone_open_opc_interfaces/GetLiftInfoArray "
    array: [
            gateway_ip: 'a', 
            gateway_port: 1, 
            opc_serv_ip: 'b', 
            opc_serv_type: 'v', 
            site: 'd', 
            location: 'e', 
            group: 'f', 
            lift: 'g'

So I have a srv file called GetLiftInfoArray.srv:

LiftId[] array

And LiftId.msg is defined as bellow:

string gateway_ip
int32 gateway_port
string opc_serv_ip
string opc_serv_type
string site
string location
string group
string lift

To note that I can make it works when the array is empty :

ros2 service call /get_lift_info_array kone_open_opc_interfaces/GetLiftInfoArray "
    array: [

And I can also make it works when I use a python file with a client calling the service :

cli = node.create_client(GetLiftInfoArray, 'get_lift_info_array')

req = GetLiftInfoArray.Request()
req.array = []
lift_id = LiftId()
lift_id.gateway_ip = 'a'
lift_id.gateway_port = 1
lift_id.opc_serv_ip = 'b'
lift_id.opc_serv_type = 'c' = 'd'
lift_id.location = 'e' = 'f'
lift_id.lift = 'g'

It works, but I would like to be able to use the command line, does anyone have any idea of what's wrong with my command ?

Thank you.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2018-09-29 07:30:22 -0600

marguedas gravatar image

There is nothing wrong with your command :), this is currently not possible to populate nested / complex messages via command line. Here are some links about the issue and what feature is missing to enable it.

edit flag offensive delete link more

answered 2019-07-26 07:13:37 -0600

madmax gravatar image

As this was closed as duplicate, and this question here seems to be the first one, I post the answer here:

ros2 topic pub /cmd_vel geometry_msgs/Twist "{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.2}}"
edit flag offensive delete link more

Question Tools



Asked: 2018-09-26 04:10:45 -0600

Seen: 2,730 times

Last updated: Jul 26 '19