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 JAXA Bridge Demo (fixes space-ros#26)
- Loading branch information
1 parent
c316131
commit 2159d7d
Showing
32 changed files
with
1,741 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
# ----------------------------------------------------------------------------- | ||
# Dockerfile for setting up an environment with Space ROS and cFS | ||
# Author: Minahil Raza | ||
# Date: [email protected] | ||
# ----------------------------------------------------------------------------- | ||
|
||
FROM osrf/space-ros:latest | ||
|
||
# Set environment variables | ||
ENV JAXA_BRIDGE_DIR=/tmp/racs2_bridge | ||
ENV CFS_DIR=${HOME_DIR}/cfs | ||
|
||
# Install dependencies for the ROS - cFS bridge | ||
RUN sudo apt-get install -y libwebsockets-dev protobuf-c-compiler libprotobuf-c-dev python3-pip git \ | ||
&& pip3 install protobuf websockets | ||
|
||
# Set working directory and clone the JAXA bridge repository | ||
WORKDIR ${HOME_DIR} | ||
RUN git clone https://github.com/jaxa/racs2_bridge ${JAXA_BRIDGE_DIR} | ||
|
||
# Prepare cFS | ||
|
||
## Clone cFS repository | ||
RUN git clone --recursive -b v6.7.0a https://github.com/nasa/cFS/ ${CFS_DIR} | ||
WORKDIR ${CFS_DIR} | ||
RUN git submodule init \ | ||
&& git submodule update | ||
|
||
## Customize cFS to run the bridge | ||
RUN cp cfe/cmake/Makefile.sample Makefile \ | ||
&& cp -r cfe/cmake/sample_defs sample_defs \ | ||
&& cp -pr ${JAXA_BRIDGE_DIR}/cFS/Bridge/Client_C/apps/racs2_bridge_client ${CFS_DIR}/apps/ | ||
|
||
# Uncomment the following line if you only want the bridge and not the sample app. | ||
# RUN cp -p ${JAXA_BRIDGE_DIR}/cFS/Bridge/Client_C/sample_defs/* ${CFS_DIR}/sample_defs/ | ||
|
||
## Deploy the sample talker application and adjust the startup scripts | ||
RUN cp -pr ${JAXA_BRIDGE_DIR}/Example/Case.1/cFS/sample_defs/* ${CFS_DIR}/sample_defs/ | ||
COPY ./cFS_app_examples/space_robots/cfs_app/sample_talker ${CFS_DIR}/apps/sample_talker | ||
|
||
## Adjust settings for running 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 \ | ||
&& sed -i -e 's/^#undef OSAL_DEBUG_DISABLE_TASK_PRIORITIES/#define OSAL_DEBUG_DISABLE_TASK_PRIORITIES 1/g' sample_defs/default_osconfig.h \ | ||
&& sed -i -e 's/^wss_uri=.*/wss_uri=127.0.0.1/g' sample_defs/racs2_bridge_config.txt | ||
|
||
## Compile cFS | ||
RUN make SIMULATION=native prep \ | ||
&& make \ | ||
&& make install | ||
|
||
# Prepare ROS packages | ||
|
||
## Create ROS workspace | ||
WORKDIR ${HOME_DIR} | ||
RUN mkdir -p ros2-project/src | ||
|
||
## Copy bridge and example packages into the workspace | ||
RUN cp -pr ${JAXA_BRIDGE_DIR}/ROS2/Bridge/Server_Python/bridge_py_s ${HOME_DIR}/ros2-project/src/ | ||
COPY ./racs2_msg ${HOME_DIR}/ros2-project/src/racs2_msg | ||
|
||
## Compile and install ROS 2 packages | ||
WORKDIR ${HOME_DIR}/ros2-project | ||
SHELL ["/bin/bash", "-c"] | ||
RUN source ${HOME_DIR}/spaceros/install/setup.bash && colcon build --symlink-install | ||
|
||
## Adjust configuration for the JAXA bridge (IPv4 settings) | ||
RUN sed -i -e 's/wss_uri:.*/wss_uri: "127.0.0.1"/g' ./src/bridge_py_s/config/params.yaml | ||
|
||
# Set the default shell in screen to bash | ||
RUN echo "defshell -bash" > ${HOME_DIR}/.screenrc | ||
|
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,23 @@ | ||
FROM osrf/space-ros:latest | ||
|
||
# Define key locations | ||
ENV JAXA_ROS_DIR=${HOME_DIR}/jaxa_comm_ws | ||
ENV JAXA_COMM_DIR=${JAXA_ROS_DIR}/src/jaxa_comm_spaceros | ||
ENV JAXA_MSG_DIR=${JAXA_ROS_DIR}/src/racs2_msg | ||
|
||
# Copy package files for jaxa bridge | ||
RUN mkdir -p $JAXA_COMM_DIR | ||
COPY --chown=${USERNAME}:${USERNAME} ./jaxa_comm_spaceros $JAXA_COMM_DIR | ||
RUN mkdir -p $JAXA_MSG_DIR | ||
COPY --chown=${USERNAME}:${USERNAME} ./racs2_msg $JAXA_MSG_DIR | ||
|
||
# install protobuf | ||
RUN pip install protobuf==3.20.1 | ||
|
||
# Build packages | ||
WORKDIR ${JAXA_ROS_DIR} | ||
|
||
RUN /bin/bash -c 'source ${SPACEROS_DIR}/install/setup.bash \ | ||
&& colcon build' | ||
|
||
CMD ["bash"] |
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,123 @@ | ||
# RACS2 Bridge Tutorial | ||
|
||
This tutorial demonstrates the use of the RACS2 (ROS and cFS System 2) Bridge to facilitate communication between Space ROS and Core Flight Executives (cFE). The cFE is a core component of NASA-supplied spacecraft software, the Core Flight System (CFS). | ||
|
||
## Directory Overview | ||
|
||
- **jaxa_comm_spaceros**: Ros package for communication over the bridge. | ||
- **racs2_msg**: Ros package containing message definitions for communication between ROS 2 and cFS. | ||
- **cFS_app_examples**: Example apps for cFS. | ||
- **Dockerfile.jaxa_spaceros_cfs**: Dockerfile for building the `jaxa_spaceros_cfs` container. It uses the spaceros image as its base. | ||
- **Dockerfile.jaxa_spaceros_listener**: Dockerfile for building the `jaxa_spaceros_listener` container. It uses the spaceros image as its base. | ||
- **run_jaxa_spaceros_cfs.sh**: Script to run the `jaxa_spaceros_cfs` container. | ||
- **run_jaxa_spaceros_listener.sh**: Script to run the `jaxa_spaceros_listener` container. | ||
- **build.sh**: Script to build two Docker images: `jaxa_spaceros_listener` and `jaxa_spaceros_cfs`. | ||
|
||
|
||
|
||
## Dependencies | ||
|
||
To get started, ensure you have Docker Desktop installed on your system. This tutorial uses the Space ROS image, which can either be pulled from a registry or built locally. | ||
|
||
## Build Instructions | ||
|
||
To build the two necessary Docker containers, simply run the provided `build.sh` script: | ||
|
||
```bash | ||
./build.sh | ||
``` | ||
|
||
Once completed, you will have two Docker images: **jaxa_spaceros_listener** and **jaxa_spaceros_cfs**. | ||
|
||
## Usage Instructions | ||
###Terminal 1: Start the cFS Container | ||
|
||
To start the `jaxa_spaceros_cfs` container, run: | ||
```bash | ||
./run_jaxa_spaceros_cfs.sh | ||
``` | ||
|
||
When the bash terminal for the container opens, execute the following commands to start the bridge nodes: | ||
```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 | ||
``` | ||
|
||
### Terminal 2: Start the cFE Publisher | ||
Connect to the same `jaxa_spaceros_cfs` container using | ||
```bash | ||
docker exec -it jaxa_spaceros_cfs bash | ||
``` | ||
|
||
Now, run the following commands inside the container to send messages over the bridge: | ||
```bash | ||
cd ../cfs/build/exe/cpu1/ | ||
./core-cpu1 | ||
``` | ||
|
||
### Terminal 3: Start the Listener Node | ||
The `jaxa_comm_spaceros` package provides different examples of listener nodes, including demos of interacting with the Curiosity Rover and Canadarm. | ||
|
||
#### Example 1: Simple Listener Demo | ||
In this example, a simple listener node is spawned which would receive the message and print it. | ||
|
||
First, run the `jaxa_spaceros_listener` container using the following script: | ||
```bash | ||
./run_jaxa_spaceros_listener.sh | ||
``` | ||
|
||
Then, run the following commands inside the container to start the listener node: | ||
```bash | ||
source install/setup.bash | ||
ros2 run jaxa_comm_spaceros jaxa_simple_listener | ||
|
||
``` | ||
|
||
#### Example 2: JAXA Bridge and Curiosity Rover Demo | ||
In this example, the listener node received numbers as a message from the cFS (commands) over the bridge and performs an action accordingly including moving and stopping the rover, turning the rover, opening and closing the tool arm or the mast. | ||
|
||
You need to build the space_robots image or run the curiosity rover on your own machine prior to running this example by following the instructions in the [demos](https://github.com/space-ros/demos) and [docker](https://github.com/space-ros/docker/tree/main) repos. | ||
|
||
Once you run the demo docker container, launch the demo using: | ||
```bash | ||
ros2 launch mars_rover mars_rover.launch.py | ||
``` | ||
|
||
Then, run the `jaxa_spaceros_listener` container using the following script: | ||
```bash | ||
./run_jaxa_spaceros_listener.sh | ||
``` | ||
|
||
Then, run the following commands inside the container to start the rover listener node: | ||
```bash | ||
source install/setup.bash | ||
ros2 run jaxa_comm_spaceros jaxa_rover_listener | ||
|
||
``` | ||
|
||
#### Example 3: JAXA Bridge and Canadarm Demo | ||
In this example, the listener node received numbers as a message from the cFS (commands) over the bridge and performs an action accordingly by calling services for the Canadarm. | ||
|
||
Similar to example 2, you need to build the space_robots image or run the Canadarm demo on your own machine prior to running this example. | ||
|
||
Once you run the demo docker container, launch the demo using: | ||
```bash | ||
ros2 launch canadarm canadarm.launch.py | ||
``` | ||
|
||
Then, run the `jaxa_spaceros_listener` container using the following script: | ||
```bash | ||
./run_jaxa_spaceros_listener.sh | ||
``` | ||
|
||
Then, run the following commands inside the container to start the canadarm listener node: | ||
```bash | ||
source install/setup.bash | ||
ros2 run jaxa_comm_spaceros jaxa_canadarm_listener | ||
|
||
``` | ||
|
||
## Notes | ||
- When running ROS nodes inside docker containers, all the containers must be over the same network. | ||
- The listener node can be run in the same spaceros container as the bridge and cFS. Two separate containers demonstrate a scenario where different systems are communicating over the RACS2 Bridge. | ||
|
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,26 @@ | ||
#!/bin/bash | ||
|
||
# Define variables | ||
APP1="jaxa_spaceros_cfs" | ||
APP2="jaxa_spaceros_listener" | ||
|
||
# Define Docker image names | ||
IMAGE1="jaxa_spaceros_cfs" | ||
IMAGE2="jaxa_spaceros_listener" | ||
|
||
# Define Dockerfile names | ||
DOCKERFILE1="Dockerfile.${APP1}" | ||
DOCKERFILE2="Dockerfile.${APP2}" | ||
|
||
# Exit script with failure if build fails | ||
set -eo pipefail | ||
|
||
# Build Docker images | ||
echo "Building Docker image for ${APP1}..." | ||
docker build -t $IMAGE1 -f $DOCKERFILE1 . | ||
|
||
echo "Building Docker image for ${APP2}..." | ||
docker build -t $IMAGE2 -f $DOCKERFILE2 . | ||
|
||
echo "Docker images built successfully." | ||
|
15 changes: 15 additions & 0 deletions
15
jaxa_integration/cFS_app_examples/space_robots/cfs_app/sample_talker/CMakeLists.txt
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,15 @@ | ||
cmake_minimum_required(VERSION 2.6.4) | ||
project(CFE_SAMPLE_TALKER C) | ||
|
||
include_directories(fsw/mission_inc) | ||
include_directories(fsw/platform_inc) | ||
|
||
aux_source_directory(fsw/src APP_SRC_FILES) | ||
|
||
# Create the app module | ||
add_cfe_app(sample_talker ${APP_SRC_FILES}) | ||
|
||
target_link_libraries(sample_talker | ||
${PROTOBUF_LIBRARY} | ||
protobuf-c | ||
) |
7 changes: 7 additions & 0 deletions
7
...S_app_examples/space_robots/cfs_app/sample_talker/fsw/mission_inc/sample_talker_perfids.h
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,7 @@ | ||
#ifndef _sample_talker_perfids_h_ | ||
#define _sample_talker_perfids_h_ | ||
|
||
|
||
#define SAMPLE_APP_PERF_ID 91 | ||
|
||
#endif /* _sample_talker_perfids_h_ */ |
9 changes: 9 additions & 0 deletions
9
...S_app_examples/space_robots/cfs_app/sample_talker/fsw/platform_inc/sample_talker_msgids.h
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,9 @@ | ||
#ifndef _sample_talker_msgids_h_ | ||
#define _sample_talker_msgids_h_ | ||
|
||
#define SAMPLE_TALKER_CMD_MID 0x1892 | ||
#define SAMPLE_TALKER_SEND_HK_MID 0x1893 | ||
#define SAMPLE_TALKER_HK_TLM_MID 0x0893 | ||
#define RACS2_BRIDGE_MID 0x1EFE | ||
|
||
#endif /* _sample_talker_msgids_h_ */ |
Oops, something went wrong.