How leggedrobotics/maxon_epos_ethercat_sdk works
Project Type and Purpose
• This project is a C++ library designed to provide a high-level interface for controlling Maxon EPOS motor drivers over EtherCAT.
• It integrates with ROS (built with catkin and tested on Ubuntu) and relies on external libraries (like soem_interface, ethercat_sdk_master, and message_logger) to handle lower-level EtherCAT and logging functionalities.
File Structure Insights
• The top-level directories include configuration/build files (.clang-format, CMakeLists.txt, package.xml) and documentation (doc, Contributing.md, LICENSE, README.md).
• The ‘include’ directory contains public header files under a subfolder named “maxon_epos_ethercat_sdk”. These headers define key components such as Command, Configuration, Controlword, DriveState, and more.
• The ‘src’ directory provides the corresponding implementation files for the library’s logic. It mirrors the structure of the include directory, which promotes modularity and clarity.
• The presence of example configuration files (in example_configs) and documentation (doc/Usage.md) indicates that users can easily integrate or test the SDK.
Key Components
a. The High-Level API Layer:
• This includes classes like Maxon, Command, Configuration, ConfigurationParser, and other related entities.
• These components form the public interface for applications to interact with motor drivers.
b. Communication and Control Modules:
• Components handling EtherCAT command generation and state monitoring, such as Controlword, Statusword, and related modules.
• Integration with diagnostic modules (e.g., Diagnostics.cpp) for error monitoring and state management.
c. Configuration and Parsing:
• Configuration, ConfigurationParser, and example config files (YAML) from the example_configs directory represent how the library accepts and processes setup parameters.
d. External Dependencies and Integration Points:
• Other ROS/Catkin packages (ethercat_sdk_master and message_logger) the project depends on, indicating how the library fits within the broader ROS ecosystem.
Relationships and Data Flow
• How calls from the high-level API (e.g., commands from the Command module or configuration setup from the Configuration and ConfigurationParser modules) translate into EtherCAT message generation.
• How diagnostic feedback flows back into the SDK for error handling and monitoring.
Architectural Patterns and Design Principles
• Modular design: The separation between header (interface) and implementation (source) underscores a clean separation of concerns.
• Layered architecture: Distinguish between the high-level abstraction of motor control and the low-level communication details.
• Reusability and integration: Emphasize the use of external libraries (soem_interface, etc.), which offers a plug-and-play approach to building on EtherCAT functionalities.