inorbit-ai / ros_amr_interop

BSD 3-Clause "New" or "Revised" License
80 stars 27 forks source link

Add schema checking for all sent messages #15

Closed leandropineda closed 3 years ago

leandropineda commented 3 years ago

Changes

Demo

Identity Report

{
  "uuid": "foobar",
  "timestamp": "2021-06-30T09:36:44-03:00",
  "manufacturerName": "Spoonlift",
  "robotModel": "spoony1.0",
  "robotSerialNumber": "2172837",
  "baseRobotEnvelope": {
    "x": 2,
    "y": 1,
    "z": 3
  },
  "maxSpeed": 2.5,
  "maxRunTime": 8,
  "emergencyContactInformation": "555-5555",
  "chargerType": "24V plus",
  "supportVendorName": "We-B-Robots",
  "supportVendorContactInformation": "support@we-b-robots.com",
  "productDocumentation": "https://spoon.lift/support/docs/spoony1.0",
  "thumbnailImage": "https://spoon.lift/media/spoony1.0.png",
  "cargoType": "Anything solid or liquid",
  "cargoMaxVolume": {
    "x": 2,
    "y": 2,
    "z": 1
  },
  "cargoMaxWeight": "4000"
}

Status report with invalid data

$ ros2 topic pub --once /we_b_robots/mode std_msgs/String "data: foobar"
publisher: beginning loop
publishing #1: std_msgs.msg.String(data='foobar')

image

leandropineda commented 3 years ago

I was able to capture the unexpected rosFrameToPlanarDatumUUID property on the Identity report message by implementing schema checking before sending each message.

[ERROR] [1624993135.448303037] [MassRoboticsAMRInteropNode]: Invalid schema for '<class 'massrobotics_amr_sender.messages.IdentityReport'>' message. The error reported is: 'Additional properties are not allowed ('rosFrameToPlanarDatumUUID' was unexpected)'. Ignoring message.

This also captured other minor issues on Status report messages

[ERROR] [1624993136.693667449] [MassRoboticsAMRInteropNode]: Invalid schema for '<class 'massrobotics_amr_sender.messages.StatusReport'>' message. The error reported is: ''foo' is not one of ['navigating', 'idle', 'disabled', 'offline', 'charging', 'waiting', 'loadingUnloading', 'manualOveride']'. Ignoring message.
miguelgarcia commented 3 years ago

LGTM @leandropineda great work and great PR description!