Skip to content

Relay example type2

yuyu edited this page Jan 25, 2021 · 5 revisions

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

Type2: cFE->ROS 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_pub1" directory from "roscfe/tutorial/ros_cfe_relay/type2/cfe/apps/sample_pub_1" to cFE "apps" directory.

    Example)

    cp -r /home/yuyuqq/roscfe/tutorial/ros_cfe_relay/type2/cfe/apps/sample_pub_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_sub" directory from "roscfe/sample_sub" to ROS "src" directory.

    Example)

    cp -r /home/yuyuqq/roscfe/sample_sub /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="1" />
    </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/type2/cfe/build/cpu1/Makefile" to cFE "build/cpu1" directory.

    Example)

    cp -r /home/yuyuqq/roscfe/tutorial/ros_cfe_relay/type2/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/type2/cfe/build/cpu1/exe/cfe_es_startup.scr" to cFE "build/cpu1/exe" directory.

    Example)

    cp -r /home/yuyuqq/roscfe/tutorial/ros_cfe_relay/type2/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_sub node

    source devel/setup.bash
    roslaunch sample_sub bringup.launch
    

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_pub application.

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

    You can see publication log on terminal.

    ....
    EVS Port1 66/1/SAMPLE_PUB 0: send msg.data: 23, rostimenow.toSec: 1001000.475524
    EVS Port1 66/1/SAMPLE_PUB 0: send msg.data: 24, rostimenow.toSec: 1001000.485578
    EVS Port1 66/1/SAMPLE_PUB 0: send msg.data: 25, rostimenow.toSec: 1001000.495632
    ....
    

    After above execution, you can see subscription log on terminal at ROS side.

    ....
    [ INFO] [1606209233.831778256]: received data: 23
    [ INFO] [1606209233.840723263]: received data: 24
    [ INFO] [1606209233.850741021]: received data: 25
    ....