跳至主要内容

Advantech ROS2 資料格式

ROS 2 節點的訊息定義位於 include/adv_msgs 資料夾中:

  • .msg:用於 Topic 發佈/訂閱的資料結構
  • .action:用於可寫入感測器的設定流程

訊息定義

AdvSensor.msg 用來描述研華裝置所提供的硬體感測資料,欄位如下:

# 研華硬體感測資料
string sensor # 感測器名稱
string type # 資料型別:"v"、"bv"、"sv"
bool bv # 布林值
float64 v # 數值
string sv # 字串值
uint64 ts # 時間戳

Action 定義

AdvSensorSet.action 透過 Request/Response/Feedback 形式處理感測器設定。

Action TypeAction nameAction File
adv_msgs/action/AdvSensorSetadv_sensor_setAdvSensorSet.action
# This is a request/response/feedback that holds a detail hardware sensor data that Advantech device/board provided.
#
string cmd # Request command of set sensor value
string sensor # Sensor name of set request
string type # Sensor type: "v", "bv" or "sv"
bool bv # Boolean type of sensor value
float64 v # Number type of sensor value
string sv # String type of sensor value
---
int16 code # 受理:100,若 >100 表示失敗
---
int16 status # Status feedback of set sensor request
string sensor # Sensor name feedback of set request
string info # Information feedback of set request
uint64 ts # Timestamp of sensor value

環境設定

  1. 設定 ROS 2 環境變數:
    source /opt/ros/${ROS_DISTRO}/setup.bash
  2. 載入 Advantech 訊息定義:
    source /usr/local/Advantech/ros/${ROS_DISTRO}/include/edge-converter-ros2/adv_msgs/install/local_setup.bash