This repository contains the code for the first 2023/2024 Robotics project @ Politecnico di Milano.
This is a ROS 1 project containing three nodes: the first node retrieves geographical coordinates from the GPS module in the robot and converts them first to ECEF coordinates and then to ENU coordinates; the second node retrieves the ENU coordinates from the first node in order to create two transforms (TF): one relative to the robot itself, and another one relative to the robot's wheels, which can then be visualised on RViz; finally, the third node retrieves LIDAR data from the robot's LIDAR sensor and converts it to a PointCloud that can be made relative to either the robot's TF or the wheels' TF.
The project was set up as per the requirements specified in the project presentation. The only thing the evaluator should do is to place the robotics.bag file in the directory first_project/bags. Then, to launch the nodes, it is sufficient to use the roslaunch command:
$ roslaunch first_project launch.launch
The first node is made up of six ROS services, which separate the work the node has to perform. Below is a table explaining what each service does.
| Service name | Description |
|---|---|
deg2rad.srv |
Converts angles specified in degrees to radians |
n_func.srv |
Performs the |
lla2ecef.srv |
Performs the conversion from geographical coordinates to ECEF coordinates using the values and formulas specified here |
ecef2enu.srv |
Performs the ECEF to ENU conversion using the formulas specified here |
heading.srv |
Calculates the heading of the robot in radians using two consecutive positions of the robot, specified in ENU coordinates |
heading2quat.srv |
Calculates the quaternion starting from the robot heading to specify the full pose of the robot using the method specified here |
The node subscribes to the /fix topic to retrieve latitude, longitude and altitude, then uses the services described above to convert this information into the robot's pose and publishes the odometry, formatted into a nav_msgs/Odometry message, to the /gps_odom topic.
The node uses some parameters to store the first position of the robot to compute the ENU coordinates---which are relative to the origin of the robot---and to store the previous position of the robot each time the robot moves---to compute the robot heading and, consequently, its quaternion.
The second node is instantiated twice by the launch file in two different groups so that parameters do not get mixed up. The first group is called gps_odom_to_tf, while the second group is called wheel_odom_to_tf. The nodes share the same name with their group.
Each node is launched with the following parameters:
my_name: The name of the node for debugging.root_frame: The root frame of the TF tree.child_frame: The child frame of the TF tree.rot_offset: The rotation offset of the origin of the TF.
The rotation offset is set to 0 for the gps_odom_to_tf node and to -128° for the wheel_odom_to_tf node in order for them to match when visualised through RViz.
The third node takes the LIDAR data from the /os_cloud_node/points topic by subscribing to it, then duplicates the messages sent to that topic in order to change the reference transform in them, update their timestamp and republish them to /pointcloud_remapped. The node makes use of a parameter, called reference_frame, in order to allow for the dynamic reconfiguration of the reference frame to which the PointCloud is attched to.
Task 1 has been fulfilled with the second_project_mapping package, using both gmapping and slam toolbox. The maps generated by slam can be found under the maps directory.
Copy the bag in the second_project_mapping/bags directory and rename it to robotics2.bag.
To launch the mapping nodes, use the following command:
gmapping:roslaunch second_project_mapping gmapping.launch
- Slam Toolbox (recommended, provides better results):
roslaunch second_project_mapping slam.launch
Note
In order to avoid a timing bug, do not launch this package after the second task. Please restart ROS core before launching the nodes.
Task 2 has been fulfilled with the second_project_sim package.
The navigation stack has been set up using the amcl localization, navFn global planner and teb local planner.
Place the .csv file in the second_project_sim/ directory and rename it to waypoints.csv.
The launch file for the navigation stack is amcl.launch. To launch the navigation stack, use the following command:
roslaunch second_project_sim amcl.launchNote
If the simulation seems to halt, it may be because Docker is having a hard time utilising resources to run it. This happens especially on emulated containers (i.e. x86 containers on aarch64 machines). To increase performance, edit the
tebconfiguration file, located atsecond_project_sim/config/teb_local_planner_params.yaml, look for the parameterno_inner_iterationsand change it to 1. This should increase the simulation speed.