Attributes of High-Quality ROS2-Based Systems

high-quality-ros-system

Below are the attributes of high-quality ROS2-based systems.

Compatibility

Use standard ROS 2 message formats as much as possible to ensure the project is compatible with other ROS2-based systems.

Avoid using non-standard tools or libraries that may not be accessible to everyone.

Independence

Design ROS 2 nodes to be as hardware-independent as possible.

Extendibility

Make it easy to add new features and functionality.

Maintainability

Write and document code so that it is easy to make changes in the future.

Modularity

Divide nodes into small, independent, loosely coupled, highly cohesive, functional modules to avoid high technical debt. Each node should have a clear responsibility, and make sure nodes have minimal dependence on each other.

The easiest way to ensure modularity is to isolate what changes. Code that is likely to change in the future should be isolated from the rest of the system.

Performance

Software should be responsive and stable when run under its expected workload.

One technique for improving performance and reducing overhead at runtime is to not persist raw data if only a piece of it will be used. 

For example, if you have a robotic arm on a conveyor belt with an overhead camera, save only the pixels of the camera image that change. Do not save all pixels from all video frames. This technique was used in this ROS system.

Readability

Make code easy to understand and follow. Someone else should be able to look at your code and figure out what is going on.

Reliability

The system should behave as it is expected to behave. You can achieve good reliability by running many tests on the software to minimize the probability of future failure.

Resiliency

ROS 2 nodes should be able to handle gaps in sensor data as well as times when there is an overload of sensor data. Using an Extended Kalman Filter to estimate the robot’s state via a motion model is a good design choice.

Reusability

Write code so that it could easily be reused in an entirely different project.

Safety

Think about different scenarios that could cause the robot to do harm to a person or object, and write code to handle these scenarios (e.g. run into a wall at full speed).

Security

Add safeguards to the system to make it robust to tampering. 

Testability

Make it easy to debug your code and ensure the system is working correctly.

“Anything that can go wrong, will go wrong.”

Murphy’s Law

Think of all the ways that your code can break under abuse from users, and write test cases for those scenarios to see how your system holds up.

What Are the Most Important Attributes?

This paper mentions that maintainability, performance, and reliability (in order from most important to least important) are the most important attributes for a ROS-based system.

References

I. Malavolta, G. Lewis, B. Schmerl, P. Lago and D. Garlan, “How do you Architect your Robots? State of the Practice and Guidelines for ROS-based Systems,” 2020 IEEE/ACM 42nd International Conference on Software Engineering: Software Engineering in Practice (ICSE-SEIP), 2020, pp. 31-40.