Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 59

Subscribing to a Bool msg via rosserial_arduino.

$
0
0
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::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::Subscriber(const char*, ros::Subscriber::CallbackT, int) [with MsgT = std_msgs::Bool; ros::Subscriber::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!!!

Viewing all articles
Browse latest Browse all 59

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>