Configuration
EtherCAT Master 配置
代码 1 EtherCAT Master 配置
<ros2_control name="mySystem" type="system">
<hardware>
<plugin>ethercat_driver/EthercatDriver</plugin>
<param name="master_id">0</param>
<param name="control_frequency">100</param>
</hardware>
</ros2_control>如 代码 1 所示,EtherCAT driver 作为一个 hardware interface 被加载。
EtherCAT Slave 配置
代码 2 EtherCAT Slave 配置
<ec_module name="ECModule">
<plugin>ethercat_plugins/ECModule</plugin>
<param name="alias">0</param>
<param name="position">1</param>
</ec_module>如 代码 2 所示,EtherCAT slave module被配置为一个 plugin 插件。
基本应用实例
<gpio name="myGPIO">
<command_interface name="dig_output.1"/>
<command_interface name="dig_output.2"/>
<state_interface name="ana_input.1"/>
<state_interface name="ana_input.2"/>
<ec_module name="EL3104">
<plugin>ethercat_generic_plugins/GenericEcSlave</plugin>
<param name="alias">0</param>
<param name="position">0</param>
<param name="slave_config">/path/to/EL3104_slave_config.yaml</param>
</ec_module>
<ec_module name="EL2008">
<plugin>ethercat_generic_plugins/GenericEcSlave</plugin>
<param name="alias">0</param>
<param name="position">1</param>
<param name="slave_config">/path/to/EL2008_slave_config.yaml</param>
</ec_module>
</gpio>在上述代码中,<gpio> 标签定义了一个 GPIO 接口,<ec_module> 标签定义了 EtherCAT slave module,以ethercat_generic_plugins/GenericEcSlave这一通用形式进行定义,在’‘中只需要定义alias,position和slave_config即可。而具体处理方案则被移入slave_config.yaml文件中。
- alias: 表示从站的别名地址
- position: 表示从站在拓扑结构中的物理位置
- slave_config: 表示从站的配置文件路径