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

How to use rosservice call with correct parameter form?

asked 2014-06-11 17:38:59 -0500

updated 2017-07-17 13:36:14 -0500

jayess gravatar image

Hi,

I'm using Roscopter package and want to send some waypoints to my copter.

The /waypoint is a service I can find using rosservice list

they type of /waypoint is roscopter/SendWaypoint I use rossrv show to check the type format:

roscopter/Waypoint waypoint
  uint8 TYPE_NAV=1
  uint8 TYPE_CONDITION_YAW=2
  uint8 TYPE_CONDITION_CHANGE_ALT=3
  uint8 TYPE_TAKEOFF=4
  int32 latitude
  int32 longitude
  int32 altitude
  uint16 pos_acc
  uint8 speed_to
  uint16 hold_time
  int32 yaw_from
  int32 pan_angle
  int32 tilt_angle
  uint8 waypoint_type
---
bool result

then I run the command: rosservice call /waypoint 15 22 0 40 0 30 3 0 0 0

I put 10 arguments for 10 parameters but got the error:

ERROR: Incompatible arguments to call service:
Too many arguments:
 * Given: [15, 22, 0, 40, 0, 30, 3, 0, 0, 0]
 * Expected: ['waypoint']
Provided arguments are:
 * 15 (type int)
 * 22 (type int)
 * 0 (type int)
 * 40 (type int)
 * 0 (type int)
 * 30 (type int)
 * 3 (type int)
 * 0 (type int)
 * 0 (type int)
 * 0 (type int)

Service arguments are: [waypoint.latitude waypoint.longitude waypoint.altitude waypoint.pos_acc waypoint.speed_to waypoint.hold_time waypoint.yaw_from waypoint.pan_angle waypoint.tilt_angle waypoint.waypoint_type]

the content of waypoint.msg

# latitude and longitude given in decimal degrees (* 10^7)
int32 latitude
int32 longitude

# height in mm
int32 altitude

# posAcc given in mm
uint16 pos_acc

# max speed to travel to waypoint in % of 100
uint8 speed_to

# time to stay at waypoint in ms
uint16 hold_time

# yawFrom angle given in degrees (* 1000)
int32 yaw_from

# camera pan and tilt angles during waypoint travel given in degrees (* 1000)
int32 pan_angle
int32 tilt_angle

# Type of Waypoint
uint8 waypoint_type

uint8 TYPE_NAV = 1
uint8 TYPE_CONDITION_YAW = 2
uint8 TYPE_CONDITION_CHANGE_ALT = 3
uint8 TYPE_TAKEOFF = 4

Then I used the following format but there is still an error:

>rosservice call /waypoint "{waypoint.latitude: 15, waypoint.longitude: 22, waypoint.speedTo: 0, waypoint.altitude: 40, waypoint.hold_time: 0, waypoint.yaw_from: 30, waypoint.pos_acc: 3, waypoint.pan_angle: 0,waypoint.tilt_angle: 0,waypoint_type: 1}"

ERROR: Incompatible arguments to call service:
No field name [waypoint.longitude]
Provided arguments are:
 * {'waypoint.longitude': 22, 'waypoint.speedTo': 0, 'waypoint.altitude': 40, 'waypoint.tilt_angle': 0, 'waypoint.pan_angle': 0, 'waypoint.latitude': 15, 'waypoint.hold_time': 0, 'waypoint.yaw_from': 30, 'waypoint_type': 1, 'waypoint.pos_acc': 3} (type dict)

Service arguments are: [waypoint.latitude waypoint.longitude waypoint.altitude waypoint.pos_acc waypoint.speed_to waypoint.hold_time waypoint.yaw_from waypoint.pan_angle waypoint.tilt_angle waypoint.waypoint_type]

So I think I should send all the data in one group as the type waypoint, but I don't know what to do...

Thanks

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
4

answered 2014-07-03 07:53:02 -0500

BennyRe gravatar image

updated 2014-07-03 08:11:57 -0500

Just hit tab after typing rosservice call /waypoint and your shell will present you an empty message body which you can fill with values.

If this does not work try rosservice call /waypoint roscopter/SendWaypoint and then tab.

edit flag offensive delete link more

Comments

Thanks but after I entered tab it became `rosservice call /waypoint Usage: rosservice type /service` followed by an error `rosservice: error: service must be specified`

lanyusea gravatar image lanyusea  ( 2014-07-03 08:01:39 -0500 )edit

well, nothing showed up this time...

lanyusea gravatar image lanyusea  ( 2014-07-03 08:25:17 -0500 )edit

My shell doesn't show anything but an error. Usage: rosservice call /service [args...]

Jägermeister gravatar image Jägermeister  ( 2019-06-27 08:09:13 -0500 )edit
1

answered 2014-07-03 08:41:58 -0500

updated 2014-07-03 08:44:49 -0500

well, I think I find the answer, accidently

I'm using zsh instead of bash, I tried once using format

rosservice call /waypoint [15,22,0,40,0,30,3,0,0,1]

but the return is

zsh: no matches found: [15,22,0,40,0,30,3,0,0,1]

I changed into bash just know and tried the same command, but there is no error:

>rosservice call /waypoint [15,22,0,40,0,30,3,0,0,1]
result: False

then I think that is the correct form and there is sth wrong with my zsh,

after google I add an alias in my .zshrc alias rosservice='noglob rosservice' and then I got the same result in zsh return false

so the format problem is solved out, but now I need to find out why it return false....


but I'm still wondering is there exist a more readable format like what I use in the question?

Because I think putting every argument inside [] without telling which is which is not quite user-friendly

edit flag offensive delete link more

Comments

Please always add some information about your system. Most ROS users use Ubuntu and Bash, so this is assumed if nothing else is mentioned.

BennyRe gravatar image BennyRe  ( 2014-07-03 08:55:50 -0500 )edit

@BennyRe thanks for your suggestion, I will add more detail in my future asking

lanyusea gravatar image lanyusea  ( 2014-07-03 09:02:43 -0500 )edit

@lanyusea Did you have any luck with rosservice call /waypoint. I am also getting a "result: False" and can't figure out why...

AllieCat_Duncan gravatar image AllieCat_Duncan  ( 2014-09-28 14:14:27 -0500 )edit

@AllieCat_Duncan really old question. I remember I change my shell from Zsh to Bash, then it works.

lanyusea gravatar image lanyusea  ( 2019-06-27 08:27:23 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2014-06-11 17:38:59 -0500

Seen: 7,794 times

Last updated: Jul 03 '14