0
$\begingroup$

Rosanswers logo

Hi,

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'
lift_id.site = 'd'
lift_id.location = 'e'
lift_id.group = 'f'
lift_id.lift = 'g'
req.array.append(lift_id)
...

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.


Originally posted by Marc Testier on ROS Answers with karma: 203 on 2018-09-26

Post score: 1

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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.


Originally posted by marguedas with karma: 3606 on 2018-09-29

This answer was ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.