Skip to content

longhongc/ros2-practice-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ROS2 Practice Example

This repository is for practicing some ros2 feature.
The publisher and subscriber of three different sensors are implemented.
The publisher is written in C++ and the subscriber is written in Python for eaiser usage of matplotlib visualization.
Each example contains some demonstrations:

  • Temperature Sensor
    • Publish simulated temperature of gaussian distribution
    • Using custom message type
    • Visualize received data with matplotlib
  • Speed Sensor
    • Publish simulated speed with gaussian noise
    • Using geometry_msgs/Twist message type
    • Visualize received data with turtlesim and matplotlib
  • Laser Sensor
    • Parse and publish pre-recored rosbag2 data
    • Using sensors_msgs/LaserScan message type
    • Visualize message data with RVIZ

Environment

Ubuntu 20.04 (on Windows11 wsl2)
ROS2 foxy

File Structure

├── data_processor # Sensors subscriber and visualization tools  
│   ├── data_processor  
│   │   └── utils  
│   ├── launch  
│   ├── resource  
│   ├── rviz # Rviz config file  
│   └── test 
├── sensor_interfaces # Custom temperature sensor data  
│   ├── include  
│   │   └── sensor_interfaces 
│   ├── msg  
│   └── src  
└── sensors  # Sensors publisher and launch file  
    ├── include  
    │   └── sensors  
    ├── laser_test_data # Test data for laser sensor 
    ├── launch  
    └── src  

Build

Clone project into src of ros2 workspace

cd {ros2_workspace}/src
git clone https://github.com/longhongc/ros2-practice-example.git

Go back to ros2 workspace and build

cd {ros2_workspace}
colcon build

Run

Temperature Sensor

Run nodes seperately

ros2 run sensors temp_publisher  
ros2 run data_processor temp_subscriber 

Launch all nodes

ros2 launch sensors temp.launch

drawing

Speed Sensor

Run nodes seperately

ros2 run sensors speed_publisher  
ros2 run data_processor speed_subscriber 

Launch all nodes

ros2 launch sensors speed.launch

Laser Sensor

Run nodes seperately

ros2 run sensors laser_publisher  
ros2 run data_processor laser_subscriber 

Launch all nodes

ros2 launch sensors laser.launch

About

Practice examples of ros2 publisher and subscriber

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published