suchetanrs / ORB-SLAM3-ROS2-Docker

This repository contains a full wrapper class for running ORB-SLAM3 on a docker container with ROS2 Humble with Ubuntu 22.04.
116 stars 19 forks source link

ros2 communication inside and outside docker and point cloud view in rviz2@suchetanrs #8

Closed GLtangzero closed 2 weeks ago

GLtangzero commented 2 weeks ago
          @suchetanrs 

Hello, I just check it, the work which you upload is very good, it is work successfully in the docker both the wrapper and the simulation, I will try to moved it without docker, or build the new project in the docker. And could I ask the rviz2 progress which you show the SLAM? I don't know how to check this image: Screenshot from 2024-06-24 12-59-03

There are some warning in the below: In the gazebo-husky-gazebo-ros2 after running :"ros2 launch scout_gazebo start_world.launch.py" [spawner-6] [INFO] [1719200308.333893647] [scout_2.diff_drive_controller_spawner]: Configured and activated diff_drive_controller [spawner-5] [INFO] [1719200308.436446472] [scout_2.joint_state_broadcaster_spawner]: Configured and activated joint_state_broadcaster [INFO] [spawner-6]: process has finished cleanly [pid 8868] [INFO] [spawner-5]: process has finished cleanly [pid 8866]

[navsat_transform_node-8] [INFO] [1719200309.107280808] [scout_2.navsat_transform]: Datum UTM coordinate is (31T, 376764.25, 4824746.89) [navsat_transform_node-8] [INFO] [1719200309.107359742] [scout_2.navsat_transform]: Corrected for magnetic declination of -0.0274017, user-specified offset of 0 and meridian convergence of -0.0183578. Transform heading factor is now -0.138116 [INFO] [SetDatum "{geo_pose: {position: {latitude: 43.5655, longitude: 1.4740, altitude: 149.34}, orientation: {x: 0.079, y: -0.043, z: -0.041, w: 0.959}}}"-10]: process has finished cleanly [pid 8876] [ekf_node-9] Error: TF_SELF_TRANSFORM: Ignoring transform from authority "Authority undetectable" with frame_id and child_frame_id "" because they are the same [ekf_node-9] at line 209 in ./src/buffer_core.cpp [ekf_node-9] Error: TF_NO_CHILD_FRAME_ID: Ignoring transform from authority "Authority undetectable" because child_frame_id not set [ekf_node-9] at line 217 in ./src/buffer_core.cpp [ekf_node-9] Error: TF_NO_FRAME_ID: Ignoring transform with child_frame_id "" from authority "Authority undetectable" because frame_id not set [ekf_node-9] at line 224 in ./src/buffer_core.cpp [navsat_transform_node-8] Error: TF_SELF_TRANSFORM: Ignoring transform from authority "Authority undetectable" with frame_id and child_frame_id "" because they are the same [navsat_transform_node-8] at line 209 in ./src/buffer_core.cpp [navsat_transform_node-8] Error: TF_NO_CHILD_FRAME_ID: Ignoring transform from authority "Authority undetectable" because child_frame_id not set [navsat_transform_node-8] at line 217 in ./src/buffer_core.cpp [navsat_transform_node-8] Error: TF_NO_FRAME_ID: Ignoring transform with child_frame_id "" from authority "Authority undetectable" because frame_id not set [navsat_transform_node-8] at line 224 in ./src/buffer_core.cpp [rviz2-7] Error: TF_SELF_TRANSFORM: Ignoring transform from authority "Authority undetectable" with frame_id and child_frame_id "" because they are the same [rviz2-7] at line 209 in ./src/buffer_core.cpp [rviz2-7] Error: TF_NO_CHILD_FRAME_ID: Ignoring transform from authority "Authority undetectable" because child_frame_id not set [rviz2-7] at line 217 in ./src/buffer_core.cpp [rviz2-7] Error: TF_NO_FRAME_ID: Ignoring transform with child_frame_id "" from authority "Authority undetectable" because frame_id not set [rviz2-7] at line 224 in ./src/buffer_core.cpp

01

Thanks for your job again, it's really a amazing good project!

Originally posted by @GLtangzero in https://github.com/suchetanrs/ORB-SLAM3-ROS2-Docker/issues/6#issuecomment-2185554970

GLtangzero commented 2 weeks ago

@suchetanrs Hello, thanks for your replay, I think it's better than before but there is still some problems.

