ROS2 CANopen 使用教程(一)+https://developer.aliyun.com/article/1585394
2.3.3 设备部分
通过设备配置可以配置所连接 CANopen 设备的特性。
注意事项
需要注意的是,在选择操作(简单节点或托管节点)时,应仅选择生命周期驱动程序或仅选择简单驱动程序。
混合使用将不起作用!
配置项 | 描述 |
driver |
The fully qualified class name of the driver to use. (要使用的驱动程序的全限定类名。) |
package |
The ros2 package name in which the driver class can be found. (可以找到驱动程序类的 ros2 软件包名称。) |
enable_lazy_load |
A flag that states whether the driver is loaded on start-up. (表示是否在启动时加载驱动程序的标志。) |
dcf |
The filename of the EDS/DCF describing the slave (mandatory). (描述从属设备的 EDS/DCF 文件名(必须填写)。) |
dcf_path |
The directory in which the generated .bin file will be available at runtime (default: see options section). (运行时生成的 .bin 文件所在的目录(默认值:参见选项部分)。) |
node_id |
The node-ID (default: 255, can be omitted if specified in the DCF). (节点 ID(默认值:255,如果在 DCF 中指定,则可省略)。) |
revision_number |
The revision number (default: 0x00000000, can be omitted if specified in the DCF). (修订版本号(默认值:0x00000000,如果在 DCF 中指定,则可省略)。) |
serial_number |
The serial number (default: 0x00000000, can be omitted if specified in the DCF). (序列号(默认值:0x00000000,可在 DCF 中省略)。) |
heartbeat_multiplier |
The multiplication factor used to obtain master heartbeat consumer time from the slave heartbeat producer time (default: see options section). (用于从心跳生产者时间中获取主心跳消费者时间的乘法系数(默认值:参见选项部分)。) |
heartbeat_consumer |
Specifies whether the slave should monitor the heartbeat of the master (default: false). (指定从属设备是否应监控主设备的心跳(默认值:false)。) |
heartbeat_producer |
The heartbeat producer time in ms (default: 0). (以毫秒为单位的心跳生产者时间(默认值:0)。) |
error_behavior |
A dictionary of error behaviors for different classes or errors (default: {}, see object 1029). (针对不同类别或错误的错误行为字典(默认值:{},参见对象 1029)。) |
rpdo |
The Receive-PDO configuration (see below). (接收-PDO 配置(见下文)。) |
tpdo |
The Transmit-PDO configuration (see below). (发送-PDO 配置(见下文)。) |
boot |
Specifies whether the slave will be configured and booted by the master (default: true, see bit 2 in object 1F81). (指定从站是否由主站配置和启动(默认值:true,参见对象 1F81 中的第 2 位)。) |
mandatory |
Specifies whether the slave is mandatory (default: false, see bit 3 in object 1F81). (指定从属设备是否必须使用(默认值:false,参见对象 1F81 中的第 3 位)。) |
reset_communication |
Specifies whether the NMT reset communication command may be sent to the slave (default: true, see bit 4 in object 1F81). (指定是否可以向从属设备发送 NMT 复位通信命令(默认值:true,参见对象 1F81 中的第 4 位)。) |
software_file |
The name of the file containing the firmware (default: “”, see object 1F58). (含有固件的文件名(默认值:"",参见对象 1F58)。) |
software_version |
The expected software version (default: 0x00000000, see object 1F55).(预期软件版本(默认值:0x00000000,参见对象 1F55)。) |
configuration_file |
The name of the file containing the configuration (default: “<dcf_path>/<name>.bin” (where <name> is the section name), see object 1F22).(包含配置的文件名(默认值:"<dcf_path>/<name>.bin"(其中 <name> 为部分名称),请参见对象 1F22)。) |
restore_configuration |
The sub-index of object 1011 to be used when restoring the configuration (default: 0x00).(恢复配置时使用的对象 1011 的子索引(默认值:0x00)。) |
sdo_timeout_ms |
The timeout to use for SDO reads/writes to this device. (default: 20ms) (用于 SDO 读/写该设备的超时。(默认值:20ms)) |
sdo |
Additional SDO requests to be sent during configuration (see below). (配置期间要发送的附加 SDO 请求(见下文)。) |
2.3.4 更多参考资料
dcfgen 文档详细介绍了如何使用 dcfgen 工具生成 DCF: https://opensource.lely.com/canopen/docs/dcf-tools/
2.3.5 变量
@bus_config_path@: 如果遵循配置包结构,则自动定义配置路径。
2.4 配置包 CMake
为了构建配置包并从总线配置文件和 eds/dcf 文件生成必要的运行时工件,ly_core_libraries 包包含一个额外的 CMAKE 宏。
cogen_dcf(target)
目标:配置的名称(例如,config/{bus_config_name_1} 就是 bus_config_name_1)
cogen_dcf(bus_config)
2.5 主驱动程序
主驱动程序负责创建必要的 can 接口,并建立一个 canopen 事件循环,供驱动程序挂接。此外,该节点还提供通过 nmt 和 sdo 与节点通信的服务。
Master Drivers
Type |
Package |
Name |
lifecycle |
canopen_master_driver |
ros2_canopen::LifecycleMasterDriver |
simple |
canopen_master_driver |
ros2_canopen::MasterDriver |
2.5.1 Services
Services |
Type |
Description |
~/read_sdo |
COReadID |
Reads an SDO object specified by Index, Subindex and Datatype of the device with the specified nodeid. (读取一个 SDO 对象,该对象由指定节点 ID 的设备的 Index、Subindex 和 Datatype 指定。) |
~/write_sdo |
COWriteID |
Writes Data to an SDO object specified by Index, Subindex and Datatype on the device with the specified nodeid. (向指定节点 ID 的设备上由 Index、Subindex 和 Datatype 指定的 SDO 对象写入数据。) |
~/set_heartbeat |
COHeartbeatID |
Sets the heartbeat of the device with the specified nodeid to the heartbeat value (ms) (将指定节点 ID 的设备心跳设置为心跳值(毫秒)) |
~/set_nmt |
CONmtID |
Sends the NMT command to the device with the specified nodeid (向指定节点 ID 的设备发送 NMT 命令) |
2.6 Proxy Driver(代理驱动程序)
代理驱动程序通过 ROS2 服务和报文转发特定设备的 CANopen 功能。
Proxy Drivers
Type |
Package |
Name |
lifecycle |
canopen_proxy_driver |
ros2_canopen::LifecycleProxyDriver |
simple |
canopen_proxy_driver |
ros2_canopen::ProxyDriver |
2.6.1 Services
Services |
Type |
Description |
~/nmt_reset_node |
Trigger |
Resets CANopen Device the Proxy Device Node manages. (重置代理设备节点管理的 CANopen 设备。) |
~/sdo_read |
CORead |
Reads an SDO object from the specified index, subindex and datatype of the remote device. (从远程设备的指定索引、子索引和数据类型中读取 SDO 对象。) |
~/sdo_write |
COWrite |
Writes data to an SDO object on the specified index, subindex and datatype of the remote device. (根据远程设备的指定索引、子索引和数据类型向 SDO 对象写入数据。) |
2.6.2 Publishers
Topic |
Type |
Description |
~/nmt_state |
String |
Publishes NMT state on change (更改时发布 NMT 状态) |
~/rpdo |
COData |
Publishes received PDO objects on reception (在接收时发布收到的 PDO 对象) |
2.6.3 Subscribers
Topic |
Type |
Description |
~/tpdo |
COData |
Writes received data to remote device if the specified object is RPDO mapped on remote device. (如果指定对象是远程设备上的 RPDO 映射,则将接收到的数据写入远程设备。) |
2.7 Cia402 驱动器
Cia402 驱动器为运动控制器实现了 CIA402 配置文件,可设置驱动器状态、运行模式并向运动控制器发送目标值。
CIA402 Drivers
Type |
Package |
Name |
lifecycle |
canopen_402_driver |
ros2_canopen::LifecycleCia402Driver |
simple |
canopen_402_driver |
ros2_canopen::Cia402Driver |
2.7.1 Services
Services |
Type |
Description |
~/nmt_reset_node |
Trigger |
Resets CANopen Device the Proxy Device Node manages. (重置代理设备节点管理的 CANopen 设备。) |
~/sdo_read |
CORead |
Reads an SDO object from the specified index, subindex and datatype of the remote device. (从远程设备的指定索引、子索引和数据类型中读取 SDO 对象。) |
~/sdo_write |
COWrite |
Writes data to an SDO object on the specified index, subindex and datatype of the remote device. (根据远程设备的指定索引、子索引和数据类型向 SDO 对象写入数据。) |
~/init |
Trigger |
Initialises motion controller including referencing (初始化运动控制器,包括参照) |
~/recover |
Trigger |
Recovers motion controller (恢复运动控制器) |
~/halt |
Trigger |
Stops motion controller (停止运动控制器) |
~/position_mode |
Trigger |
Switches to profiled position mode (切换到轮廓定位模式) |
~/velocity_mode |
Trigger |
Switches to profiled velocity mode (切换到速度曲线模式) |
~/torque_mode |
Trigger |
Switches to profiled torque mode (切换到曲线扭矩模式) |
~/cyclic_position_mode |
Trigger |
Switches to cyclic position mode (切换到循环位置模式) |
~/cyclic_velocity_mode |
Trigger |
Switches to cyclic velocity mode (切换到循环速度模式) |
~/interpolated_position_mode |
Trigger |
Switches to interpolated position mode, only linear mode with fixed time is supported (切换到内插位置模式,仅支持固定时间的线性模式) |
~/target |
CODouble |
Sets the target value. Only accepted when an operation mode is set. (设置目标值。仅在设置操作模式时接受。) |
2.7.2 Publishers
Publishers |
Type |
Description |
~/joint_states |
sensor_msgs/msg/JointState |
Joint states of the drive (驱动器的关节状态) |
~/nmt_state |
String |
Publishes NMT state on change |
~/rpdo |
COData |
Publishes received PDO objects on reception |
2.7.3 Subscribers
Topic |
Type |
Description |
~/target |
COTargetDouble |
Sets target value. |
~/tpdo |
COData |
Writes received data to remote device if the specified object is RPDO mapped on remote device. |
2.7.4 总线配置参数
可用于此驱动程序 bus.yml 的附加参数。
Parameter |
Type |
Description |
polling |
bool |
Enables polling of the drive status. Default: true. If false, period will be used to run a ros2 timer as update loop. If true, the update loop will be triggered by the sync signal and directly executed in the canopen realtime loop. This requires all data processed in the update loop to be PDO, otherwise the loop will get stuck. This can speed reduce processor load significantly though. (启用驱动器状态轮询。默认值:true。如果为假,将使用周期运行 ros2 定时器作为更新循环。如果为 true,更新循环将由同步信号触发,并直接在 canopen 实时循环中执行。这就要求更新循环中处理的所有数据都必须是 PDO,否则循环就会卡住。不过这可以大大降低处理器负载。) |
period |
Milliseconds |
Refresh period for 402 state machine. Should be similar to sync period of master. (402 状态机的刷新周期。应类似于主站的同步周期。) |
switching_state |
see below |
The state to switch the operation mode in. (切换运行模式的状态。) |
scale_pos_to_dev |
double |
Scaling factor to convert from SI units to device units for position. (缩放因子,用于将位置单位从国际单位制转换为设备单位。) |
scale_vel_to_dev |
double |
Scaling factor to convert from SI units to device units for velocity. (缩放因子,用于将速度单位从 SI 单位转换为设备单位。) |
scale_pos_from_dev |
double |
Scaling factor to convert from device units to SI units for position. (缩放因子,用于将设备单位转换为位置的 SI 单位。) |
scale_vel_from_dev |
double |
Scaling factor to convert from device units to SI units for velocity. (缩放因子,用于将速度单位从设备单位转换为 SI 单位。) |
position_mode |
int |
The drives operation mode to use for the position interface (位置接口使用的驱动器运行模式) |
velocity_mode |
int |
The drives operation mode to use for the velocity interface (速度接口使用的驱动器运行模式) |
torque_mode |
int |
The drives operation mode to use for the torque interface (扭矩接口使用的驱动器运行模式) |
ROS2 CANopen 使用教程(三)+https://developer.aliyun.com/article/1585397