-
Notifications
You must be signed in to change notification settings - Fork 3
Development guidelines
Revision | date of issue | Contents |
---|---|---|
1.0 | 7/7/2020 | First edition |
[[TOC]]
This document describes the guidelines for ROS application development when developing software using the ROS/cFE conversion module.
The ROS/cFE conversion module is a conversion module for building a system by incorporating a ROS application using cFE as a platform. This document defines guidelines for developing ROS applications.
The terms used in this guideline are defined below.
Table 2-1 Definition of terms
Term | Description |
---|---|
ROS | Abbreviation for Robot OS. One of middleware for robots. |
node | Software components created with ROS. |
topic | Data communicated between ROS nodes |
package | A collection of ROS nodes in functional units |
cFE | Abbreviation for Core Flight Executive. Open source middleware for spacecraft created by NASA Goddard Space Flight Center. |
OSAL | Abbreviation for OS Abstraction Layer. The lower part of the OS-dependent part of cFE. |
The operating environment of ROS and cFE application is shown in this chapter.
This document shows the building procedure in the environment where Ubuntu 16.04 LTS is installed. The required libraries are shown below.
- gcc-multilib
- g ++-multilib
- build-essential
- libc-dev-i386
- libstdc ++ 6-4.7-dev: i386
The version of ROS used is kinetic or melodic.
Version 4.2.1 is used for OSAL. OSAL is downloaded from the following URL. Https://sourceforge.net/projects/osal/files/osal-4.2.1a-release.tar.gz/download
Version 6.5.0 of the cFE source code is used. Download cFE source code from the following URL. Https://sourceforge.net/projects/coreflightexec/files/cFE-6.5.0/
The development language is C ++.
The procedure for installing ROS kinetic is shown below. Reference URL: http://wiki.ros.org/kinetic/Installation/Ubuntu
Execute the following command.
# sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
# sudo apt-key adv --keyserver 'hkp://ha.pool.sks-keyservers.net:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
# sudo apt update
# sudo apt install ros-kinetic-desktop-full
Execute the following command to configure ROS.
# echo "source /opt/ros/kinetic/setup.bash" >> ~/.bashrc
# source ~/.bashrc
Execute the following command to perform rosinstall order.
# sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
# sudo apt-get install python-rosinstall
# sudo rosdep init
# rosdep update
The procedure for installing ROS melodic is shown below. Reference URL: http://wiki.ros.org/melodic/Installation/Ubuntu
Execute the following command.
# sudo sh -c 'echo "deb http://packages.ros.org/ros/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/ros-latest.list'
# sudo apt-key adv --keyserver 'hkp://keyserver.ubuntu.com:80' --recv-key C1CF6E31E6BADE8868B172B4F42ED6FBAB17C654
# sudo apt update
# sudo apt install ros-melodic-desktop-full
Execute the following command to configure ROS.
# echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
# source ~/.bashrc
Execute the following command to perform rosinstall order.
# sudo apt install python-rosdep python-rosinstall python-rosinstall-generator python-wstool build-essential
# sudo apt install python-rosdep
# sudo rosdep init
# rosdep update
Download the OSAL and cFE source code from the URL shown in Chapter 3.1.3.1 and 3.1.3.2 and execute the following command.
# tar -zxf cFE-6.5.0-OSS-release.tar.gz
# tar -zxf osal-4.2.1-release.tar.gz
# mv osal-4.2.1-release cFE-6.5.0-OSS-release /osal
The list of ROS functions to be ported is shown below.
Table 4-1 ROS function portability list
No. | Function name | Portability | Remarks |
---|---|---|---|
1. | Publish | 〇 | |
2. | Subscribe | 〇 | |
3. | Service | × | incompatible |
4. | Action | × | incompatible |
5. | Param | △ | Future support |
6. | Bag | △ | Future support |
The ROS functions supported by the ROS/cFE conversion module are shown below.
Table 4-2 List of supported functions
The topic / message types supported by the ROS/cFE conversion module are shown below.
Table 4-3 Supported topics / message types
The ROS package supported by the ROS/cFE conversion module is only part of tf. The supported tf package files are shown below.
Table 4-4 List of supported tf package files
No. | tf file name | Class name |
---|---|---|
1. | Matrix3x3.h | Matrix3x3 |
2. | MinMax.h | - |
3. | QuadWord.h | QuadWord |
4. | Quaternion.h | Quaternion |
5. | Scalar.h | - |
6. | StampedTransform.h | StampedTransform |
7. | Transform.h | Transform |
8. | Vector3.h | Vector3 |
The precautions when describing the ROS code are shown below.
① Do not indent global variable and global function definitions
② Do not place multiple source codes with a main statement in a ROS node
③ Separate the definition of Publisher and Subscriber from advertise / subscribe
Example)
# Conversion error
ros::Publisher ros_pub = n.advertise<std_msgs::Header>("ros_cfe_msg", 1000);
# Convertible
ros::Publisher ros_pub;
ros_pub = n.advertise<std_msgs::Header>("ros_cfe_msg", 1000);
④ Place parentheses in function definitions at the beginning of a line
[Reference] ROS cpp coding style guide
http://wiki.ros.org/CppStyleGuide
ROS sample nodes that publish and subscribe are described below.
-
sample_pub.h
#ifndef _SAMPLE_PUB_ #define _SAMPLE_PUB_ #include <ros/ros.h> #include <std_msgs/Header.h> #endif // _SAMPLE_PUB_
-
sample_pub.cpp
#include "sample_pub/sample_pub.h" int main(int argc, char** argv) { ros::init(argc, argv, "sample_pub"); ros::NodeHandle nh; ros::Publisher ros_pub; ros_pub = nh.advertise<std_msgs::Header>("ros_cfe_msg", 100); ros::Rate loop_rate(100); int count = 0; while(ros::ok()) { std_msgs::Header msg; msg.seq = count; ROS_INFO("send msg.data: %d, rostimenow.toSec: %f", msg.seq, ros::Time::now().toSec()); ros_pub.publish(msg); loop_rate.sleep(); count++; } return 0; }
-
sample_sub.h
#ifndef _SAMPLE_SUB_ #define _SAMPLE_SUB_ #include <ros/ros.h> #include <std_msgs/Header.h> #endif // _SAMPLE_SUB_
-
sample_sub.cpp
#include "sample_sub/sample_sub.h" void msgCallback(const std_msgs::Header::ConstPtr& msg) { ROS_INFO("received data: %d", msg->seq); } int main(int argc, char** argv) { ros::init(argc, argv, "sample_sub"); ros::NodeHandle nh; ros::Subscriber ros_sub; ros_sub = nh.subscribe<std_msgs::Header>("ros_cfe_msg", 100, msgCallback); ros::spin(); return 0; }
The ROS node to be developed here is assumed to be embedded software to be mounted on a spacecraft, so the mounting environment is limited by the special environment. Here, the restrictions are described.
Older versions of compilers are often used in embedded software development environments. In C / C ++, it is often at the C99 level. When developing a ROS node, using an older version such as C99 instead of the latest compiler facilitates conversion to the ROS/cFE conversion module environment.
Although the ROS node running on LinuxPC is almost unaware of the stack size, the amount of memory that can generally be used in embedded environments is small (several tens to hundreds of kilobytes). For this reason, memory destruction or the like will occur unless implemented with consideration for the stack amount. It should be noted that the implementation is as follows.
- Do not declare large class objects, arrays, etc. as local variables. Allocate memory in the heap area with new or malloc.
- Do not pass large-sized class objects, arrays, etc. to functions by value. Pass by reference.
Usually, the embedded software operates in an environment without a display or the like, and thus rarely uses the standard output. For this reason, libraries in the embedded development environment may not include those related to standard output. Use the following method to use the standard output only when debugging or developing on a Linux PC.
- Implementation example 1: Surround the standard output part with #ifdef, and comment out the compile option in the embedded environment.
- Implementation example 2: Create two standard output functions, one for debugging and one for embedded environment, and replace them with the development environment.
Compared to Linux PCs, the operating environment of embedded software has extremely low performance such as CPU clock and memory capacity. For this reason, high-performance libraries are rarely used (linking a large library increases the amount of memory). Therefore, even in a development environment, even in a Linux environment, even a library such as a general STL cannot be used in many cases. It is recommended to implement using basic functions as much as possible. If the operating environment and development environment have been determined, investigate that environment and investigate available libraries in advance.
Avoid publish / subscribe using the same topic name within one ROS node. In that case, change to a different topic name and modify other ROS nodes.
Refer to the operation manual for the building procedure.
Regarding version upgrades, either ROS or cFE shall make any changes that affect the development of spacecraft software. At the time of version upgrade, the policy is to make it backward compatible.