First of all, actually I'm not use the project in the docker, I was moved it to a new work space, but it's almost same condition, the work space is also from zang9/ORB_SLAM3_ROS2, because I need to connect the project with the gazebo garden and there are some other ros2 project need to combine.

For now, if we still use the order of ros2 launch orb_slam3_ros2_wrapper unirobot.launch.py, it's still just show waiting for image. But if we try zang9's order like "ros2 run orbslam3_ros2 rgbd /home/tang/colcon_ws/src/orbslam3_ros2/vocabulary/ORBvoc.txt /home/tang/colcon_ws/src/orbslam3_ros2/src/rgbd/TUM1.yaml" there is image in the orbslam3 Screenshot from 2024-06-24 09-37-37 but there are some problems happened even the image could be seen,:

  1. I think we not load the document "rgbd-ros-params.yaml",
  2. There are not any point show in the ORBSLAM3 even the point have been catch in the iamge.
  3. There are some warning in the terminal (1)if there are images: it will repeat like "Error: TF_SELF_TRANSFORM: Ignoring transform from authority "Authority undetectable" with frame_id and child_frame_id "" because they are the same at line 209 in ./src/buffer_core.cpp Error: TF_NO_CHILD_FRAME_ID: Ignoring transform from authority "Authority undetectable" because child_frame_id not set at line 217 in ./src/buffer_core.cpp Error: TF_NO_FRAME_ID: Ignoring transform with child_frame_id "" from authority "Authority undetectable" because frame_id not set at line 224 in ./src/buffer_core.cpp" (2)if the camera not catch the image: it will repeat: "ORB-SLAM failed: Not initialized."

the rqt image will show like this: Screenshot from 2024-06-24 09-39-00

Thanks for your work, I think we could make it work, now I will try test the job in the docker, but I really don't have the experience to use this tool.

suchetanrs commented 2 weeks ago

Hi, @GLtangzero thanks a lot for moving this to a new issue. Let's first try to resolve the issues with the scout simulation and the wrapper docker if there are any. Then try to debug the other one. Request you to please tell me if you did the following:

  1. Do a git pull or a fresh git clone and rebuild the docker image of the wrapper as well as the scout simulation.
  2. After this, were you able to run the SLAM with the no_odometry_mode set to false in the rgbd-ros-params.yaml. If you set no_odometry_mode to true then you might get the error "Could not obtain scout_2/odom -> scout_2/base_footprint transform. Will not remove offset of navsat device from robot's origin" You can safely ignore this for now. Will fix it soon.
  3. To answer your question, you should be able to visualize the pointcloud in the demo image by setting ros_visualization to true in the rgbd-ros-params.yaml. However, when I tried this, the program crashed after a while or the TF was not being published correctly. I am working to fix it. I still suggest you to try it and see if it works.
  4. The TF warnings you are seeing on rviz, are they consistent and repetitive? If they stop showing up a few seconds after the SLAM is started, they can safely be ignored. Please try adding the "TF" visualization on RViz and try running with and without odometry by setting no_odometry_mode parameter and make sure the TF is correcly being visualized. If you did a git pull or a fresh clone and built the image again, a custom RViz screen should open up with the scout_simu.launch.py. You don't need to open an rviz separately. This custom rviz config has the TF already.

If these are resolved, we can try to address your second comment. Just a quick note, before you start anything, make sure the latest commit os a25df1b on the local clone of the wrapper git. I just pushed something :p

GLtangzero commented 2 weeks ago

@suchetanrs Hello again, you are right. The TF just show one time and it's because I add the TF by my self. This image is build in the no_odometry_mode: false: Screenshot from 2024-06-24 13-57-47

But after change the no_odometry_mode: true: There are some problems happened.

  1. gazebo terminal will repeat the error [navsat_transform_node-8] [ERROR] [1719205254.243866385] [scout_2.navsat_transform]: Could not obtain scout_2/odom -> scout_2/base_footprint transform. Will not remove offset of navsat device from robot's origin
  2. the wrapper terminal will repeat the warning [rgbd-1] [INFO] [1719205311.726816125] [scout_2.ORB_SLAM3_RGBD_ROS2]: Publishing map data [rgbd-1] [WARN] [1719205311.755340010] [scout_2.ORB_SLAM3_RGBD_ROS2]: Odometry msg recorded but no odometry mode is true, set to false to use this odometry [rgbd-1] [WARN] [1719205311.854743948] [scout_2.ORB_SLAM3_RGBD_ROS2]: Odometry msg recorded but no odometry mode is true, set to false to use this odometry [rgbd-1] [WARN] [1719205311.956552647] [scout_2.ORB_SLAM3_RGBD_ROS2]: Odometry msg recorded but no odometry mode is true, set to false to use this odometry

