Skip to content

Instantly share code, notes, and snippets.

@domhel
Created February 19, 2022 09:52
Show Gist options
  • Select an option

  • Save domhel/4fae70ee87c1ce98131cd672a6f76266 to your computer and use it in GitHub Desktop.

Select an option

Save domhel/4fae70ee87c1ce98131cd672a6f76266 to your computer and use it in GitHub Desktop.
Create and run ROS2 Galactic example package (Ubuntu)
cd
apt update && apt upgrade -y && apt install wget
ros2 pkg create --build-type ament_python py_pubsub
wget https://raw.githubusercontent.com/ros2/examples/master/rclpy/topics/minimal_publisher/examples_rclpy_minimal_publisher/publisher_member_function.py -P ~/py_pubsub/py_pubsub
wget https://raw.githubusercontent.com/ros2/examples/master/rclpy/topics/minimal_subscriber/examples_rclpy_minimal_subscriber/subscriber_member_function.py -P ~/py_pubsub/py_pubsub
sed -i '23 i \\t\t"talker = py_pubsub.publisher_member_function:main",\n\t\t"listener = py_pubsub.subscriber_member_function:main"' ~/py_pubsub/setup.py
rosdep install -i --from-path ~ --rosdistro galactic -y
colcon build --packages-select py_pubsub
. install/setup.bash
ros2 run py_pubsub talker &
ros2 run py_pubsub listener
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment