- Docker installed on your system.
- A working internet connection to pull Docker images and dependencies.
- X11 server installed and configured for GUI-based applications. (For Linux users, this is typically installed by default; for Mac, consider using XQuartz; for Windows, VcXsrv).
-
Clone the Repository
Clone the repository to your local machine:
git clone https://github.com/ZhiangChen/virtual_shake_robot_pybullet.git && cd virtual_shake_robot_pybullet
-
Build the Docker Image
Inside the cloned repository, build the Docker image with the following command:
cd docker docker build -t vsr_pybullet .
This will create a Docker image named
vsr_pybullet
. TheDockerfile
will install all the dependencies, including PyBullet and ROS2 Humble. -
Enable X11 Forwarding for GUI Applications
For GUI applications to work (e.g., viewing PyBullet's simulation environment), you need to enable X11 forwarding:
-
Linux:
- Allow Docker to use your display by running:
xhost +local:docker
- Allow Docker to use your display by running:
-
Mac (using XQuartz):
- Start XQuartz from your Applications.
- Allow connections from localhost by going to
XQuartz > Preferences
, navigating to theSecurity
tab, and checkingAllow connections from network clients
. - Run the following in your terminal:
xhost + 127.0.0.1
-
Windows (using VcXsrv):
- Start VcXsrv with the default configuration, making sure to enable the "Disable access control" option.
-
-
Run the Docker Container
Now, run the Docker container with X11 forwarding:
docker run -it --rm --name vsr_pybullet_container -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix vsr_pybullet
- The
-e DISPLAY=$DISPLAY
flag ensures that the display is correctly forwarded to your host. - The
-v /tmp/.X11-unix:/tmp/.X11-unix
mounts the X11 socket to enable GUI support.
This will start a container named
vsr_pybullet_container
from thevsr_pybullet
image. The-it
flag runs the container interactively, and the--rm
flag ensures that the container is removed once you exit. - The
-
Access the ROS2 Workspace
Once inside the Docker container, navigate to the ROS2 workspace and build the package:
cd ~/ros2_ws/src/virtual_shake_robot_pybullet colcon build --packages-select virtual_shake_robot_pybullet
-
Source the ROS2 Environment
Before running any ROS2 commands, source the workspace:
source ~/ros2_ws/install/setup.bash
-
Run the Simulation
You can now run the Virtual Shake Robot simulations as you would on a native setup. For example:
ros2 launch virtual_shake_robot_pybullet <launch_file>.launch.py
Replace
<launch_file>
with the appropriate launch file name.
- If you encounter any display issues, make sure that your X11 server is running correctly and that the
xhost
settings are properly configured. - This setup assumes that you are using the default display
:0
. If you are using a different display, adjust theDISPLAY
environment variable accordingly.