a

And also the the tires in rviz also flash black and white some time the statue is ok sometime the statue is false: b c

In rivz2 the TF list is a warning: The scout_2/odom still is No transform from [scout_2/odom] to [map]

Screenshot from 2024-06-24 14-16-43 Screenshot from 2024-06-24 14-17-42

Thanks for your reply, I will check it also.

suchetanrs commented 2 weeks ago

Hi @GLtangzero , Thanks for your comment.

  1. Yes, if you set the no_odometry_mode to true, the warning on ORB-SLAM3 will show up. It is on purpose. You can ignore this.
  2. The navsat transform error can also safely be ignored. I will fix this in a future commit.
  3. The wheels will flicker if the odometry is set to false since the TF to the wheels is not a static transform and is published by the odometry node. This is natural as well.

For now, I think the warnings and errors you are facing can be safely ignored. Please try the pointcloud visualization as well. It should be published under the topic /scout_2/map_points if ros_visualization is set to true. But it is not stable, needs some testing. You can also instead use the camera pointcloud directly. This is much more dense and is coloured :p

Happy that we are now on the same page! :smile:

Information

Once you update the parameter file or make any changes in the code, you do not need to rebuild the docker image. A simple colcon build --symlink-install should do the trick. Important: If you are using the scout_simulation you can run it with no_odometry_mode set to false. This will prevent any wheel TF issues.

GLtangzero commented 2 weeks ago

Hello: Thank you so much about you detail explanation, I realize the image which you show in the main page, it's quiet cool! So the progress is change the rgbd-ros-params.yaml to : ORB_SLAM3_RGBD_ROS2: ros__parameters: robot_base_frame: base_footprint global_frame: map odom_frame: odom robot_x: 0.0 robot_y: 0.0 visualization: true ros_visualization: true no_odometry_mode: false

and add the /scout_2/map_points to rviz2. Look this coolest image!: Screenshot from 2024-06-24 15-03-31 Now I will try to check how to get the project to working without docker. Thanks again!!

suchetanrs commented 2 weeks ago

Awesome! Great to hear that it worked! :smile: :smile:

I just wanted to say that you can very well run your own gazebo environment outside of docker and the ROS 2 wrapper within the docker. They both will communicate seamlessly. Just make sure the following:

  1. The environment variable ROS_DOMAIN_ID is the same inside the docker and outside. I remember setting it to 55 inside the docker. You can check the environment variable outside the docker using echo $ROS_DOMAIN_ID and in case it is not the same, you can set it using export ROS_DOMAIN_ID=55.
  2. I still recommend you run the wrapper within the docker and run anyting else that you need outside of it. Just make sure the topics that are being published from outside are visible inside the docker container using ros2 topic list. They should be visible if the ROS_DOMAIN_ID is the same.
GLtangzero commented 2 weeks ago

I will try to make it, after that I will reply ASAP and upload the progress. Thanks a lot for your help. Later we can try some cool things, maybe using the pointscloud data in octomap, as I know for now almost 3D mapping is still based on ROS1, so maybe this project will be the first one which based on ROS2. I will reply later! Thanks again!

GLtangzero commented 2 weeks ago

@suchetanrs I just try to use the same ROS_DOMAIN_ID in both docker and outside. But some problem is happened. Now I transport some Image type message from outside to docker. But I run the “ros2 topic list” the topic name could be check but if I run "ros2 topic echo /rgb_image" or want check the image in rviz2 there is no message transport.

Screenshot from 2024-06-25 09-54-53

I already check it without docker the transport is no problem.

suchetanrs commented 2 weeks ago

Hi, I am not sure what exactly could be the issue. You could try a couple of things.

  1. Run ros2 run demo_nodes_cpp talker outside the docker
  2. ros2 run demo_nodes_cpp listener inside the docker container. If this communication works, it's all good. Something else might be the issue.

Are you using the same ROS versions inside and outside the container? The container runs Humble.

Also, it is the case that if a message is too big, ros2 topic echo just won't print it. Before initialising the subscriber or RViz inside docker, please do ros2 topic info -v /topic_name and check the QOS policy of the publisher. The subscription on rviz should have the same qos policy to work. This could be the issue only if the demo talker and listener work.

