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

Sensor data via USB

asked 2018-07-23 06:24:22 -0600

S.Yildiz gravatar image

Im working on a project and i want to use a sensor. I can plug in the sensor via usb. I do not need any driver for the sensor. My task is to have an access to the sensor data. I have followed the tutorial on this page: But i dont know if this is my soution. I dont know what to do now. How can i have access to the data in ROS? Do I have to write a wrapper node? If yes, how?

edit retag flag offensive close merge delete


How can I take raw data from the sensors and publish it to a ROS topic?

S.Yildiz gravatar image S.Yildiz  ( 2018-07-23 06:30:17 -0600 )edit

How do you usually access the data without ROS? Is there a program you run? Or is it like a mouse that you just plug and play? I think you might need a wrapper to capture the stream of data.

bpinaya gravatar image bpinaya  ( 2018-07-23 06:30:38 -0600 )edit

I can have access to the data on windows. I have to install a software(Docklight) and configure the setting for the sensor like the baudrate etc. If i do this i get all the data on the software listed. Yes like a mouse. And how can i write a wrapper? is there any tutorial for this?

S.Yildiz gravatar image S.Yildiz  ( 2018-07-23 06:33:45 -0600 )edit

ROS works on Linux, did you get it to run on Windows? I think you should find how the data is being communicated (maybe serial? in that case check ). More info on the sensor would be helpful, but btw if you have to use Windows it seems quite hard to do.

bpinaya gravatar image bpinaya  ( 2018-07-23 08:04:07 -0600 )edit

So it is a sensor for detecting the range between two modules. No, I dont have to use Windows. There is just a software which can read the data supported on windows. And yes the communicatian is serial.

S.Yildiz gravatar image S.Yildiz  ( 2018-07-23 08:19:25 -0600 )edit

Btw I replied down below.

bpinaya gravatar image bpinaya  ( 2018-07-31 02:54:06 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2018-07-25 04:29:39 -0600

bpinaya gravatar image

updated 2018-07-25 07:11:52 -0600

Okay with the info provided I think I can sort of give some help. Check this past answer too btw.

So you in order to get the data in ROS, you need to make a wrapper for your sensor, if you know it's serial communication check the serial support for ROS here.

Also the guy from the answer made a nice simple example of ROS serial communication here

From his code:

#include <ros/ros.h>
#include <serial/serial.h>
#include <std_msgs/String.h>
#include <std_msgs/Empty.h>

serial::Serial ser;

void write_callback(const std_msgs::String::ConstPtr& msg){
    ROS_INFO_STREAM("Writing to serial port" << msg->data);

int main (int argc, char** argv){
    ros::init(argc, argv, "serial_example_node");
    ros::NodeHandle nh;

    ros::Subscriber write_sub = nh.subscribe("write", 1000, write_callback);
    ros::Publisher read_pub = nh.advertise<std_msgs::String>("read", 1000);

        serial::Timeout to = serial::Timeout::simpleTimeout(1000);
    catch (serial::IOException& e)
        ROS_ERROR_STREAM("Unable to open port ");
        return -1;

        ROS_INFO_STREAM("Serial Port initialized");
        return -1;

    ros::Rate loop_rate(5);


            ROS_INFO_STREAM("Reading from serial port");
            std_msgs::String result;
            ROS_INFO_STREAM("Read: " <<;


I think it doesn't get any simpler than that. Once you read the data from the serial port you can use it in your project. Good luck and happy coding!

edit flag offensive delete link more

Question Tools



Asked: 2018-07-23 06:24:22 -0600

Seen: 1,106 times

Last updated: Jul 25 '18