Skip to content

Relay example type1

yuyu edited this page Jan 25, 2021 · 6 revisions

ROS and cFS System (RACS): ROS/cFE message relay example

Type1: ROS->cFE Relay

Configuration

configuration

Setup environment

Follow "Environment construction" in Manual.

Generate relay app/node

  1. Edit the following “roscfe/cfs_converter/config.ini” file according to the worker's environment.

    [setting]
    ; Output cfe directory path
    cfe_path=/home/jaxa/roscfe_ws/cFE-6.5.0-OSS-release/apps
    ; Output ros directory path
    ros_path=/home/jaxa/catkin_ws/src
    ; Log directory path
    log_dir_path=./
    ; Set path of convert target pkg directory path and read target launch file
    target_path=./convert_list.txt
    ; Whether to create relay_node and relay_app(1: create, 0: not create)
    create_relay_flag=0
    ; Set path of main function name setting 
    main_func_path=./main_func_name.yaml
    
    • Change 1: Change "cfe_path" to match the path of "apps" in your cFE project.

      Example)

      cfe_path=/home/yuyuqq/cFE-6.5.0-OSS-release/apps
      
    • Change 2: Change "ros_path" to match the path of the ROS workspace.

      Example)

      ros_path=/home/yuyuqq/catkin_ws/src
      
  2. Copy the "sample_sub_1" directory from "roscfe/tutorial/ros_cfe_relay/type1/cfe/apps/sample_sub_1" to cFE "apps" directory.

    Example)

    cp -r /home/yuyuqq/roscfe/tutorial/ros_cfe_relay/type1/cfe/apps/sample_sub_1 /home/yuyuqq/cFE-6.5.0-OSS-release/apps/
    
  3. Copy the "convert_lib" directory from "roscfe/convert_lib" to cFE "apps" directory.

    Example)

    cp -r /home/yuyuqq/roscfe/convert_lib /home/yuyuqq/cFE-6.5.0-OSS-release/apps/ 
    
  4. Copy the "sample_pub" directory from "roscfe/sample_pub" to ROS "src" directory.

    Example)

    cp -r /home/yuyuqq/roscfe/sample_pub /home/yuyuqq/catkin_ws/src/
    
  5. Edit "roscfe/cfs_converter/relay_base/relay_node_base/launch/Connection.launch". (** You can leave the default **)

    <launch>
      <ros_relay_node protocol="tcp" port="9876" port_send="9877" ip_addr="127.0.0.1" ring_length="30" />
      <cfe_relay_app port="9877" port_send="9876" ip_addr="127.0.0.1" ring_length="30" />
      <include file="./MsgId2Topic.launch" />
    </launch>
    
    • The items that can be set:
      • ros_relay_node tag, cfe_relay_app tag
        • protocol: "tcp" or "udp"
        • port: Relay message receiving port number
        • port_send: Relay message sending port number
        • ip_addr: IP address of the relay message destination (specify "127.0.0.1" for local execution)
        • ring_length: Buffer size of incoming messages
  6. Edit the "roscfe/cfs_converter/relay_base/relay_node_base/launch/MsgId2Topic.launch" as follows.

    <launch>
        <correspond topic="/ros_cfe_msg" msg_id="0x1900" cfe_data_type="std_msgs::Header" ros_data_type="std_msgs::Header" sender="0" />
    </launch>
    
  7. Go to "roscfe/cfs_converter" and run "start_cfs_relay.sh".

    cd roscfe/cfs_converter
    chmod +x start_cfs_relay.sh  
    ./start_cfs_relay.sh
    
    • If the execution is successful, the following message will be displayed at the end of the output.

      Finish creating cFS relay app & ROS relay node
      
    • After execution, "relay_app" directories will be created in the cFE project directory as shown below.

      cFE-6.5.0-OSS-release
          `-- apps
              |-- XXXX
              |-- relay_app
              |-- XXXX
              |-- XXXX
              `-- XXXX
      

      The "relay_node" directory is created in the ROS workspace as shown below.

      catkin_ws
          `-- src
              |-- relay_node
              |-- XXXX
              `-- XXXX
      
  8. Copy the "Makefile" from "roscfe/tutorial/ros_cfe_relay/type1/cfe/build/cpu1/Makefile" to cFE "build/cpu1" directory.

    Example)

    cp -r /home/yuyuqq/roscfe/tutorial/ros_cfe_relay/type1/cfe/build/cpu1/Makefile /home/yuyuqq/cFE-6.5.0-OSS-release/build/cpu1/ 
    
  9. Copy the "cfe_es_startup.scr" from "roscfe/tutorial/ros_cfe_relay/type1/cfe/build/cpu1/exe/cfe_es_startup.scr" to cFE "build/cpu1/exe" directory.

    Example)

    cp -r /home/yuyuqq/roscfe/tutorial/ros_cfe_relay/type1/cfe/build/cpu1/exe/cfe_es_startup.scr /home/yuyuqq/cFE-6.5.0-OSS-release/build/cpu1/exe/ 
    

Build

ROS side

  1. Go to the ROS workspace and run the following command

    catkin_make clean  
    catkin_make -i  
    catkin_make
    

cFE side

  1. Go to "cFE-6.5.0-OSS-release" and execute the following commands in order

    . ./setvars.sh
    cd build/cpu1  
    make config  
    make 
    

Run

Follow the procedure below to subscribe to the message delivered by the ROS sample_pub node with the cFE conversion sample_sub app. (** Be sure to execute from the ROS side **)

ROS side

  1. Execute the following command to start roscore

    roscore
    
  2. Open a new terminal, go to the ROS workspace and execute the following command to start the relay node.

    source devel/setup.bash
    rosrun relay_node relay_node
    
  3. Open a new terminal, go to the ROS workspace and run the following command to launch the sample_pub node

    source devel/setup.bash
    roslaunch sample_pub bringup.launch
    

    You can see publication log on terminal.

    ....
    [ INFO] [1606207510.466702043]: send msg.data: 1386, rostimenow.toSec: 1606207510.466692
    [ INFO] [1606207510.476702310]: send msg.data: 1387, rostimenow.toSec: 1606207510.476692
    [ INFO] [1606207510.486703073]: send msg.data: 1388, rostimenow.toSec: 1606207510.486693
    ....
    

cFE side

  1. Go to "cFE-6.5.0-OSS-release" and execute the following commands in order to start the relay application and conversion sample_sub application.

    cd build/cpu1/exe
    sudo su
    ./core-linux.bin
    

    You can see subscription log on terminal, which has the same data as publication log.

    ....
    EVS Port1 66/1/SAMPLE_SUB 0: received data: 1386
    EVS Port1 66/1/SAMPLE_SUB 0: received data: 1387
    EVS Port1 66/1/SAMPLE_SUB 0: received data: 1388
    ....