lardemua / atom

Calibration tools for multi-sensor, multi-modal robotic systems
GNU General Public License v3.0
248 stars 27 forks source link

How to communicate with the Zau computer #920

Closed miguelriemoliveira closed 5 months ago

miguelriemoliveira commented 5 months ago

Related to #904

tagging @manuelgitgomes , @Kazadhum , @brunofavs and @rarrais for visibility email from Manuel:

Como falado com o Prof. Miguel, o Zau tem um computador a bordo que corre o ROS Melodic. O Jorge colocou tudo a funcionar dentro desse computador. O que foi falado entre mim e o Prof. Miguel é que isso poderia dar problemas, especialmente com a quantidade de sensores que temos. Sugerimos então fazermos comunicação entre o portátil do Bruno e esse computador.

Mas como faríamos essa comunicação? Fiquei de verificar a comunicação entre Melodic e Noetic. De acordos com os fóruns seguintes, esta comunicação é possível:

https://discourse.ros.org/t/ros-cross-distribution-communication/27335 https://answers.ros.org/question/354867/ros-noetic-master-on-ubuntu-2004-pc-cannot-be-reached-by-ros-melodic-node-on-ubuntu-1804-beaglebone/ https://robotics.stackexchange.com/questions/97403/can-ros-communicate-between-different-versions-via-wifi

Acho que podemos dizer que é seguro a comunicação entre os mesmos. Para isto, é preciso uma conexão LAN entre os dois, possivelmente com um cabo Ethernet. O computador do Bruno tem apenas uma porta, certo? Poderíamos usar um switch para juntar o cabo do VLP16 também, ou usar um adaptador USB-RJ45 que tem aqui no LAR.

Têm mais alguma sugestão ou possível problema que se consigam lembrar?

miguelriemoliveira commented 5 months ago

@manuelgitgomes , thanks for the research work. From what I read it should be possible, but there are also some people reporting problems and others saying this is not recommended.

I will make a simple ROS Melodic -> rabitmq -> ROS Noetic example just in case we need it.

brunofavs commented 5 months ago

It might be relevant to show you my current pc setup and specs.

Im running kernel 6.6.23-1-lts on my host and using a ubuntu 20.04 distrobox docker container. I reckon using a container might induce some communication issues somewhere in the network chain but we'll see.

image

miguelriemoliveira commented 5 months ago

Right that's similar to what I have so it should be fine ...

manuelgitgomes commented 5 months ago

I reckon using a container might induce some communication issues somewhere in the network chain but we'll see.

If I recall correctly, Distrobox has --network=host by default, so networking issues should be seamless. You could see that when using the VLP16, as no problem arose in there.

miguelriemoliveira commented 5 months ago

Ok, so I was working on this today.

I developed a translator from ROS to mqtt back to ROS based on mosquitto (https://mosquitto.org/).

Later I found that this exists in ros already but I had everything done already so lets use this one. I did not find it in the initial search because my initial intention was using rabbitmq.

Anyway, the code is here:

https://github.com/lardemua/ros_mqtt_bridge

There are two scripts:

ros_to_mqtt subscribes to all ros topics listed in the topics.yml file. When a ROS message is received it is published on mqtt using the same topic name.

mqtt_to_ros subscribes to all mqtt topics listed in the topics.yml file, and creates a corresponding ros publisher for each. When a mqtt message is received, it is published on ROS using the same topic name.

I tested in different configurations using distrobox:

  1. ros_to_mqtt and mqtt_to_ros both in Ubuntu 20.04 ros noetic
  2. ros_to_mqtt and mqtt_to_ros both in Ubuntu 18.04 ros melodic
  3. ros_to_mqtt in Ubuntu 18.04 ros melodic and mqtt_to_ros in Ubuntu 20.04 ros noetic (the zau case)

All cases work fine. I think this should solve the problem of how to use the Zau computer together with @brunofavs 's laptop.

Tip: if you test use the --verbose flag to see the message traffic printed to the terminal.

miguelriemoliveira commented 5 months ago

Hi @manuelgitgomes , @Kazadhum and @brunofavs ,

I got home and tested the mosquitto pub and sub and it worked. I think you should not waste time on this. Focus on the intrinsic calibrations if you can.

Teh communications should work fine I think. I will meet you Thursday morning to test them again.

miguelriemoliveira commented 5 months ago

BTW I did the following.

mosquitto installed on the host, not on the containers. Configuration file like this:

# Place your local configuration in /etc/mosquitto/conf.d/
#
# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

persistence true
persistence_location /var/lib/mosquitto/

log_dest file /var/log/mosquitto/mosquitto.log

include_dir /etc/mosquitto/conf.d

listener 1883
allow_anonymous true

I used the home wireless network and was able to send one message from one computer to another.

first the subscriber:

mosquitto_sub -v -t 'test/topic' 

then the publisher:

mosquitto_pub -t 'test/topic' -m 'helloWorld334345' -h 192.168.0.16

and it worked!

Kazadhum commented 5 months ago

Hi @miguelriemoliveira!

Great news! By the way, did you test it on 2 different machines or on 2 different containers inside one machine?

It seems like it's 2 PCs, but just making sure.

miguelriemoliveira commented 5 months ago

Great news! By the way, did you test it on 2 different machines or on 2 different containers inside one machine?

two different pcs

miguelriemoliveira commented 5 months ago

@rarrais I just finished the README file for the ros to mqtt translation so you can test on your side. Sorry for taking so long.

It's here:

https://github.com/lardemua/ros_mqtt_bridge

We test on our side and it seems to be working fine. If you need some help let me know.

manuelgitgomes commented 5 months ago

This was already solved with:

https://github.com/lardemua/ros_mqtt_bridge