ros-industrial / ros2_canopen

CANopen driver framework for ROS2
https://ros-industrial.github.io/ros2_canopen/manual/rolling/
140 stars 60 forks source link

Add diagnostics msgs #109

Closed ipa-vsp closed 1 year ago

ipa-vsp commented 1 year ago

This pull request introduces the implementation of the diagnostic messages publisher for the diagnostic_msgs/msg/DiagnosticArray.msg message type. The publisher is responsible for publishing device information, including:

Reference issue: #104 Depends on: #115

In order to send the device a diagnostic message, an additional timer callback must be added. Therefore by default, the diagnostic publisher is disabled. In order to enable it, add the following to the bus.yml file.

diagnostics:
    enable: true
    period: 1000 # in milliseconds

[or]

diagnostics:
    enable: true

Todo:

ipa-vsp commented 1 year ago

Example for ros2 launch canopen_tests proxy_setup.launch.py:

$ ros2 topic echo /proxy_device_1/diagnostic
header:
  stamp:
    sec: 1684321506
    nanosec: 189701989
  frame_id: ''
status:
- level: "\0"                                             # 0: OK | 1: WARN | 2: ERROR | 3: STALE
  name: proxy_device_1
  message: 'Device is in operational state.'
  hardware_id: '2'                                   # Node ID
  values:                                                 # Key values recorder while the device is running 
  - key: Add to master
    value: OK
  - key: NMT
    value: START
  - key: EMCY
    value: 'Emergency message received. eec: 4369 er: 17 msef: 17 0 0 0 0 '
  - key: NMT
    value: START
---
ipa-vsp commented 1 year ago

Example for ros2 launch canopen_tests cia402_setup.launch.py

$ ros2 topic echo /cia402_device_1/diagnostic
header:
  stamp:
    sec: 1684486270
    nanosec: 689278892
  frame_id: ''
status:
- level: "\0"
  name: cia402_device_1
  message: Operation enabled
  hardware_id: '2'
  values:
  - key: Add to master
    value: OK
  - key: CiA402
    value: 'State transition: 2 -> 3'
  - key: CiA402
    value: 'State transition: 3 -> 4'
  - key: CiA402
    value: 'State transition: 4 -> 5'
  - key: CiA402
    value: 'Mode selected: 6'
  - key: CiA402
    value: 'No mode selected: 0'
  - key: CiA402
    value: 'Mode selected: 1'
---