GLtangzero commented 2 weeks ago

@suchetanrs Hey ,I just test it, both of out and inside could not listen each other. And yes I use the same ros2 humble.

Screenshot from 2024-06-25 11-01-44

Screenshot from 2024-06-25 11-01-09

suchetanrs commented 2 weeks ago

I will need to try and recreate this to propose any solution or find the problem. Please allow me sometime :p

GLtangzero commented 2 weeks ago

No problem. I will try to make it work out of docker without any presetting. Later I will upload the progress. Thanks again.

suchetanrs commented 2 weeks ago

@GLtangzero So I was able to recreate this. This issue exists on my machine too. I never realised it because I never ran ros on my host machine outside of docker :p The issue seems to be with the default DDS implementation. I quickly tried cyclonedds and it seems to fix the issue. I did the following:

sudo apt-get install -y ros-humble-rmw-cyclonedds-cpp in both places.

  1. To your ~/.bashrc both inside and outside the docker container add these:
    source /opt/ros/humble/setup.bash
    export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
    export CYCLONEDDS_URI=~/.ros/cyclonedds.xml
    export ROS_DOMAIN_ID=55
    1. Add the following file inside the ~/.ros directory both inside and outside. The file name should be cyclonedds.xml. So the path will be ~/.ros/cyclonedds.xml
      <?xml version="1.0" encoding="UTF-8" ?>
      <CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
      <Domain id="any">
      <General>
      <NetworkInterfaceAddress>auto</NetworkInterfaceAddress>
      <AllowMulticast>false</AllowMulticast>
      </General>
      <Discovery>
      <ParticipantIndex>auto</ParticipantIndex>
      <MaxAutoParticipantIndex>100</MaxAutoParticipantIndex>
      <Peers>
      <Peer Address="localhost" />
      </Peers>
      </Discovery>
      </Domain>
      </CycloneDDS>
    2. Source your ~/.bashrc using source ~/.bashrc both inside and outside.
    3. Run the talked and the listener. Please let me know if this works.

If i am unable to figure out why the default DDS implementation caused the issue, maybe we should update the docker container to use Cyclone DDS by default.

GLtangzero commented 2 weeks ago

@suchetanrs God man, you are so cool! It worked so good!! Screenshot from 2024-06-25 11-55-37 Thanks a lot, I will upload every step in this afternoon.

suchetanrs commented 2 weeks ago

Great :smile: Happy to help! Not sure why there are TF errors :p

GLtangzero commented 2 weeks ago

I think it's my project's problem, this project is based on px4 sitl but not based on rviz2. I think even ignored it is also ok.We still could check the pointcloud in rviz2.

Screenshot from 2024-06-25 12-08-08

But looks like we need input sudo apt-get install -y ros-humble-rmw-cyclonedds-cpp every time else it will like: "[ERROR] [1719284980.704864503] [rcl]: Error getting RMW implementation identifier / RMW implementation not installed (expected identifier of 'rmw_cyclonedds_cpp'), with error message 'failed to load shared library 'librmw_cyclonedds_cpp.so' due to dlopen error: librmw_cyclonedds_cpp.so: cannot open shared object file: No such file or directory, at ./src/shared_library.c:99, at ./src/functions.cpp:65', exiting with 1., at ./src/rcl/rmw_implementation_identifier_check.c:139"

suchetanrs commented 2 weeks ago

Yeah, when you exit the docker container and make a new one, it will create a new container from the image. If you don't want to do it everytime, you can add the line at the end of the Dockerfile in the repository using RUN sudo apt-get install -y ros-humble-rmw-cyclonedds-cpp Build the docker image again and run the container. I suppose you wont need to install it everytime then.

GLtangzero commented 2 weeks ago

Look I really need to study the base order of this tool.:>

GLtangzero commented 2 weeks ago

1.Problem of communication inside docker with outside (1) after follow the main page succefully running the ros2 launch orb_slam3_ros2_wrapper unirobot.launch.py (it will show like) 1

add RUN sudo apt-get install -y ros-humble-rmw-cyclonedds-cpp to /ORB-SLAM3-ROS2-Docker/Dockerfile (2) run sudo docker build -t orb-slam3-humble:22.04 . again to rebuild the docker (3) in the basehost also run sudo apt-get install -y ros-humble-rmw-cyclonedds-cpp (4) in the home/user_name/.bashrc and ORB-SLAM3-ROS2-Docker/container_root/.bashrc add:

