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

rosserial_arduino service

asked 2011-11-07 09:54:27 -0500

mcsmith gravatar image

updated 2012-02-27 07:35:47 -0500

kwc gravatar image

I'm a newbie trying to get a ROS service running on an Arduino-based node. My first attempt was to get the basic client/server code working on my Ubuntu system. I've got the basics working and now want to migrate the server code to the Arduino. Can someone suggest how to bridge the gap between the command-line development tools (rosmake, srv_gen files, etc.) to the Arduino IDE?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2011-11-08 03:51:48 -0500

fergs gravatar image

Service servers aren't that well documented yet as they are still experimental. First off, make sure you are using rosserial 0.3.0 or newer (as previous versions did not include working services).

If you have a service defined in a .srv file, you can use the make_library.py script to export the definitions into header files (see this tutorial). From there the code for a service server callback is very similar to that found in roscpp, an example can be found in ros_lib/examples/ServiceServer/ServiceServer.pde

edit flag offensive delete link more

Comments

The tutorial gives me: roslib.packages.InvalidROSPkgException: Cannot locate installation of package /opt/ros/electric/ros/myDir: [rospack] couldn't find package [/opt/ros/electric/ros/myDir]. ROS_ROOT[/opt/ros/electric/ros] ROS_PACKAGE_PATH[/home/mcsmith/ros_workspace:/opt/ros/electric/stacks]
mcsmith gravatar image mcsmith  ( 2011-11-08 10:28:34 -0500 )edit
You're invoking it wrong -- your package name is not "/opt/ros/electric/ros/myDir".. the package name you supply should be the name of the package (maybe that is myDir?) not the path.
fergs gravatar image fergs  ( 2011-11-08 18:05:40 -0500 )edit
Arduino compile error: cannot declare field ‘...::header’ to be of abstract type ‘std_msgs::Header’ .../ros_lib/std_msgs/Header.h:14: note: because the following virtual functions are pure within ‘std_msgs::Header’: .../ros_lib/ros/msg.h:44: note: virtual int ros::Msg::serialize(unsigned char*)
mcsmith gravatar image mcsmith  ( 2011-11-09 05:29:19 -0500 )edit
Make sure that all of your <sketchbook>/libraries/ros_lib is updated to the newest messages. We changed the definition of serialize to be a const function between 0.2.0 and 0.3.0 releases.
fergs gravatar image fergs  ( 2011-11-09 07:29:27 -0500 )edit
Yes, the header files all contain "virtual int serialize(unsigned char *outbuffer) const".
mcsmith gravatar image mcsmith  ( 2011-11-09 08:33:36 -0500 )edit
Does msg.h though?
fergs gravatar image fergs  ( 2011-11-09 10:26:59 -0500 )edit
No, it's: "virtual int serialize(unsigned char *outbuffer) = 0;"
mcsmith gravatar image mcsmith  ( 2011-11-10 07:15:20 -0500 )edit
then it's not up to date.... you need to update *all* the files in the ros_lib folder
fergs gravatar image fergs  ( 2011-11-10 08:18:52 -0500 )edit

Question Tools

Stats

Asked: 2011-11-07 09:54:27 -0500

Seen: 2,039 times

Last updated: Nov 08 '11