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);
ser.write(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);
try
{
ser.setPort("/dev/ttyACM0");
ser.setBaudrate(9600);
serial::Timeout to = serial::Timeout::simpleTimeout(1000);
ser.setTimeout(to);
ser.open();
}
catch (serial::IOException& e)
{
ROS_ERROR_STREAM("Unable to open port ");
return -1;
}
if(ser.isOpen()){
ROS_INFO_STREAM("Serial Port initialized");
}else{
return -1;
}
ros::Rate loop_rate(5);
while(ros::ok()){
ros::spinOnce();
if(ser.available()){
ROS_INFO_STREAM("Reading from serial port");
std_msgs::String result;
result.data = ser.read(ser.available());
ROS_INFO_STREAM("Read: " << result.data);
read_pub.publish(result);
}
loop_rate.sleep();
}
}
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!
How can I take raw data from the sensors and publish it to a ROS topic?
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.
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?
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 http://wjwwood.io/serial/ ). More info on the sensor would be helpful, but btw if you have to use Windows it seems quite hard to do.
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.
Btw I replied down below.