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

unable to use custom messages on arduino

asked 2013-03-07 11:13:12 -0600

hd271 gravatar image

updated 2013-03-07 20:31:20 -0600

fergs gravatar image

Hi Guys,

I'm trying to write a ros publisher on an arduino Uno using a custom message type and am running into compile errors for the arduino code. I followed the instructions here: link:http://ros.org/wiki/rosserial_arduino/Tutorials/Adding%20Custom%20Messages#Adding_Custom_Messages.28Generating_Message_Header_File.29 (Rosserial_arduino custom messages) and I'm able to include the generated header file. I then get the following error when I try to instantiate a variable of the message type:

I2C_Send_and_Receive.cpp:21:25: error: cannot declare variable ‘encoders’ to be of abstract type ‘GCRobotics::Encoder_msg’
In file included from I2C_Send_and_Receive.cpp:7:0:
/home/josh/sketchbook/libraries/ros_lib/GCRobotics/Encoder_msg.h:12:9: note:   because the following virtual functions are pure within ‘GCRobotics::Encoder_msg’:
In file included from /home/josh/sketchbook/libraries/ros_lib/std_msgs/Time.h:7:0,
                 from /home/josh/sketchbook/libraries/ros_lib/ros/node_handle.h:38,
                 from /home/josh/sketchbook/libraries/ros_lib/ros.h:38,
                 from I2C_Send_and_Receive.cpp:5:
/home/josh/sketchbook/libraries/ros_lib/ros/msg.h:44:19: note:  virtual int ros::Msg::serialize(unsigned char*) const
/home/josh/sketchbook/libraries/ros_lib/ros/msg.h:47:28: note:  virtual const char* ros::Msg::getMD5()

My code for creating it looks like this:

#include <ros.h>
#include <Wire.h>
#include <GCRobotics/Encoder_msg.h>
#include <GCRobotics/i2cData.h>
#include <std_msgs/String.h>

#include <TimerOne.h>

ros::NodeHandle n;
//std_msgs::String encoders;
GCRobotics::Encoder_msg encoders;
ros::Publisher pub("EncoderData", &encoders);

Im using Groovy and arduino 1.0.1, Any ideas on what I'm doing wrong or missing?

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2013-03-07 20:28:25 -0600

fergs gravatar image

Under groovy (and even under Fuerte to a lesser extent) the older rosserial package is pretty busted (as it depended on internal roslib functions that have changed/disappeared). I would suggest trying out the new catkin-based version hosted here: https://github.com/ros-drivers/rosserial -- it will automatically build all messages for all installed packages found by rospack when running the make_libraries script. Please do read the README as the workflow has changed (but is probably simpler) from the past.

edit flag offensive delete link more

Comments

Awesome, that worked for one of my machines, but the other machine i'm running gives me this error when running make_libraries.py: rospkg.common.ResourceNotFound: kobuki_qtestsuite. But as long as one of them generates them, I guess I can just copy to the other. Thanks for your help!

hd271 gravatar image hd271  ( 2013-03-08 10:33:44 -0600 )edit

I've patched rosserial temporarily to blacklist kobuki_testsuite. There is a ticket for it as well for a future, proper, patch (https://github.com/ros-drivers/rosserial/issues/30)

fergs gravatar image fergs  ( 2013-03-08 19:31:09 -0600 )edit

Question Tools

Stats

Asked: 2013-03-07 11:13:12 -0600

Seen: 1,430 times

Last updated: Mar 07 '13