diff --git a/.gitignore b/.gitignore index c18dd8d..f637901 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,25 @@ +# Launch files +*build/ +*devel/ +*install/ +*log/ + +# Python files __pycache__/ +*.pyc +*.pyo +*.pyd + +# Git history +*.history/ + +# VS files +.vscode/ +.idea/ +*.swp + +# Dependencies +venv/ +*.egg-info/ +*.eggs/ +pip-log.txt \ No newline at end of file diff --git a/inorbit_republisher/README.md b/inorbit_republisher/README.md index c24b053..9d48dd0 100644 --- a/inorbit_republisher/README.md +++ b/inorbit_republisher/README.md @@ -181,7 +181,7 @@ You can run the commands below for building and running the republisher inside a docker run -ti --rm \ --workdir /root/ros2_ws/ \ -v .:/root/ros2_ws/src/inorbit_republisher \ - osrf/ros:foxy-desktop + osrf/ros:humble-desktop ``` ### Build diff --git a/inorbit_republisher/launch/sample_data.launch.xml b/inorbit_republisher/launch/sample_data.launch.xml new file mode 100644 index 0000000..02dfb47 --- /dev/null +++ b/inorbit_republisher/launch/sample_data.launch.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/inorbit_republisher/test/README.md b/inorbit_republisher/test/README.md new file mode 100644 index 0000000..1cb2a09 --- /dev/null +++ b/inorbit_republisher/test/README.md @@ -0,0 +1,65 @@ +# Sample data for testing + +A very simple ``rosbag`` with hardcoded data for smoke testing the transformer node. + +```bash +$root@7c94d2cf9659:~# ros2 bag info ros2_ws/src/inorbit_republisher/test/sample_data/hardcodedRosbag/rosbag2_2024_12_13-19_33_34_0.db3 + +closing. +[INFO] [1734553121.938063653] [rosbag2_storage]: Opened database 'ros2_ws/src/inorbit_republisher/test/sample_data/hardcodedRosbag/rosbag2_2024_12_13-19_33_34_0.db3' for READ_ONLY. + +Files: ros2_ws/src/inorbit_republisher/test/sample_data/hardcodedRosbag/rosbag2_2024_12_13-19_33_34_0.db3 +Bag size: 24.0 KiB +Storage id: sqlite3 +Duration: 16.005861016s +Start: Dec 13 2024 19:45:00.085674077 (1734119100.085674077) +End: Dec 13 2024 19:45:16.091535093 (1734119116.091535093) +Messages: 34 +Topic information: Topic: /my_magnetic_field | Type: sensor_msgs/msg/MagneticField | Count: 17 | Serialization Format: cdr + Topic: /my_temperature | Type: sensor_msgs/msg/Temperature | Count: 17 | Serialization Format: cdr + +``` + +To validate the node works launch the sample by using the ``sample_data.launch.xml`` launch file and look at ``out`` topic: ``ros2 topic echo my_temperature``. +1. **Start ROS2 docker container (optional)**: +You can run the commands below for building and running the republisher inside a docker container. + ```bash + docker run -ti --rm \ + --workdir /root/ros2_ws/ \ + -v .:/root/ros2_ws/src/inorbit_republisher \ + osrf/ros:humble-desktop + ``` +2. **Build the Workspace**: + Ensure the workspace is built and the environment is sourced: + ```bash + cd ~/ros2_ws + rosdep install --from-paths src -y --ignore-src + colcon build --packages-select inorbit_republisher --symlink-install + ``` +3. **Source and Run the Workspace**: +```bash +cd ros2_ws/src +colcon build --packages-select inorbit_republisher --symlink-install +source install/setup.bash +cd +ros2 launch inorbit_republisher sample_data.launch.xml +# On a different terminal windows +source /opt/ros/humble/setup.bash +ros2 topic echo inorbit/custom_data +data: my_magnetic_field_x=1.233536973711507 +--- +data: my_magnetic_field_y=6.557449696128689 +--- +data: my_magnetic_field_z=-1.6201375987982995 +--- +data: my_temperature=29.562268283427592 +--- +data: my_magnetic_field_x=-3.071746389301242 +--- +data: my_magnetic_field_y=6.080682955949868 +--- +data: my_magnetic_field_z=3.952488443512035 +--- +data: my_temperature=21.159168808582983 +--- +``` \ No newline at end of file diff --git a/inorbit_republisher/test/sample_data/config.yaml b/inorbit_republisher/test/sample_data/config.yaml new file mode 100644 index 0000000..c7eccf9 --- /dev/null +++ b/inorbit_republisher/test/sample_data/config.yaml @@ -0,0 +1,23 @@ +republishers: + - topic: "/my_magnetic_field" + msg_type: "sensor_msgs/MagneticField" + mappings: + - field: "magnetic_field.x" + out: + topic: "/inorbit/custom_data" + key: "my_magnetic_field_x" + - field: "magnetic_field.y" + out: + topic: "/inorbit/custom_data" + key: "my_magnetic_field_y" + - field: "magnetic_field.z" + out: + topic: "/inorbit/custom_data" + key: "my_magnetic_field_z" + - topic: "/my_temperature" + msg_type: "sensor_msgs/Temperature" + mappings: + - field: "temperature" + out: + topic: "/inorbit/custom_data" + key: "my_temperature" \ No newline at end of file diff --git a/inorbit_republisher/test/sample_data/hardcodedRosbag/metadata.yaml b/inorbit_republisher/test/sample_data/hardcodedRosbag/metadata.yaml new file mode 100644 index 0000000..d4b7cc5 --- /dev/null +++ b/inorbit_republisher/test/sample_data/hardcodedRosbag/metadata.yaml @@ -0,0 +1,32 @@ +rosbag2_bagfile_information: + version: 5 + storage_identifier: sqlite3 + duration: + nanoseconds: 16005861016 + starting_time: + nanoseconds_since_epoch: 1734119100085674077 + message_count: 34 + topics_with_message_count: + - topic_metadata: + name: /my_temperature + type: sensor_msgs/msg/Temperature + serialization_format: cdr + offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false" + message_count: 17 + - topic_metadata: + name: /my_magnetic_field + type: sensor_msgs/msg/MagneticField + serialization_format: cdr + offered_qos_profiles: "- history: 3\n depth: 0\n reliability: 1\n durability: 2\n deadline:\n sec: 9223372036\n nsec: 854775807\n lifespan:\n sec: 9223372036\n nsec: 854775807\n liveliness: 1\n liveliness_lease_duration:\n sec: 9223372036\n nsec: 854775807\n avoid_ros_namespace_conventions: false" + message_count: 17 + compression_format: "" + compression_mode: "" + relative_file_paths: + - rosbag2_2024_12_13-19_33_34_0.db3 + files: + - path: rosbag2_2024_12_13-19_33_34_0.db3 + starting_time: + nanoseconds_since_epoch: 1734119100085674077 + duration: + nanoseconds: 16005861016 + message_count: 34 \ No newline at end of file diff --git a/inorbit_republisher/test/sample_data/hardcodedRosbag/rosbag2_2024_12_13-19_33_34_0.db3 b/inorbit_republisher/test/sample_data/hardcodedRosbag/rosbag2_2024_12_13-19_33_34_0.db3 new file mode 100644 index 0000000..c4f6806 Binary files /dev/null and b/inorbit_republisher/test/sample_data/hardcodedRosbag/rosbag2_2024_12_13-19_33_34_0.db3 differ