forked from space-ros/demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add gazebo docker image for canadarm_demo
Related to space-ros/space-ros#178
- Loading branch information
1 parent
aa27bb5
commit cd2f1eb
Showing
5 changed files
with
133 additions
and
157 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
FROM ros:humble-ros-core-jammy | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | ||
ENV ROS_DISTRO=humble | ||
ENV USERNAME=spaceros-user | ||
ENV HOME=/home/spaceros-user | ||
ENV IGNITION_VERSION=fortress | ||
ENV GZ_VERSION=fortress | ||
|
||
# Install dependencies | ||
RUN apt update && apt install -y ros-${ROS_DISTRO}-rmw-cyclonedds-cpp \ | ||
wget \ | ||
curl \ | ||
&& apt clean \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
RUN wget https://packages.osrfoundation.org/gazebo.gpg -O /usr/share/keyrings/pkgs-osrf-archive-keyring.gpg\ | ||
&& echo "deb [arch=amd64 signed-by=/usr/share/keyrings/pkgs-osrf-archive-keyring.gpg] http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" | tee /etc/apt/sources.list.d/gazebo-stable.list > /dev/null | ||
|
||
# Install Gazebo | ||
RUN apt-get update -qq \ | ||
&& apt-get install -y \ | ||
gz-${GZ_VERSION} \ | ||
libgz-sim7 \ | ||
libgz-transport12 \ | ||
libgz-gui7 \ | ||
build-essential\ | ||
ros-${ROS_DISTRO}-rcl-interfaces\ | ||
ros-${ROS_DISTRO}-rclcpp\ | ||
ros-${ROS_DISTRO}-builtin-interfaces\ | ||
ros-${ROS_DISTRO}-ros-gz\ | ||
ros-${ROS_DISTRO}-sdformat-urdf\ | ||
ros-${ROS_DISTRO}-vision-msgs\ | ||
ros-${ROS_DISTRO}-actuator-msgs\ | ||
ros-${ROS_DISTRO}-image-transport\ | ||
ros-${ROS_DISTRO}-xacro\ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
|
||
# Install Rviz2 | ||
RUN apt-get update -qq \ | ||
&& apt-get install -y \ | ||
ros-${ROS_DISTRO}-rviz2 \ | ||
ros-${ROS_DISTRO}-moveit-ros-visualization \ | ||
ros-${ROS_DISTRO}-nav2-rviz-plugins \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
# Demo package | ||
RUN mkdir -p ${HOME}/canadarm2_ws/src | ||
WORKDIR ${HOME}/canadarm2_ws/src | ||
COPY ./canadarm_description ./canadarm_description | ||
COPY ./canadarm_gazebo ./canadarm_gazebo | ||
COPY .defaults.yaml ${HOME}/canadarm2_ws/.defaults.yaml | ||
|
||
RUN apt update \ | ||
&& apt install -y python3-rosdep python3-colcon-common-extensions \ | ||
&& apt clean \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& rosdep init \ | ||
&& rosdep update | ||
|
||
RUN . /opt/ros/humble/setup.sh \ | ||
&& cd ${HOME}/canadarm2_ws \ | ||
&& apt update \ | ||
&& rosdep install --from-paths src --ignore-src -r -y \ | ||
&& colcon build | ||
|
||
WORKDIR ${HOME}/canadarm2_ws | ||
|
||
RUN apt update && apt install -y ros-humble-ros-ign-gazebo | ||
RUN echo "source /opt/ros/humble/setup.bash" >> ${HOME}/.bashrc | ||
RUN echo "source ${HOME}/canadarm2_ws/install/setup.bash" >> ${HOME}/.bashrc | ||
|
||
CMD ign gazebo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
version: "3" | ||
|
||
services: | ||
canadarm_gui: | ||
image: osrf/space-ros:gui | ||
build: | ||
context: ./ | ||
dockerfile: ./Dockerfile.GUI | ||
# runtime: nvidia | ||
environment: | ||
- PYTHONUNBUFFERED=1 # important to show error messages if a ros service crashes! | ||
- DISPLAY # for UI | ||
- QT_X11_NO_MITSHM=1 #fix some QT bugs | ||
- NVIDIA_VISIBLE_DEVICES=all # for docker-nvidia2 | ||
- NVIDIA_DRIVER_CAPABILITIES=all # for docker-nvidia2 | ||
- XDG_RUNTIME_DIR | ||
- __NV_PRIME_RENDER_OFFLOAD=1 | ||
- __GLX_VENDOR_LIBRARY_NAME=nvidia | ||
- XAUTHORITY=$XAUTHORITY | ||
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | ||
volumes: | ||
- /tmp/.X11-unix:/tmp/.X11-unix:rw # for UI | ||
- /run/user:/run/user:ro # for UI | ||
command: | ||
[ | ||
"bash", | ||
"-c", | ||
"source /opt/ros/$ROS_DISTRO/setup.bash && source ~/canadarm2_ws/install/setup.bash && ros2 launch canadarm_gazebo canadarm.launch.py", | ||
] | ||
network_mode: host | ||
privileged: true # for UI | ||
deploy: | ||
resources: | ||
reservations: | ||
devices: | ||
- driver: nvidia | ||
count: 1 | ||
capabilities: [gpu] | ||
canadarm_demo: | ||
image: osrf/space-ros:canadarm_demo | ||
build: | ||
context: ./ | ||
dockerfile: ./Dockerfile | ||
environment: | ||
- PYTHONUNBUFFERED=1 # important to show error messages if a ros service crashes! | ||
- RMW_IMPLEMENTATION=rmw_cyclonedds_cpp | ||
network_mode: host | ||
command: | ||
[ | ||
"bash", | ||
"-c", | ||
"source /home/spaceros-user/canadarm_ws/install/setup.bash && ros2 launch canadarm_demo canadarm.launch.py", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,4 @@ | ||
#!/bin/bash | ||
|
||
# shellcheck disable=SC2089 | ||
XTERM_CONFIG="-bg black -fg white -fa 'Monospace' -fs 11" | ||
DOCKER_IMAGE="osrf/space-ros:canadarm_demo" | ||
LOCAL_WORKSPACE=$(pwd) | ||
|
||
# Run the CanadArm Gazebo simulation locally | ||
run-gazebo() { | ||
# shellcheck disable=SC2090 | ||
# shellcheck disable=SC2086 | ||
xterm $XTERM_CONFIG -T 'CanadArm2 Gazebo' -e "source /opt/ros/\${ROS_DISTRO}/setup.bash \ | ||
&& source $LOCAL_WORKSPACE/install/setup.bash \ | ||
&& ros2 launch canadarm_gazebo canadarm.launch.py" & | ||
} | ||
|
||
run-control-demo() { | ||
# shellcheck disable=SC2090 | ||
# shellcheck disable=SC2086 | ||
xterm $XTERM_CONFIG -T 'CanadArm2 Demo' -e "docker run -it --rm \ | ||
-e RMW_IMPLEMENTATION=rmw_cyclonedds_cpp \ | ||
$DOCKER_IMAGE \ | ||
bash -c 'source /home/spaceros-user/canadarm_ws/install/setup.bash && ros2 launch canadarm_demo canadarm.launch.py'" & | ||
} | ||
|
||
check_docker() { | ||
if ! command -v docker &>/dev/null; then | ||
echo "Docker is not installed. Please install Docker to continue." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_xterm() { | ||
if ! command -v xterm &>/dev/null; then | ||
echo "xterm is not installed. Please install xterm to continue." | ||
echo "On Ubuntu, you can install xterm with 'sudo apt install xterm'." | ||
exit 1 | ||
fi | ||
} | ||
|
||
check_ros2() { | ||
if ! command -v ros2 &>/dev/null; then | ||
echo "ROS 2 is not installed. Please install ROS 2 to continue." | ||
exit 1 | ||
fi | ||
} | ||
|
||
run() { | ||
|
||
check_docker | ||
check_xterm | ||
check_ros2 | ||
|
||
run-gazebo | ||
run-control-demo | ||
} | ||
|
||
run | ||
docker-comppose down | ||
docker-compose up -d |