weam33 / task_-2

0 stars 0 forks source link

Task _3 #2

Open weam33 opened 1 month ago

weam33 commented 1 month ago

To bridge topics between ROS 1 and ROS 2 using ros1_bridge, you'll need to follow several steps. This process involves setting up both ROS 1 and ROS 2 environments and using the ros1_bridge package to facilitate communication between them. Below is a detailed guide on how to achieve this:

  1. Setup ROS 1 and ROS 2 Ensure you have both ROS 1 (e.g., ROS Noetic) and ROS 2 (e.g., ROS 2 Foxy) installed on your system.

  2. Install ros1_bridge The ros1_bridge package enables bidirectional communication between ROS 1 and ROS 2. You need to install it in your ROS 2 workspace.

    Source your ROS 1 setup source /opt/ros/noetic/setup.bash

    Source your ROS 2 setup source /opt/ros/foxy/setup.bash

    Install the ros1_bridge package sudo apt update sudo apt install ros-foxy-ros1-bridge

  1. Launch ROS 1 Environment Start a ROS 1 node that publishes to a topic. For this example, we will use the turtlesim package in ROS 1.

Source ROS 1 setup source /opt/ros/noetic/setup.bash Start the ROS 1 core roscore

Open a new terminal and run the ROS 1 turtlesim node:

Source ROS 1 setup source /opt/ros/noetic/setup.bash

Run the turtlesim node rosrun turtlesim turtlesim_node

  1. Launch ROS 2 Environment Open another terminal and source the ROS 2 setup:

    Source ROS 2 setup source /opt/ros/foxy/setup.bash

Run the ros1_bridge ros2 run ros1_bridge dynamic_bridge

The dynamic_bridge automatically bridges all topics between ROS 1 and ROS 2.

  1. Print Topic from ROS 1 in ROS 2 Now, you can print the ROS 1 topics in ROS 2. For example, you can print the /turtle1/pose topic from the ROS 1 turtlesim in ROS 2.

Open another terminal, source the ROS 2 setup, and use ros2 topic echo:

Source ROS 2 setup source /opt/ros/foxy/setup.bash

Print the turtle1/pose topic ros2 topic echo /turtle1/pose

You should see the pose of the turtle being printed in your terminal, which is originally a ROS 1 topic now available in ROS 2. ![Uploading Task3.jpg…]()

Additional Notes

weam33 commented 1 month ago

task3

weam33 commented 1 month ago

task 3

weam33 commented 1 month ago

Run code video Task3.zip

weam33 commented 1 month ago

run