Hello All!
I'm in the process of building a tool for a robot that I'm working with and we are trying to use an Arduino to communicate with ROS to control the end effector. We are right now broadcasting a Boolean topic via a separate node, and we would like the Arduino node to subscribe to the topic and then do an operation based off of the true/false state of the topic.
In my callback I have:
void messageCB(const std_msgs::Bool::ConstPtr& state)
{
if (state.data = true)
{
//do stuff
}
But I keep getting many errors:
rotational_table_node.ino:17:22: error: ‘ConstPtr’ in ‘class std_msgs::Bool’ does not name a type
rotational_table_node.ino:17:48: error: ISO C++ forbids declaration of ‘state’ with no type [-fpermissive]
rotational_table_node.ino: In function ‘void messageCB(const int&)’:
rotational_table_node.ino:21:13: error: request for member ‘data’ in ‘state’, which is of non-class type ‘const int’
rotational_table_node.ino: At global scope:
rotational_table_node.ino:54:76: error: invalid conversion from ‘void (*)(const int&)’ to ‘ros::Subscriber<std_msgs::Bool>::CallbackT {aka void (*)(const std_msgs::Bool&)}’ [-fpermissive]
In file included from /home/motherbrain/sketchbook/libraries/ros_lib/ros/node_handle.h:84:0,
from /home/motherbrain/sketchbook/libraries/ros_lib/ros.h:38,
from rotational_table_node.ino:5:
/home/motherbrain/sketchbook/libraries/ros_lib/ros/subscriber.h:97:7: error: initializing argument 2 of ‘ros::Subscriber<MsgT, void>::Subscriber(const char*, ros::Subscriber<MsgT, void>::CallbackT, int) [with MsgT = std_msgs::Bool; ros::Subscriber<MsgT, void>::CallbackT = void (*)(const std_msgs::Bool&)]’ [-fpermissive]
Subscriber(const char * topic_name, CallbackT cb, int endpoint=rosserial_msgs::TopicInfo::ID_SUBSCRIBER) :
^
Any idea what I'm doing wrong or could do differently?
Thanks!!!
Originally posted by atomoclast on ROS Answers with karma: 151 on 2016-09-07
Post score: 1