Closed LihanChen2004 closed 5 months ago
Hi Lihan, Great Work! Basically you adopted the package to work with ROS2 and provide comprehensive step by step! Feel free to create a pull request, even if it's only in the readme of the repository. I believe this can be very helpful for the community. Thank you.
Hi Lihan, Great Work! Basically you adopted the package to work with ROS2 and provide comprehensive step by step! Feel free to create a pull request, even if it's only in the readme of the repository. I believe this can be very helpful for the community. Thank you.
Thank you for your recognition! I will submit a Pull Request recently. I will try to retain and merge the original Running The Code section as much as possible.
Pgm2Posegraph in ROS2
This might also be a way to edit the posegraph map, but it's a bit convoluted.
I. Refine and Edit the PGM Map
Modify the map as needed by adding or removing barriers. The most crucial step is to completely black out the obstacles, ensuring there are no white areas within any obstacles!
II. Use Ogm2Pgbm to Obtain a Rosbag with PointCloud and Poses
GitHub - MigVega/Ogm2Pgbm: Robust BIM-based 2D-LiDAR Localization for Lifelong Indoor Navigation in Changing and Dynamic Environments
This repository implements the conversion of Occupancy Grid Maps (OGM) to Pose Graph-based maps. The workflow is as follows:
/laserscan
topic.2.1 Use Docker to Obtain the Package
The original repository uses the ROS1 melodic version.
I have prepared a Docker image for easy deployment.
Pull the Docker image:
Clone the repository. The
/Ogm2Pgbm/workspace/map/
directory will be mapped to the Docker container, making it easy to replace the map:Create the container based on
lihanchen2004/ogm2pgbm:latest
:2.2 Start the Package
Copy the .pgm and .yaml files you need to convert to the
Ogm2Pgbm/workspace/map/
directory on the host machine.All following operations should be performed inside the Docker container. Ensure the current terminal is within the Docker container.
Wait for 2-3 minutes. After completion, the program will output "Done" in the terminal.
Terminate the program with Ctrl+C. The rosbag will automatically be saved to
/root/.ros/ogm2pgbm_sensordata.bag
.2.3 Download the Rosbag to the Host Machine
All following operations should be performed on the host machine.
Get the CONTAINER ID:
Save the rosbag to the host machine:
Remember to modify
CONTAINER_ID
! Here, I save the rosbag from the container to the host's Download directory:III. Convert .bag to .db3
All following operations should be performed on the host machine.
In ROS1, rosbag files have a .bag suffix, which is a binary format for storing ROS messages. ROS2 has improved and extended the rosbag format, adopting an SQLite-based database format that includes a .db3 database and a .yaml file.
Ternaris / rosbags · GitLab
Install the conversion package:
Navigate to the directory containing the rosbag and execute the following command to convert
ogm2pgbm_sensordata.bag
toRMUC.db3
:IV. Play the Rosbag and Generate the Map
All following operations should be performed on the host machine.
4.1 Preparation
You can use the following rviz configuration file for visualization.
ogm2pgbm.rviz (Click to expand)
```yaml Panels: - Class: rviz_common/Displays Help Height: 78 Name: Displays Property Tree Widget: Expanded: - /Global Options1 - /Status1 Splitter Ratio: 0.5 Tree Height: 549 - Class: rviz_common/Selection Name: Selection - Class: rviz_common/Tool Properties Expanded: - /2D Goal Pose1 - /Publish Point1 Name: Tool Properties Splitter Ratio: 0.5886790156364441 - Class: rviz_common/Views Expanded: - /Current View1 Name: Views Splitter Ratio: 0.5 - Class: rviz_common/Time Experimental: false Name: Time SyncMode: 0 SyncSource: LaserScan Visualization Manager: Class: "" Displays: - Alpha: 0.699999988079071 Class: rviz_default_plugins/Map Color Scheme: map Draw Behind: false Enabled: true Name: Map Topic: Depth: 5 Durability Policy: Volatile Filter size: 10 History Policy: Keep Last Reliability Policy: Reliable Value: /map Update Topic: Depth: 5 Durability Policy: Volatile History Policy: Keep Last Reliability Policy: Reliable Value: /map_updates Use Timestamp: false Value: true - Alpha: 1 Autocompute Intensity Bounds: true Autocompute Value Bounds: Max Value: 10 Min Value: -10 Value: true Axis: Z Channel Name: intensity Class: rviz_default_plugins/LaserScan Color: 255; 255; 255 Color Transformer: Intensity Decay Time: 0 Enabled: true Invert Rainbow: false Max Color: 255; 255; 255 Max Intensity: 4096 Min Color: 0; 0; 0 Min Intensity: 0 Name: LaserScan Position Transformer: XYZ Selectable: true Size (Pixels): 3 Size (m): 0.009999999776482582 Style: Points Topic: Depth: 5 Durability Policy: Volatile Filter size: 10 History Policy: Keep Last Reliability Policy: Reliable Value: /scan Use Fixed Frame: true Use rainbow: true Value: true - Class: rviz_default_plugins/TF Enabled: true Frame Timeout: 15 Frames: All Enabled: true robot_base_link: Value: true robot_map: Value: true robot_odom: Value: true Marker Scale: 1 Name: TF Show Arrows: true Show Axes: true Show Names: false Tree: robot_map: robot_base_link: {} robot_odom: {} Update Interval: 0 Value: true Enabled: true Global Options: Background Color: 48; 48; 48 Fixed Frame: robot_base_link Frame Rate: 30 Name: root Tools: - Class: rviz_default_plugins/Interact Hide Inactive Objects: true - Class: rviz_default_plugins/MoveCamera - Class: rviz_default_plugins/Select - Class: rviz_default_plugins/FocusCamera - Class: rviz_default_plugins/Measure Line color: 128; 128; 0 - Class: rviz_default_plugins/SetInitialPose Covariance x: 0.25 Covariance y: 0.25 Covariance yaw: 0.06853891909122467 Topic: Depth: 5 Durability Policy: Volatile History Policy: Keep Last Reliability Policy: Reliable Value: /initialpose - Class: rviz_default_plugins/SetGoal Topic: Depth: 5 Durability Policy: Volatile History Policy: Keep Last Reliability Policy: Reliable Value: /goal_pose - Class: rviz_default_plugins/PublishPoint Single click: true Topic: Depth: 5 Durability Policy: Volatile History Policy: Keep Last Reliability Policy: Reliable Value: /clicked_point Transformation: Current: Class: rviz_default_plugins/TF Value: true Views: Current: Class: rviz_default_plugins/Orbit Distance: 25.282127380371094 Enable Stereo Rendering: Stereo Eye Separation: 0.05999999865889549 Stereo Focal Distance: 1 Swap Stereo Eyes: false Value: false Focal Point: X: -1.1839663982391357 Y: 1.0030579566955566 Z: -0.871300458908081 Focal Shape Fixed Size: true Focal Shape Size: 0.05000000074505806 Invert Z Axis: false Name: Current View Near Clip Distance: 0.009999999776482582 Pitch: 1.1747967004776 Target Frame:4.2 Start
Start the slam_toolbox to prepare for mapping:
Play the rosbag:
Start rviz2 for visualization:
Ensure to modify the rviz2 configuration file path:
4.3 Save the .posegraph Map
After the rosbag finishes playing, set the filename in the
SlamToolBoxPlugin
on the left side of the rviz2 interface, and clickSerialize Map
to save the.posegraph+.data
map. ClickSave Map
to save the.pgm+.yaml
map.Note
The reason for not using Ogm2Pgbm to directly generate the .posegraph map is due to a previously encountered issue where maps generated in ROS1 could not be loaded in ROS2. This is likely due to a version issue with slam_toolbox.