0
$\begingroup$

Rosanswers logo

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?


Originally posted by mcsmith on ROS Answers with karma: 66 on 2011-11-07

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by fergs with karma: 13902 on 2011-11-08

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by mcsmith on 2011-11-16:
OK, I'm back from distractions and have an LED that I can use to trace the execution of my code on the Arduino. After nodeHandle.initNode() executes, should "rosnode list" or "rosservice list" show anything? I'm not seeing anything.

Comment by mcsmith on 2011-11-11:
I take it that I need to do something like debugging through a blinking LED. That may take a bit to get set up here. Thanks so much for the patience and perseverance with a newbie.

Comment by fergs on 2011-11-10:
You can't have the arduino serial port monitor connected at the same time as the serial_node.py program -- and until the serial_node.py node is connected, you won't be able to see anything from the Arduino.

Comment by mcsmith on 2011-11-10:
Fixed. Now when nodeHandle.initNode() executes on the Arduino, the serial port monitor captures nonsense data, which I assume is binary data used for registering with the ROS master. However I can't subsequently write to the serial port and "rosnode list" doesn't show the Arduino node.

Comment by fergs on 2011-11-10:
then it's not up to date.... you need to update all the files in the ros_lib folder

Comment by mcsmith on 2011-11-10:
No, it's: "virtual int serialize(unsigned char *outbuffer) = 0;"

Comment by fergs on 2011-11-09:
Does msg.h though?

Comment by mcsmith on 2011-11-09:
Yes, the header files all contain "virtual int serialize(unsigned char *outbuffer) const".

Comment by fergs on 2011-11-09:
Make sure that all of your /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.

Comment by mcsmith on 2011-11-09:
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*)

Comment by fergs on 2011-11-08:
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.

Comment by mcsmith on 2011-11-08:
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]

$\endgroup$

Your Answer

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