Skip to content

Commit

Permalink
avoiding circular reference code (#2)
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyuqq committed Feb 3, 2025
1 parent c750cae commit 4ff2dda
Show file tree
Hide file tree
Showing 34 changed files with 114 additions and 983 deletions.
2 changes: 1 addition & 1 deletion racs2_demos_on_spaceros/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.8)
project(racs2_demos_on_spaceros)
project(mars_rover)

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
Expand Down
31 changes: 24 additions & 7 deletions racs2_demos_on_spaceros/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ RUN git submodule update

# Get the RACS2 source code
WORKDIR ${RACS2_DEMO_DIR}
RUN git clone https://github.com/jaxa/racs2_bridge
RUN git clone https://github.com/jaxa/racs2_bridge -b v1.1

# Get the demo source code
# rename old demo directory and exclude from build
WORKDIR ${DEMO_DIR}/src
RUN mv demos demos_old
# RUN mv demos demos_old
RUN cp -r demos demos_old
RUN touch demos_old/COLCON_IGNORE
# git clone new demo
RUN git clone https://github.com/tt-saito/demos.git -b racs2_demo
# RUN git clone https://github.com/tt-saito/demos.git -b racs2_demo2
# RUN git clone https://github.com/space-ros/demos

# Customize cFS to run the bridge
WORKDIR ${RACS2_DEMO_DIR}/cfs
Expand All @@ -82,8 +84,12 @@ RUN cp -r cfe/cmake/sample_defs sample_defs
RUN cp -pr ${RACS2_DEMO_DIR}/racs2_bridge/cFS/Bridge/Client_C/apps/racs2_bridge_client apps/

