Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.