Giter VIP home page Giter VIP logo

pcl_tutorial's Introduction

pcl_tutorial

Tutorial for using Point Cloud Library (PCL) with ROS 2.

Code adapted for ROS 2 from ROS Industrial: Building a Perception Pipeline.

Screenshot from 2023-03-22 21-02-56

Getting Started

Install ROS 2, create a workspace then install the following packages:

sudo apt install ros-galactic-pcl-ros
sudo apt install ros-galactic-pcl-conversions

Clone this repo into a ROS 2 workspace and build:

source <ROS_WS>/install.setup.bash
cd <ROS_WS>/src
git clone https://github.com/adrian-soch/pcl_tutorial
colcon build

Running the code

After building the easiest way to start the node is through the launch file, change the paramters inside processing_node.launch.py then:

ros2 launch pcl_tutorial processing_node.launch.py

Then start a PointCloud2 Publisher, this can be from a real hardware, from a simulation, or a rosbag. To play a rosbag that has pointcloud data recorded:

ros2 bag play <PATH_TO_BAG>

Optionally, you can pause rosbags, or play them 1 message at a time:

ros2 service call /rosbag2_player/toggle_paused rosbag2_interfaces/TogglePaused

ros2 service call /rosbag2_player/play_next rosbag2_interfaces/PlayNext

Visualization

  1. To view the point cloud topics, run rviz2 in a new terminal.

  2. Click Add near the bottom right, select the By topic tab, and then select the point cloud 2 topic that you want to see.

  3. Go to Global Options -> Fixed Frame and select the frame the data is in. Otherwise there will be a Global Status error that prevents you from seeing the data.

  4. To make LiDAR points easier to see go to PointCloud2 -> Style and select Points from the dropdown menu. Feel free to try changing any other settings

  5. You can save the current configuration and rviz2 will open to this configuration by default. This can be changed at any time.

Debugging

An easy way to debug ROS 2 C++ programs is through VSCode.

  1. Build the package with simlinks, and the debug flag
  2. Run the ROS node with gdb prefix (or add to launch file)
  3. Add the following to the launch.json' in the .vscode` folder
colcon build --packages-select lesson_perception --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=RelWithDebInfo

ros2 run --prefix 'gdbserver localhost:3000' lesson_perception perception_node

Create VSCode `launch.json`
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "ROS2 C++ Debugger",
            "request": "launch",
            "type": "cppdbg",
            "miDebuggerServerAddress": "localhost:3000",
            "cwd": "/",
            "program": "/home/<PATH_TO_ROS_WS>/install/<PACKAGE>/lib/<PACKAGE>/<EXECUTABLE>"
        }
    ]
}

# Run debugger in vscode

Resources

pcl_tutorial's People

Contributors

adrian-soch avatar

Stargazers

 avatar  avatar

Watchers

 avatar

pcl_tutorial's Issues

Missing 'vision_msgs' dependency

I just cloned your repo and tried to build. My distro is iron.

Seems like you need to add vision_msgs to your dependency list. Afterwards it builds OK.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.