source /opt/ros/humble/setup.bash
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export CYCLONEDDS_URI=~/.ros/cyclonedds.xml
export ROS_DOMAIN_ID=55

to the end (5) add a "cyclonedds.xml" in both basehost and docker (for me these two folder in the home/user_name/.ros and ORB-SLAM3-ROS2-Docker/container_root/.ros and don't forget they are hidden folders so clip the option of show Hidden Files) the content is:

<?xml version="1.0" encoding="UTF-8" ?>
<CycloneDDS xmlns="https://cdds.io/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <Domain id="any">
   <General>
     <NetworkInterfaceAddress>auto</NetworkInterfaceAddress>
     <AllowMulticast>false</AllowMulticast>
   </General>
   <Discovery>
     <ParticipantIndex>auto</ParticipantIndex>
     <MaxAutoParticipantIndex>100</MaxAutoParticipantIndex>
     <Peers>
       <Peer Address="localhost" />
     </Peers>
   </Discovery>
 </Domain>
</CycloneDDS>

ps:if there is a problem about permissions in "ORB-SLAM3-ROS2-Docker/container_root/.ros"

try:

<1>open a terminal in **ORB-SLAM3-ROS2-Docker/container_root/.ros** run `sudo touch cyclonedds.xml` <2>`sudo getdit cyclonedds.xml` <3>copy the content to the xml and ctrl+s then close it <4>done (6) close all terminal and open them again or just `source ~/.bashrc` in every terminal (7) run: <1>in terminal 1 `cd ORB-SLAM3-ROS2-Docker` `sudo docker compose run orb_slam3_22_humble` `ros2 run demo_nodes_cpp listener` <2>in terminal 2 `ros2 run demo_nodes_cpp listener` or vice versa if the terminal could communicate each other then it's successfully!! **_### All solution steps come from suchetanrs if there is any other problem please report it!_** Thank you! @suchetanrs
GLtangzero commented 2 weeks ago

2.Problem of point cloud view in rviz2 of the guest simulator after follow the step of the problem 1 for now it should be could communicate both in docker and outside for the guest simulator which mean you not use the simulator by the suchetanrs supply in simualtion if you also want check the pointcloud in the rviz2 please follow the step

<1>open the terminal in **ORB-SLAM3-ROS2-Docker** `sudo docker compose run orb_slam3_22_humble` <2>`cd /root/colcon_ws/` <3>`export ROBOT_NAMESPACE="" && export ROBOT_Y="1.0" && export ROBOT_X="1.0"` if you won't do that it will show : ``` [ERROR] [launch]: Caught exception in launch (see debug for traceback): Caught multiple exceptions when trying to load file of format [py]: - KeyError: 'ROBOT_NAMESPACE' - InvalidFrontendLaunchFileError: The launch file may have a syntax error, or its format is unknown ``` <4>`source install/setup.bash` <5>`ros2 launch orb_slam3_ros2_wrapper rgbd.launch.py` <6>transport the RGB image to the topic `camera/image_raw` transport the depth image to the topic `camera/depth/image_raw` (then it should show like the image below) ![Screenshot from 2024-06-25 14-18-47](https://github.com/suchetanrs/ORB-SLAM3-ROS2-Docker/assets/135005974/aa534b44-6bd6-41c1-8a81-7fa5819dd0d1) (ignore the warning it will be fix in future) <7>open the rviz2 in any terminal choose Add->by topic->/map_points/PointCloud2 ![Screenshot from 2024-06-25 14-20-12](https://github.com/suchetanrs/ORB-SLAM3-ROS2-Docker/assets/135005974/5a184c06-05ac-4897-bb5f-1d62e4804656) ![Screenshot from 2024-06-25 14-20-28](https://github.com/suchetanrs/ORB-SLAM3-ROS2-Docker/assets/135005974/448b619f-b76f-44bc-a5eb-cb5130e99a4c) ![333](https://github.com/suchetanrs/ORB-SLAM3-ROS2-Docker/assets/135005974/7425ec91-d580-4421-b51b-7602f95f6a26) ### All solution steps come from suchetanrs if there is any other problem please report it! Thank you! @suchetanrs
GLtangzero commented 2 weeks ago

Finished.

suchetanrs commented 2 weeks ago

Thanks a ton for your efforts! @GLtangzero Really appreciate it. :smile: I will later add a relevant issues section in the README and tag this issue there in case someone is interested. Thanks again. Feel free to raise a new ticket in case you'd want to discuss something.