# Deploy the run_app application and adjust the startup scripts
RUN cp -pr ${DEMO_DIR}/src/demos/mars_rover/cFS/sample_defs/* ${RACS2_DEMO_DIR}/cfs/sample_defs/
RUN cp -pr ${DEMO_DIR}/src/demos/mars_rover/cFS/apps/run_app ${RACS2_DEMO_DIR}/cfs/apps/
# RUN cp -pr ${DEMO_DIR}/src/demos/racs2_demos_on_spaceros/cFS/sample_defs/* ${RACS2_DEMO_DIR}/cfs/sample_defs/
# RUN cp -pr ${DEMO_DIR}/src/demos/racs2_demos_on_spaceros/cFS/apps/run_app ${RACS2_DEMO_DIR}/cfs/apps/
COPY cFS/sample_defs/cpu1_cfe_es_startup.scr ${RACS2_DEMO_DIR}/cfs/sample_defs/cpu1_cfe_es_startup.scr
COPY cFS/sample_defs/racs2_bridge_config.txt ${RACS2_DEMO_DIR}/cfs/sample_defs/racs2_bridge_config.txt
COPY cFS/sample_defs/targets.cmake ${RACS2_DEMO_DIR}/cfs/sample_defs/targets.cmake
COPY cFS/apps/run_app ${RACS2_DEMO_DIR}/cfs/apps/run_app

# This is necessary to run cFS inside docker
RUN sed -i -e 's/^#undef OSAL_DEBUG_PERMISSIVE_MODE/#define OSAL_DEBUG_PERMISSIVE_MODE 1/g' sample_defs/default_osconfig.h
Expand All @@ -103,14 +109,25 @@ WORKDIR ${DEMO_DIR}
# Copy bridge & racs2_msg node
RUN cp -pr ${RACS2_DEMO_DIR}/racs2_bridge/ROS2/Bridge/Server_Python/bridge_py_s src/
RUN cp -pr ${RACS2_DEMO_DIR}/racs2_bridge/Example/Case.1/ROS2/racs2_msg src/
ENV ROSDISTRO=humble


COPY CMakeLists.txt ${DEMO_DIR}/src/demos/mars_rover/CMakeLists.txt
COPY package.xml ${DEMO_DIR}/src/demos/mars_rover/package.xml
# COPY racs2_demos_on_spaceros ${DEMO_DIR}/src/demos/mars_rover/racs2_demos_on_spaceros
COPY launch/mars_rover.launch.py ${DEMO_DIR}/src/demos/mars_rover/launch/mars_rover.launch.py
COPY nodes/RACS2Bridge_geometry_msgs_pb2.py ${DEMO_DIR}/src/demos/mars_rover/nodes/RACS2Bridge_geometry_msgs_pb2.py
COPY nodes/move_wheel ${DEMO_DIR}/src/demos/mars_rover/nodes/move_wheel




# Install dependencies
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}
&& rosdep install --from-paths src --ignore-src -r -y --rosdistro ${ROS_DISTRO}

# Build the demo
RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash && source ${MOVEIT2_DIR}/install/setup.bash \
Expand Down
75 changes: 66 additions & 9 deletions racs2_demos_on_spaceros/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,87 @@ The Dockerfile installs all of the prerequisite system dependencies along with t
This is RACS2 Bridge demo for Curiosity Mars rover.

## Building the Demo Docker
To build:

The demo image builds on top of the `spaceros`, `moveit2`, `space_robots` images.
To build the docker image, first ensure the `spaceros` base image is available either by [building it locally](https://github.com/space-ros/space-ros) or pulling it.

Then build the `moveit2`, `space_robots` and `racs2_demos_on_spaceros` demo images:

```bash
git clone https://github.com/space-ros/docker.git
cd docker/moveit2
./build.sh
cd ../space_robots
./build.sh
cd ../../
./build.sh
```
For detail and please read docker/racs2_demos_on_spaceros/README.md

## Running the Demo Docker
To run (enter docker environment by docker run):

(at /path/to/demos/racs2_demos_on_spaceros/docker/racs2_demos_on_spaceros)
run the following to allow GUI passthrough:
```bash
xhost +local:docker
```

Then run:
```bash
./run.sh
```
You will need three terminals to run demo.

For instractions after entering docker, please read docker/racs2_demos_on_spaceros/README.md
Depending on the host computer, you might need to remove the ```--gpus all``` flag in ```run.sh```, which uses your GPUs.

## Running the Demos

## Reference
### Curiosity Mars rover demo
Launch the rover demo (calling Terminal 1):
```bash
source install/setup.bash
ros2 launch mars_rover mars_rover.launch.py
```

* [RACS2 Bridge by Japan Aerospace Exploration Agency (JAXA)](https://github.com/jaxa/racs2_bridge)
#### RACS2 Bridge demo

* [Hiroki Kato and Tatsuhiko Saito, "RACS2: the ROS2 and cFS System - launched" Flight Software Workshop 2023.](https://drive.google.com/drive/folders/1C9fokWGDl2e4NfgX_ZU3f98FfPe9udwQ)
##### Running racs2 bridge node
Open a new terminal (calling Terminal 2) and attach to the currently running container:

```bash
docker exec -it <container-name> bash
source install/setup.bash
ros2 run bridge_py_s bridge_py_s_node --ros-args --params-file ./src/bridge_py_s/config/params.yaml
```

##### Running cFS bridge app & run_app app
Open a new terminal (calling Terminal 3) and attach to the currently running container:

```bash
docker exec -it <container-name> bash
cd ~/racs2_ws
cd cfs/build/exe/cpu1/
./core-cpu1
```

**Executing commands to the rover must be done with this terminal active.**

* [Hiroki Kato and Tatsuhiko Saito, "ROS and cFS System (RACS): Easing Space Robotic Development post-opensource activities and ROS2 integration" Flight Software Workshop 2021.](https://drive.google.com/file/d/11L48doT_pRNs7R0hdChPALqJO849TvV2/view?usp=drive_web)

##### Available Commands

Drive commands to the rover are input via keyboard in Terimnal 3. The keymap is as follows.

* "w": Drive the rover forward
* "s": Drive the rover backward
* "a": Turn left
* "d": Turn right
* "x": Stop the rover

##### Nodes
![RACS2 demo on Space ROS Mars rover demo](racs2_demo_on_spaceros_nodes.png)

## Reference

* [RACS2 bridge project by Japan Aerospace Exploration Agency (JAXA)](https://github.com/jaxa/racs2_bridge)

* [Hiroki Kato and Tatsuhiko Saito, "RACS2: the ROS2 and cFS System - launched" Flight Software Workshop 2023.](https://drive.google.com/drive/folders/1C9fokWGDl2e4NfgX_ZU3f98FfPe9udwQ)

* [Hiroki Kato and Tatsuhiko Saito, "ROS and cFS System (RACS): Easing Space Robotic Development post-opensource activities and ROS2 integration" Flight Software Workshop 2021.](https://drive.google.com/file/d/11L48doT_pRNs7R0hdChPALqJO849TvV2/view?usp=drive_web)
13 changes: 3 additions & 10 deletions racs2_demos_on_spaceros/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ set -eo pipefail

echo ""
echo "##### Building RACS2 Demo on Space ROS Docker Image #####"
echo "##### moveit2 -> space_robots -> racs2_demos_on_spaceros #####"
echo ""

cd docker/moveit2
./build.sh
cd ../space_robots
./build.sh
cd ../racs2_demos_on_spaceros
./build.sh
cd ..
cd ..
```
docker build -t $ORG/$IMAGE:$TAG \
--build-arg VCS_REF="$VCS_REF" \
--build-arg VERSION="$VERSION" .

echo ""
echo "##### Done! #####"
Expand Down
155 changes: 0 additions & 155 deletions racs2_demos_on_spaceros/docker/moveit2/Dockerfile

This file was deleted.

Loading

0 comments on commit 4ff2dda

Please sign in to comment.