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
Ubuntu 20.04 (on Windows11 wsl2)
ROS2 foxy
├── 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
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 nodes seperately
ros2 run sensors temp_publisher
ros2 run data_processor temp_subscriber
Launch all nodes
ros2 launch sensors temp.launch
Run nodes seperately
ros2 run sensors speed_publisher
ros2 run data_processor speed_subscriber
Launch all nodes
ros2 launch sensors speed.launch
Run nodes seperately
ros2 run sensors laser_publisher
ros2 run data_processor laser_subscriber
Launch all nodes
ros2 launch sensors laser.launch