?? How I Run ROS 2 on macOS with Docker – Stress-Free Robotics!
Image downloaded from docker website

?? How I Run ROS 2 on macOS with Docker – Stress-Free Robotics!


Cross-platform robotics development used to feel like forcing a square peg into a round hole. Most ROS tools are built for Linux, and running them on macOS was a nightmare.

But I’ve found a solution—Docker. It’s like an all-terrain vehicle for ROS development. No dual-booting. No Linux VMs. Just smooth sailing. Here’s how I got things working:


1?? Pulling the Docker Image

First, I grabbed the ROS 2 "Jazzy" core image from Docker Hub:

docker pull ros:jazzy-ros-core  
        

I verified the download by running:

docker images  
        

Output: ros | jazzy-ros-core | 505MB | 8 weeks ago


2?? Customizing the Image

Next, I needed to add a few key packages. I created a Dockerfile with this:

FROM ros:jazzy-ros-core  
RUN apt-get update && apt-get install -y \  
    ros-jazzy-demo-nodes-cpp \  
    ros-jazzy-foxglove-bridge \  
    ros-jazzy-tf2-ros  
        

Then I built the image:

docker build -t rosdemo .  
        

3?? Running the ROS 2 Container

To get things running, I used this command to open an interactive terminal:

docker run --rm -it rosdemo bash  
        

4?? Publishing Data in ROS 2

Once inside the container, I published a /chatter topic:

ros2 run demo_nodes_cpp talker  
        

5?? Viewing the Data

In another terminal, I ran this to check the messages:

docker run --rm -it rosdemo ros2 topic echo /chatter  
        

Output: "Hello world!"


6?? Visualizing with Foxglove

To take it further, I connected to Foxglove:

  1. I launched the Foxglove Bridge: docker run --rm -it -p 8765:8765 rosdemo ros2 launch foxglove_bridge foxglove_bridge_launch.xml
  2. Opened Foxglove Desktop and connected to: ws://localhost:8765
  3. Added a "Raw Messages" panel and subscribed to /chatter.


Using Docker, I can now develop ROS 2 on my Mac with zero friction—no need to dual-boot or mess with Linux. It's been a game-changer for my workflow!

If you're struggling with cross-platform robotics, give Docker a shot. Let’s build something awesome together! ??

要查看或添加评论,请登录

Tanmay Kadam的更多文章

社区洞察

其他会员也浏览了