This hex_cpp_template repository provides a unified C++ template for ROS1 and ROS2.
This project is licensed under the terms of the Apache License 2.0 - see the LICENSE file for details.
- x64
- Jetson Orin Nano
- Jetson Orin NX
- Jetson AGX Orin
- Horizon RDK X5
- ROS Noetic
- ROS Humble
| Topic | Msg Type | Description |
|---|---|---|
/string_out |
std_msgs/String |
String output |
/odom |
nav_msgs/Odometry |
Odometry test |
| Topic | Msg Type | Description |
|---|---|---|
/string_in |
std_msgs/String |
String input |
| Name | Data Type | Description |
|---|---|---|
string_prefix |
std::string |
String prefix |
odom_frame |
std::string |
Odom frame |
odom_child_frame |
std::string |
Odom child frame |
odom_vel_lin |
std::vector<double> |
Odom linear velocity |
odom_vel_ang |
std::vector<double> |
Odom angular velocity |
odom_child_in_frame |
std::vector<double> |
Transform that child frame in odom frame |
- hex_cpp_utils
- ROS Noetic or ROS Humble
-
Create a workspace
catkin_wsand get into thesrc.mkdir -p catkin_ws/src cd catkin_ws/src -
Clone this repo.
git clone git@github.com:hexfellow/hex_cpp_template.git
-
Go to
catkin_wsdirectory and build the repo.cd ../ # For ROS1 catkin_make -DCMAKE_BUILD_TYPE=Release # For ROS2 colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release
-
Source the
setup.bashand run the test blow# For ROS1 source devel/setup.bash --extend # For ROS2 source install/setup.bash --extend
-
ROS1
-
Open a terminal and run the following command:
roslaunch hex_cpp_template hex_cpp_template.launch
-
Open a new terminal and run the following command:
rostopic pub /string_in std_msgs/String "data: 'Hello, World'" -r 10 -
Open a new terminal and run the following command:
rostopic echo /string_outYou should see output like this:
data: "hex_cpp_template: Hello, World;" --- -
Open a new terminal and run the following command:
rostopic echo /odomYou should see output like this:
header: seq: 3949 stamp: secs: 1743266556 nsecs: 337166748 frame_id: "odom" child_frame_id: "base_link" pose: pose: position: x: 1.01 y: 0.55 z: 2.02 orientation: x: 0.0 y: 0.0 z: 0.0 w: 1.0 covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] twist: twist: linear: x: 1.0 y: 0.5 z: 2.0 angular: x: 0.1 y: 0.05 z: 0.0 covariance: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] ---
-
-
ROS2
-
Open a terminal and run the following command:
ros2 launch hex_cpp_template hex_cpp_template.launch.py
-
Open a new terminal and run the following command:
ros2 topic pub /string_in std_msgs/String "data: 'Hello, World'" -r 10 -
Open a new terminal and run the following command:
ros2 topic echo /string_outYou should see output like this:
data: 'hex_cpp_template: Hello, World;' --- -
Open a new terminal and run the following command:
ros2 topic echo /odomYou should see output like this:
header: stamp: sec: 1743266135 nanosec: 446084799 frame_id: odom child_frame_id: base_link pose: pose: position: x: 1.01 y: 0.55 z: 2.02 orientation: x: 0.0 y: 0.0 z: 0.0 w: 1.0 covariance: - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 twist: twist: linear: x: 1.0 y: 0.5 z: 2.0 angular: x: 0.1 y: 0.05 z: 0.0 covariance: - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 - 0.0 ---
-