diff --git a/moveit2/Dockerfile b/moveit2/Dockerfile index 6181fd8..301cf32 100644 --- a/moveit2/Dockerfile +++ b/moveit2/Dockerfile @@ -46,12 +46,20 @@ RUN mkdir ${SPACEROS_DIR}/src \ ENV MOVEIT2_DIR=${HOME_DIR}/moveit2 # Make sure the latest versions of packages are installed -RUN sudo apt-get update -RUN sudo apt-get dist-upgrade -y +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that +# the cache won't make it into the built image but will be maintained between steps. +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get update +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get dist-upgrade -y RUN rosdep update # Install the various build and test tools -RUN sudo apt install -y \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt install -y \ build-essential \ clang-format \ cmake \ @@ -92,7 +100,9 @@ RUN cd ${MOVEIT2_DIR}/src \ RUN sudo chown -R ${USERNAME}:${USERNAME} ${MOVEIT2_DIR} # Get rosinstall_generator -RUN sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator # Generate repos file for moveit2 dependencies, excluding packages from Space ROS core. COPY --chown=${USERNAME}:${USERNAME} moveit2-pkgs.txt /tmp/ @@ -116,7 +126,9 @@ RUN vcs import src < /tmp/moveit2_tutorials.repos RUN sudo chown -R ${USERNAME}:${USERNAME} ${MOVEIT2_DIR} # Install system dependencies -RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash' \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash' \ && rosdep install --from-paths ../spaceros/src src --ignore-src --rosdistro ${ROSDISTRO} -r -y --skip-keys "console_bridge generate_parameter_library fastcdr fastrtps rti-connext-dds-5.3.1 urdfdom_headers rmw_connextdds ros_testing rmw_connextdds rmw_fastrtps_cpp rmw_fastrtps_dynamic_cpp composition demo_nodes_py lifecycle rosidl_typesupport_fastrtps_cpp rosidl_typesupport_fastrtps_c ikos diagnostic_aggregator diagnostic_updater joy qt_gui rqt_gui rqt_gui_py" # Apply a patch to octomap_msgs to work around a build issue @@ -125,10 +137,12 @@ RUN cd src/octomap_msgs && git apply octomap_fix.diff # Build MoveIt2 RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \ - && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --event-handlers desktop_notification- status- --parallel-workers 1' + && colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=ON --event-handlers desktop_notification- status-' # Add a couple sample GUI apps for testing -RUN sudo apt-get install -y \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get install -y \ firefox \ glmark2 \ libcanberra-gtk3-0 \ diff --git a/moveit2/README.md b/moveit2/README.md index e7088f8..665d620 100644 --- a/moveit2/README.md +++ b/moveit2/README.md @@ -1,13 +1,14 @@ # MoveIt2 Docker Image -The MoveIt2 Docker image uses the Space ROS docker image (*openrobotics/spaceros:latest*) as its base image. The MoveIt2 Dockerfile installs all of the prerequisite system dependencies to build MoveIt2 (and Moveit2 tutorials) and then pulls and builds the latest MoveIt2 and Moveit2 tutorials source code. +The MoveIt2 Docker image uses the Space ROS docker image (*openrobotics/spaceros:latest*) as its base image. +The MoveIt2 Dockerfile installs all of the prerequisite system dependencies to build MoveIt2 (and Moveit2 tutorials) and then pulls and builds the latest MoveIt2 and Moveit2 tutorials source code. ## Building the MoveIt2 Image To build the docker image, run: -``` -$ ./build.sh +```bash +./build.sh ``` The build process will take about 30 minutes, depending on the host computer. @@ -16,8 +17,8 @@ The build process will take about 30 minutes, depending on the host computer. After building the image, you can see the newly-built image by running: -``` -$ docker image list +```bash +docker image list ``` The output will look something like this: @@ -33,11 +34,12 @@ The new image is named **openrobotics/moveit2:latest**. There is a run.sh script provided for convenience that will run the spaceros image in a container. -``` -$ ./run.sh +```bash +./run.sh ``` -Upon startup, the container automatically runs the entrypoint.sh script, which sources the MoveIt2 and Space ROS environment files. You'll now be running inside the container and should see a prompt similar to this: +Upon startup, the container automatically runs the entrypoint.sh script, which sources the MoveIt2 and Space ROS environment files. +You'll now be running inside the container and should see a prompt similar to this: ``` spaceros-user@8e73b41a4e16:~/moveit2# @@ -47,7 +49,7 @@ spaceros-user@8e73b41a4e16:~/moveit2# Run the following command to launch the MoveIt2 tutorials demo launch file: -``` +```bash ros2 launch moveit2_tutorials demo.launch.py rviz_tutorial:=true ``` @@ -55,16 +57,20 @@ You should see lots of console output and the rviz2 window appear: ![rviz2 tutorial window](resources/moveit2-rviz-tutorial.png) -You can now following the [MoveIt2 Tutorial documentation](https://moveit.picknik.ai/main/doc/tutorials/quickstart_in_rviz/quickstart_in_rviz_tutorial.html). +You can now follow the [MoveIt2 Tutorial documentation](https://moveit.picknik.ai/main/doc/tutorials/quickstart_in_rviz/quickstart_in_rviz_tutorial.html). ## Running the MoveIt2 Move Group C++ Interface Demo To run the Move Group C++ Interface Demo, execute the following command: -``` +```bash ros2 launch moveit2_tutorials move_group.launch.py ``` ![rviz2 move group window](resources/moveit2-rviz.png) Then, you can follow the [Move Group C++ Interface Demo documentation](https://moveit.picknik.ai/humble/doc/examples/move_group_interface/move_group_interface_tutorial.html). + +## Running the Space ROS Space Robots Demos + +Once you have tested that MoveIt2 works, you are ready to run some of the other [Space ROS space robot demos](../space_robots/README.md). diff --git a/renode_rcc/Dockerfile b/renode_rcc/Dockerfile index 91a3429..41b2f59 100644 --- a/renode_rcc/Dockerfile +++ b/renode_rcc/Dockerfile @@ -2,7 +2,11 @@ FROM ubuntu:20.04 WORKDIR /root ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update -y && \ +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that +# the cache won't make it into the built image but will be maintained between steps. +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update -y && \ apt-get install -y automake \ autoconf \ ca-certificates \ @@ -18,7 +22,9 @@ RUN apt-get update -y && \ ARG RENODE_VERSION=1.13.0 USER root -RUN wget https://github.com/renode/renode/releases/download/v${RENODE_VERSION}/renode_${RENODE_VERSION}_amd64.deb && \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + wget https://github.com/renode/renode/releases/download/v${RENODE_VERSION}/renode_${RENODE_VERSION}_amd64.deb && \ apt-get update && \ apt-get install -y --no-install-recommends ./renode_${RENODE_VERSION}_amd64.deb python3-dev && \ rm ./renode_${RENODE_VERSION}_amd64.deb diff --git a/renode_rcc/README.md b/renode_rcc/README.md index 99e46ca..6137aaf 100644 --- a/renode_rcc/README.md +++ b/renode_rcc/README.md @@ -1,17 +1,18 @@ # renode-RCC -Building [RTEMS Cross Compilation System (RCC)](https://www.gaisler.com/index.php/products/operating-systems/rtems), has a different directory structure compare to building RTEMS from source (might not be true). This will run RTEMS on leon3 in a renode simulation. +Building [RTEMS Cross Compilation System (RCC)](https://www.gaisler.com/index.php/products/operating-systems/rtems), has a different directory structure compare to building RTEMS from source (might not be true). +This will run RTEMS on leon3 in a renode simulation. ## Usage To run the simulator in docker container -``` -$ renode +```bash +renode ``` > If you face GTK protocol error then exit the container, run `xhost + local:` and restart the conatiner to allow other users (including root) run programs in the current session. In the renode window, run -``` +```bash start s @renode-rtems-leon3/leon3_rtems.resc ``` diff --git a/rtems/Dockerfile b/rtems/Dockerfile index 740631c..a1a394e 100644 --- a/rtems/Dockerfile +++ b/rtems/Dockerfile @@ -2,7 +2,11 @@ FROM ubuntu:20.04 WORKDIR /root ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update \ +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that +# the cache won't make it into the built image but will be maintained between steps. +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update \ && apt-get install -y \ apt-utils \ bison \ diff --git a/rtems/README.md b/rtems/README.md index 4eba0f4..94c4215 100644 --- a/rtems/README.md +++ b/rtems/README.md @@ -10,16 +10,16 @@ example is an hello world example build using `sparc-rtems5-gcc` tool. tinyxml2 is modified to work with RTEMS build using `sparc-rtems5-gcc` tool.. ## Compile -``` -$ cd /root/tinxyxml2 -$ ./doit +```bash +cd /root/tinxyxml2 +./doit ``` ## Save build artefacts After compiling the binaries for the target, save the binaries and test payload for later use in renode. -``` -$ docker cp containerId:/root/tinyxml2/tinyxml2.o /docker/renode_rcc/build/ +```bash +docker cp containerId:/root/tinyxml2/tinyxml2.o /docker/renode_rcc/build/ -$ docker cp containerId:/root/tinyxml2/xmltest.exe /docker/renode_rcc/build/ +docker cp containerId:/root/tinyxml2/xmltest.exe /docker/renode_rcc/build/ ``` diff --git a/space_robots/Dockerfile b/space_robots/Dockerfile index 84a94d7..561802c 100644 --- a/space_robots/Dockerfile +++ b/space_robots/Dockerfile @@ -44,7 +44,11 @@ ENV GZ_VERSION fortress ARG DEBIAN_FRONTEND=noninteractive # Get rosinstall_generator -RUN sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that +# the cache won't make it into the built image but will be maintained between steps. +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get update -y && sudo apt-get install -y python3-rosinstall-generator # TODO(anyone): remove demo-pkgs.txt, no packages left after exclusions # Generate repos file for demo dependencies, excluding packages from Space ROS core. @@ -64,10 +68,14 @@ WORKDIR ${DEMO_DIR} # Install libmongoc for development -RUN sudo apt install libmongoc-dev -y +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get install libmongoc-dev -y # Compile mongo cxx driver https://mongocxx.org/mongocxx-v3/installation/linux/ -RUN sudo apt install libssl-dev build-essential devscripts debian-keyring fakeroot debhelper cmake libboost-dev libsasl2-dev libicu-dev libzstd-dev doxygen -y +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get install libssl-dev build-essential devscripts debian-keyring fakeroot debhelper cmake libboost-dev libsasl2-dev libicu-dev libzstd-dev doxygen -y RUN wget https://github.com/mongodb/mongo-cxx-driver/releases/download/r3.6.7/mongo-cxx-driver-r3.6.7.tar.gz RUN tar -xzf mongo-cxx-driver-r3.6.7.tar.gz RUN cd mongo-cxx-driver-r3.6.7/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local && sudo cmake --build . --target EP_mnmlstc_core && cmake --build . && sudo cmake --build . --target install @@ -77,7 +85,9 @@ RUN cd mongo-cxx-driver-r3.6.7/build && cmake .. -DCMAKE_BUILD_TYPE=Release -DCM COPY --chown=${USERNAME}:${USERNAME} demo_manual_pkgs.repos /tmp/ RUN vcs import src < /tmp/demo_manual_pkgs.repos && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' -RUN sudo apt-get update -y \ +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + sudo apt-get update -y \ && /bin/bash -c 'source "${SPACEROS_DIR}/install/setup.bash"' \ && /bin/bash -c 'source "${MOVEIT2_DIR}/install/setup.bash"' \ && rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROSDISTRO} diff --git a/space_robots/README.md b/space_robots/README.md index b994dba..2928caa 100644 --- a/space_robots/README.md +++ b/space_robots/README.md @@ -1,42 +1,45 @@ # Space ROS Space Robots Demo Docker Image -The Space ROS Space Robots Demo docker image uses the moveit2 docker image (*openrobotics/moveit2:latest*) as its base image. Build instructions for that image can be found at [docker/moveit2/README.md](https://github.com/space-ros/docker/blob/main/moveit2/README.md). The Dockerfile installs all of the prerequisite system dependencies along with the demos source code, then builds the Space ROS Space Robots Demo. +The Space ROS Space Robots Demo docker image uses the moveit2 docker image (*openrobotics/moveit2:latest*) as its base image. +Build instructions for that image can be found in [this README](../moveit2/README.md). +The Dockerfile installs all of the prerequisite system dependencies along with the demos source code, then builds the Space ROS Space Robots Demo. This is for Curiosity Mars rover and Canadarm demos. ## Building the Demo Docker -The demo image builds on top of the `spaceros` and `moveit2` images. To build the docker image, first build both required images, then the `space_robots` demo image: +The demo image builds on top of the `spaceros` and `moveit2` images. +To build the docker image, first build both required images, then the `space_robots` demo image: -``` -$ cd docker/spaceros -$ ./build.sh -$ cd ../moveit2 -$ ./build.sh -$ cd ../space_robots -$ ./build.sh +```bash +cd docker/spaceros +./build.sh +cd ../moveit2 +./build.sh +cd ../space_robots +./build.sh ``` ## Running the Demo Docker run the following to allow GUI passthrough: -``` -$ xhost +local:docker +```bash +xhost +local:docker ``` Then run: -``` -$ ./run.sh +```bash +./run.sh ``` -Depending on the host computer, you might need to remove ```--gpus all``` flag in ```run.sh```, which uses your GPUs. +Depending on the host computer, you might need to remove the ```--gpus all``` flag in ```run.sh```, which uses your GPUs. ## Running the Demos ### Curiosity Mars rover demo Launch the demo: -``` -$ ros2 launch mars_rover mars_rover.launch.py +```bash +ros2 launch mars_rover mars_rover.launch.py ``` On the top left corner, click on the refresh button to show camera feed. @@ -47,72 +50,72 @@ On the top left corner, click on the refresh button to show camera feed. Open a new terminal and attach to the currently running container: -``` -$ docker exec -it bash +```bash +docker exec -it bash ``` Make sure packages are sourced: -``` -$ source ~/spaceros/install/setup.bash +```bash +source ~/spaceros/install/setup.bash ``` -``` -$ source ~/demos_ws/install/setup.bash +```bash +source ~/demos_ws/install/setup.bash ``` #### Available Commands Drive the rover forward -``` -$ ros2 service call /move_forward std_srvs/srv/Empty +```bash +ros2 service call /move_forward std_srvs/srv/Empty ``` Stop the rover -``` -$ ros2 service call /move_stop std_srvs/srv/Empty +```bash +ros2 service call /move_stop std_srvs/srv/Empty ``` Turn left -``` -$ ros2 service call /turn_left std_srvs/srv/Empty +```bash +ros2 service call /turn_left std_srvs/srv/Empty ``` Turn right -``` -$ ros2 service call /turn_right std_srvs/srv/Empty +```bash +ros2 service call /turn_right std_srvs/srv/Empty ``` Open the tool arm: -``` -$ ros2 service call /open_arm std_srvs/srv/Empty +```bash +ros2 service call /open_arm std_srvs/srv/Empty ``` Close the tool arm: -``` -$ ros2 service call /close_arm std_srvs/srv/Empty +```bash +ros2 service call /close_arm std_srvs/srv/Empty ``` Open the mast (camera arm) -``` -$ ros2 service call /mast_open std_srvs/srv/Empty +```bash +ros2 service call /mast_open std_srvs/srv/Empty ``` Close the mast (camera arm) -``` -$ ros2 service call /mast_close std_srvs/srv/Empty +```bash +ros2 service call /mast_close std_srvs/srv/Empty ``` #### Canadarm demo -``` -$ ros2 launch canadarm canadarm.launch.py +```bash +ros2 launch canadarm canadarm.launch.py ``` diff --git a/space_robots/demo_manual_pkgs.repos b/space_robots/demo_manual_pkgs.repos index 1170be8..1d020f8 100644 --- a/space_robots/demo_manual_pkgs.repos +++ b/space_robots/demo_manual_pkgs.repos @@ -31,4 +31,7 @@ repositories: type: git url: https://github.com/ros-planning/warehouse_ros_mongo.git version: ros2 - \ No newline at end of file + vision_msgs: + type: git + url: https://github.com/ros-perception/vision_msgs.git + version: ros2 diff --git a/spaceros/Earthfile b/spaceros/Earthfile index 442343d..192078d 100644 --- a/spaceros/Earthfile +++ b/spaceros/Earthfile @@ -21,7 +21,7 @@ earthfile: setup: # Disable prompting during package installation ARG DEBIAN_FRONTEND=noninteractive - + # The following commands are based on the source install for ROS 2 Rolling Ridley. # See: https://docs.ros.org/en/ros2_documentation/rolling/Installation/Ubuntu-Development-Setup.html # The main variation is getting Space ROS sources instead of the Rolling sources. @@ -74,7 +74,6 @@ setup: ENV HOME_DIR=/home/${USERNAME} ENV SPACEROS_DIR=${HOME_DIR}/spaceros ARG IKOS_DIR=${HOME_DIR}/ikos - ARG REPOS_FILE_URL="https://raw.githubusercontent.com/space-ros/space-ros/main/ros2.repos" ENV ROSDISTRO=humble # Create a spaceros user @@ -92,9 +91,40 @@ setup: RUN sudo add-apt-repository ppa:kisak/kisak-mesa RUN sudo apt update && sudo apt upgrade -y +spaceros-artifacts: + # we must run it in a separate container, so that downstream tasks can be cached if vcs file does not change + FROM ubuntu:jammy + RUN apt-get update && apt-get install -y git wget + + # main purpose of this command is to make sure that the git ls-remote results are not cached + RUN --no-cache echo "Cloning spaceros repo artifacts" + + # current git branch, prefilled by earthly: https://docs.earthly.dev/docs/earthfile/builtin-args + ARG EARTHLY_GIT_BRANCH + + ARG SPACEROS_REPO_URL="https://github.com/space-ros/space-ros.git" + # if current local branch does not exist in target repo then use main. note that branch supplied from CLI overrides this behavior. + ARG SPACEROS_GIT_REF="$( [ -n \"$(git ls-remote $SPACEROS_REPO_URL $EARTHLY_GIT_BRANCH)\" ] && echo $EARTHLY_GIT_BRANCH || echo 'main' )" + # get exact commit hash. this makes sure that build will be re-triggered when new commit is pushed + ARG _GIT_COMMIT_HASH = "$(git ls-remote $SPACEROS_REPO_URL $SPACEROS_GIT_REF | cut -f 1)" + + # this means that branch specified by user from CLI does not exist + IF [ -z ${_GIT_COMMIT_HASH} ] + RUN echo "Specified branch ${SPACEROS_GIT_REF} does not exist" && exit 1 + END + + IF [ $SPACEROS_REPO_URL = "https://github.com/space-ros/space-ros.git" ] + # run wget because main repo's host is known + it is public + RUN wget https://raw.githubusercontent.com/space-ros/space-ros/${_GIT_COMMIT_HASH}/ros2.repos + ELSE + GIT CLONE --branch ${_GIT_COMMIT_HASH} ${SPACEROS_REPO_URL} . + END + SAVE ARTIFACT ros2.repos + sources: FROM +setup - COPY github.com/space-ros/space-ros:earthly-wrapper+repos-file/ros2.repos ros2.repos + COPY +spaceros-artifacts/ros2.repos ros2.repos + RUN mkdir src RUN vcs import src < ros2.repos SAVE ARTIFACT src AS LOCAL src diff --git a/spaceros/README.md b/spaceros/README.md index 1abf83e..ad84631 100644 --- a/spaceros/README.md +++ b/spaceros/README.md @@ -9,18 +9,26 @@ The [Earthly](https://earthly.dev/get-earthly) utility is required to build this To build the image, run: -``` -$ ./build.sh +```bash +./build.sh ``` The build process will take about 20 or 30 minutes, depending on the host computer. +The build process defaults to cloning the `ros2.repos` file from [spaceros](https://github.com/space-ros/space-ros) repository. +It looks for a branch with the same name as the current local branch; if it doesn't find one, it falls back to cloning from the main branch. +For testing purposes, you can customize both the spaceros repository URL and the branch name by modifying arguments defined in the [Earthfile](./Earthfile). +Example: +```bash +earthly +image --SPACEROS_REPO_URL="https://github.com/my-org/my-spaceros-fork.git" --SPACEROS_GIT_REF="my-branch-name" +``` + ## Running the Space ROS Docker Image in a Container After building the image, you can see the newly-built image by running: -``` -$ docker image list +```bash +docker image list ``` The output will look something like this: @@ -37,17 +45,18 @@ The new image is named **osrf/space-ros:latest**. The `rocker` library is required to run the built image, install it by `sudo apt-get install python3-rocker`. There is a run.sh script provided for convenience that will run the spaceros image in a container. -``` -$ ./run.sh +```bash +./run.sh ``` -Upon startup, the container automatically runs the entrypoint.sh script, which sources the Space ROS environment file (setup.bash). You'll now be running inside the container and should see a prompt similar to this: +Upon startup, the container automatically runs the entrypoint.sh script, which sources the Space ROS environment file (setup.bash). +You'll now be running inside the container and should see a prompt similar to this: ``` spaceros-user@d10d85c68f0e:~/spaceros$ ``` -At this point, you can run the 'ros2' command line utility to make sure everything is working OK: +At this point, you can run the `ros2` command line utility to make sure everything is working OK: ``` spaceros-user@d10d85c68f0e:~/spaceros$ ros2 @@ -100,7 +109,8 @@ spaceros-user@d10d85c68f0e:~/spaceros$ colcon test --ctest-args -LE "(ikos|xfail The tests include running the static analysis tools clang_tidy and cppcheck (which has the MISRA 2012 add-on enabled). -You can use colcon's --packages-select option to run a subset of packages. For example, to run tests only for the rcpputils package and display the output directly to the console (as well as saving it to a log file), you can run: +You can use colcon's `--packages-select` option to run a subset of packages. +For example, to run tests only for the rcpputils package and display the output directly to the console (as well as saving it to a log file), you can run: ``` spaceros-user@d10d85c68f0e:~/spaceros$ colcon test --event-handlers console_direct+ --packages-select rcpputils @@ -108,7 +118,8 @@ spaceros-user@d10d85c68f0e:~/spaceros$ colcon test --event-handlers console_dire ## Viewing Test Output - The output from the tests are stored in XUnit XML files, named *\*.xunit.xml. After running the unit tests, you can scan the build directory for the various *\*.xunit.xml* files. + The output from the tests are stored in XUnit XML files, named *\*.xunit.xml. +After running the unit tests, you can scan the build directory for the various *\*.xunit.xml* files. For example, a clang_tidy.xunit.xml file looks like this: @@ -163,8 +174,8 @@ Sometimes it may be convenient to attach additional terminals to a running Docke With the Space ROS Docker container running, open a second host terminal and then run the following command to determine the container ID: -``` -$ docker container list +```bash +docker container list ``` The output will look something like this: @@ -174,9 +185,10 @@ CONTAINER ID IMAGE COMMAND CREATED d10d85c68f0e openrobotics/spaceros "/entrypoint.sh …" 28 minutes ago Up 28 minutes inspiring_moser ``` -The container ID in this case, is *d10d85c68f0e*. So, run the following command in the host terminal: +The container ID in this case, is *d10d85c68f0e*. +So, run the following command in the host terminal: -``` +```bash docker exec -it d10d85c68f0e /bin/bash --init-file "install/setup.bash" ``` @@ -215,10 +227,10 @@ To generate a JUnit XML file for a specific package only, you can add the *--pac spaceros-user@d10d85c68f0e:~/spaceros$ colcon test --build-base build_ikos --install-base install_ikos --packages-select rcpputils ``` -The 'colcon test' command runs various tests, including IKOS report generation, which reads the IKOS database generated in the previous analysis step and generates a JUnit XML report file. After running 'colcon test', you can view the JUnit XML files. For example, to view the JUnit XML file for IKOS scan of the rcpputils binaries you can use the following command: +The `colcon test` command runs various tests, including IKOS report generation, which reads the IKOS database generated in the previous analysis step and generates a JUnit XML report file. +After running `colcon test`, you can view the JUnit XML files. +For example, to view the JUnit XML file for IKOS scan of the rcpputils binaries you can use the following command: ``` spaceros-user@d10d85c68f0e:~/spaceros$ more build_ikos/rcpputils/test_results/rcpputils/ikos.xunit.xml - ``` - diff --git a/zynq_rtems/Dockerfile b/zynq_rtems/Dockerfile index 7767e99..fb625ab 100644 --- a/zynq_rtems/Dockerfile +++ b/zynq_rtems/Dockerfile @@ -2,7 +2,11 @@ FROM ubuntu:20.04 WORKDIR /root ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update \ +# Using Docker BuildKit cache mounts for /var/cache/apt and /var/lib/apt ensures that +# the cache won't make it into the built image but will be maintained between steps. +RUN --mount=type=cache,target=/var/cache/apt,sharing=locked \ + --mount=type=cache,target=/var/lib/apt,sharing=locked \ + apt-get update \ && apt-get install -y \ apt-utils \ bison \ diff --git a/zynq_rtems/README.md b/zynq_rtems/README.md index f3dc5dd..89ed0d9 100644 --- a/zynq_rtems/README.md +++ b/zynq_rtems/README.md @@ -4,7 +4,8 @@ The goal is to create an hard real-time embedded application that runs on a Xilinx Zynq SoC FPGA which will communicate with Space-ROS. -This demonstration will be on [QEMU](https://www.qemu.org), the open-source CPU and system emulator. This is for several reasons: +This demonstration will be on [QEMU](https://www.qemu.org), the open-source CPU and system emulator. +This is for several reasons: * Development cycles in QEMU are much faster and less painful than hardware. * Given the state of the semiconductor industry at time of writing (late 2022), it is nearly impossible to obtain Zynq development boards. * QEMU-based work requires no upfront hardware costs or purchasing delays @@ -18,7 +19,7 @@ To simplify collecting and compiling dependencies on a wide range of systems, we You will need to install Docker on your system first, for example, using `sudo apt install docker.io` Then, run this [script](https://github.com/space-ros/docker/blob/main/zynq_rtems/build_dependencies.sh): -``` +```bash cd /path/to/zynq_rtems ./build_dependencies.sh ``` @@ -28,7 +29,7 @@ This will typically take at least 10 minutes, and can take much longer if either Next, we will use this "container full of dependencies" to compile a sample application. -``` +```bash cd /path/to/zynq_rtems ./compile_demos.sh ``` @@ -41,7 +42,8 @@ The build products will land in `zynq_rtems/hello_zenoh/build`. The emulated system that will run inside QEMU needs to have a way to talk to a virtual network segment on the host machine. We'll create a TAP device for this. The following script will set this up, creating a virtual `10.0.42.x` subnet for a device named `tap0`: -``` + +```bash ./start_network_tap.sh ``` @@ -51,15 +53,18 @@ We will need three terminals for this demo: * Zenoh-Pico publisher (in RTEMS in QEMU) First, we will start a Zenoh router: -``` + +```bash cd /path/to/zynq_rtems cd hello_zenoh ./run_zenoh_router ``` -This will print a bunch of startup information and then continue running silently, waiting for inbound Zenoh traffic. Leave this terminal running. +This will print a bunch of startup information and then continue running silently, waiting for inbound Zenoh traffic. +Leave this terminal running. In the second terminal, we'll run the Zenoh subscriber example: -``` + +```bash cd /path/to/zynq_rtems cd hello_zenoh ./run_zenoh_subscriber @@ -67,14 +72,17 @@ cd hello_zenoh In the third terminal, we will run the RTEMS-based application, which will communicate with the Zenoh router and thence to the Zenoh subscriber. The following script will run QEMU inside the container, with a volume-mount of the `hello_zenoh` demo application so that the build products from the previous step are made available to the QEMU that was built inside the container. -``` + +```bash cd /path/to/zynq_rtems cd hello_zenoh ./run_rtems.sh ``` The terminal should print a bunch of information about the various emulated Zynq network interfaces and their routing information. -After that, it should contact the `zenohd` instance running in the other terminal. It should print something like this: +After that, it should contact the `zenohd` instance running in the other terminal. +It should print something like this: + ``` Opening zenoh session... Zenoh session opened. @@ -127,6 +135,7 @@ This is a good thing. # Clean up If you would like, you can now remove the network tap device that we created in the previous step: -``` + +```bash zynq_rtems/stop_network_tap.sh ```