Hi. I need to interface my GPS sensor that provides a serial output with a ROS-robot. How can I do?

asked 2020-03-03 03:07:50 -0500

Filippo gravatar image

What I want to do is to give to the robot geographic coordinates through my sensor that will be assembled over the robot.

edit retag flag offensive close merge delete

Comments

Write a driver for it.

for more solid advice, please edit your question and provide more details, e.g. what kind of sensor you use (model!), how you set up your connection, and what you have already tried....

mgruhler gravatar image mgruhler  ( 2020-03-03 08:40:19 -0500 )edit

@mgruhler I've a sensor based on UWB technology that provides cartesian coordinates (x,y,z) as output. This sensor can be connected through a serial port.

What I'd like to have is to use data from my sensor to locate and navigate the robot. So what I need is a package that allows me to read data from my sensor and then use them to localize and drive the ROS-robot instead of using data from the sensors which are integrated on the robot.

Pratically I have to:

1: read the data (x,y,z) from a serial port

2: use my data to locate and drive the robot

How can I implement this two things?

Filippo gravatar image Filippo  ( 2020-03-16 09:27:09 -0500 )edit

What language are you targeting? C++? Python? What are your thoughts about the implementation, how do you plan on doing it? Have you looked around here for advice before posting the question? What have you tried so far and where are you stuck?

Also, a UWB based localization system is definitely not a GPS and does also not provide geographic coordinates. Please try to be a more clear about what you are trying to do... Otherwise we'll only end up providing support for the wrong thing...

mgruhler gravatar image mgruhler  ( 2020-03-17 08:13:55 -0500 )edit

I'll use C++. I searched on the web but I did'n find any tips. So I have a sensor that can comunicate through a serial port and it can give as output cartesian coordinates (x,y,z).

What I need is to read the data from my sensor and use that data to localize and drive a ROS-robot. What I thought to do is read the data and then use this data in the localization and navigation package that are alredy avaible for ROS.

For read the data from a serial port I found this package (https://github.com/wjwwood/serial/blo...). I think it could work but I don't know exactly how. I need to find a way to assign the firsts bit that i get (maybe 32, or 64) to a variable x, the next ones to a variable y and finally to a variable ...(more)

Filippo gravatar image Filippo  ( 2020-03-17 10:56:29 -0500 )edit

You're on the right track. But what is the question? Where exactly do you have problems? Have you checked existing applications using the serial library or some of the provided examples? Or is your problem rather in what you need to provide to the navigation stack such that you can use it for navigation?

If your question is: "how do I implement this thing?" I highly doubt you'll receive an answer here, because that would actually mean writing the code for you, and we still don't even know which kind of hardware you have, so we also don't know the protocol etc.

If you've checked existing applications and the examples and stumble upon a problem like "I don't understand this line" or "I expect that to happen when I call open but that happens" you'll more likely to get any help...

mgruhler gravatar image mgruhler  ( 2020-03-18 04:13:44 -0500 )edit

serial::Serial ser;

int main(int argc, char **argv) {

ros::init(argc, argv, "SEQUITUR_driver");

ros::NodeHandle nh;

ros::Publisher data_topic = n.advertise<std_msgs::string>("data", 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);

data_topic.publish(result);

} loop_rate.sleep(); }

}

Filippo gravatar image Filippo  ( 2020-03-19 06:35:02 -0500 )edit

@mgruhler thanks for your help. I think the best way is to proceed step by step. Here above there's what I wrote to read from the serial port. If this is correct I'm expecting to read data 5 times per second and publish them on data_topic.

Then I will need to create a subsriber to data_topic and that can receive my data and finally do some stuff. What do you think? If I need to use this data for the navigation and localization, am I suppose to modify the existing package ? For example, modify the subcriber that read the data coming from the ROS-robot's integrated GPS. Make sure that it will be subscribed to my data_topic so it will read my own data.

Filippo gravatar image Filippo  ( 2020-03-19 06:45:28 -0500 )edit