ROS 2 package to obtain the nearest point in front of robot. The node and its component version are included, for comparison purposes. The nearest point is published on 'frontal_free_pc/point' topic for debugging.
Author: C. Mauricio Arteaga-Escamilla from "Robotica Posgrado"
Contact email: [email protected]
LinkedIn: https://linkedin.com/in/cruz-mauricio-arteaga-escamilla/
- Building this package
- frontal_free_pc functionality
- Usage
- Expected result
- Possible errors and reasons
To cloning this repo with dependencies verification:
cd ~/colcon_ws/src
git clone https://github.com/cmauricioae8/frontal_free_pc.git
cd ~/colcon_ws
rosdep install -i --from-path src --rosdistro $ROS_DISTRO -y
If you already have all your dependencies, the console will return:
#All required rosdeps installed successfully
Note
This is made only once for the whole workspace.
To build this package:
colcon build --packages-select frontal_free_pc --symlink-install
source install/setup.bash
After building correctly, if ros2 component types
,
the component will be listed as
frontal_free_pc
free_pc_ns::FrontalFreePC
Important
By default, the example 'frontal_free_pc' node is NOT generated. If user wants to create the corresponding node, it is required to comment the component creation lines in the 'CMakeLists.txt', to first generate the node. If all lines are not comment, the component will be created only.
This node computes the nearest point in front of a robot from 'cloud' topic, and publishes the distance (along the depth axis) on 'frontal_free_pc' topic with 'std_msgs/msg/Float32' type.
For debugging purposes, the nearest point is published on 'frontal_free_pc/point' topic (visualization_msgs/msg/Marker), by the 'debug_mode' param. If debug_mode is False, the topic is removed. Some information about latency is shown in terminal.
The 'reduce_resolution' param is used to reduce the required time of calculating point by skipping some pixels (horizontal only). Every second, is check the frequency of the cloud topic input to guarantee data streaming. Since the pointcloud data could be noisy, a first order low-pass filter is implemented to computed the depth distance of the nearest point.
frontal_free_pc
(std_msgs/msg/Float32)
The distance of the nearest point in front of the robot, along the depth axis in meters.frontal_free_pc/point
(visualization_msgs/msg/Marker)
The 3D point corresponding to the nearest point to be shown in Rviz, for debugging. Ifdebug_mode
param is False, this topic is removed.
cloud
(sensor_msgs/msg/PointCloud)
The input point cloud. This topic frequency is checked to inform data status.
max_depth_x
(double) - The maximum depth distance to consider a possible crash (in front of the robot)robot_width
(double, fixed) - Robot widthmin_height
(double, fixed) - The minimum vertical distance to take into account an object in frontmax_height
(double, fixed) - The maximum vertical distance to take into account an object in fronttarget_frame
(string, fixed) - The target frame to validate robot sizedebug_mode
(bool) - ROS param to publish the nearest point, for debugreduce_resolution
(int) - Resolution reducer to minimize the time to obtain the nearest pointfilter_gain
(double) - Filter gain in (0,1)
Note: Params fixed cannot be modified at runtime.
To test the frontal_free_pc functionality, loading the component
ros2 launch frontal_free_pc component_launch.py
This launch creates a container and loads the component using the 'parameters.yaml' file.
Additionally, the 'launch/load_launch.py' file is an example of loading a component on an existing container.
To test this component without using the 'component_launch.py'
In one terminal:
ros2 run rclcpp_components component_container
This creates a component container (with name /ComponentManager)
In another terminal, to load (start) the component:
ros2 component load /ComponentManager frontal_free_pc free_pc_ns::FrontalFreePC
To unload (finish) the component
ros2 component unload /ComponentManager <component_ID>
To test the frontal_free_pc functionality, running the node
, if was built
ros2 launch frontal_free_pc node_launch.py
This launch runs the node using the 'parameters.yaml' file.
The following image shows the expected result.
To open Rviz with the config file from terminal:
rviz2 -d ~/colcon_ws/src/frontal_free_pc/rviz/frontal_free_pc.rviz
-
frontal_free_pc
topic not publishing: input cloud topic is not publishing, cloud topic remapping is not correct, TF tree is broken -
frontal_free_pc/point
not listed: 'debug_mode' param set to False -
Result point is not the nearest shown point: robot size params are not correct, 'reduce_resolution' param is very large
-
Slow performance or lag: 'reduce_resolution' param is 1, 'filter_gain' param is almost 0
-
Point not shown in Rviz: the 'Fixed Frame' is not the 'target_frame' in Rviz
-
frontal_free_pc
node does not exist: the node config was not set in 'CMakeLists.txt' when building
Return to Table of Contents