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

mrtechnology1312's profile - activity

2017-06-06 13:23:24 -0500 received badge  Famous Question (source)
2017-05-03 17:34:28 -0500 received badge  Notable Question (source)
2017-03-10 11:49:16 -0500 received badge  Popular Question (source)
2017-03-09 12:18:25 -0500 answered a question How to subscribe to ros_arduino_msgs?

For anyone else who might need to do this:

In CMakeLists.txt I had (among other things):

find_package(catkin REQUIRED COMPONENTS    
  ros_arduino_msgs    
)

In package.xml I added:

<build_depend>ros_arduino_msgs</build_depend>

and

<run_depend>ros_arduino_msgs</run_depend>

And in my C++ file I had (among other things):

#include "ros_arduino_msgs/Digital.h"

int start_val = 0;

void start(const ros_arduino_msgs::DigitalConstPtr& msg) {
    start_val = msg->value;
}

int main(int argc, char * argv[]) {
    ros::init(argc, argv, "test_node");

    ros::NodeHandle nh;
    ros::Subscriber start_sub = nh.subscribe("/arduino/sensor/start_led",1,start);

    while(start_val==0) {
        ros::spinOnce();
    }

    //do other things
}

I was just using this within another program to make sure it didn't start until one of my LED values was 1.

2017-03-09 11:58:24 -0500 commented question How to subscribe to ros_arduino_msgs?

Thanks for the help! Looks like I had set up the dependencies wrong and I found the correct way after a little searching. I'll post how I did it as an answer.

2017-03-08 19:54:52 -0500 asked a question How to subscribe to ros_arduino_msgs?

I'm using the ROSArduinoBridge to connect an ODROID to an Arduino and I'd like to subscribe to a digital sensor topic that the ROSArduinoBridge is publishing. I can't figure out the C++ syntax to be able to do this. Has anyone ever done this before and would be able to help me figure this out? I've checked the basic ROS Subscriber tutorials and tried to #include "ros_arduino_msgs/Digital.h", but the compiler says it can't find that file and I don't know what it should be. Any help would be appreciated, thanks!