Competition APIs - osrf/mbzirc GitHub Wiki

The simulator offers a number of topics to retrieve information and feedback on the competition run, such as run time remaining, current phase, and current score. It also provides 2 important endpoints needed for the inspection and intervention phases of the competition: One for streaming live video from the vehicles back to the operator, and another for report target vessels, small objects, and large objects.

ROS Topic Description Message type
/clock Current sim time rosgraph_msgs/msg/Clock
/mbzirc/run_clock Count down clock for the setup phase and also the entire run, see Phase rosgraph_msgs/msg/Clock
/mbzirc/score Current score, see Score and Time Penalties std_msgs/msg/Float32
/mbzirc/phase Current phase, see Phase std_msgs/msg/String
/<robot_name>/mbzirc/target/stream/start Endpoint to stream live video imagery to, see Transmitting video stream to operator sensor_msgs/msg/Image
/<robot_name>/mbzirc/target/stream/report Endpoint for reporting targets, see Reporting targets in video stream ros_ign_interfaces/msg/StringVec
/mbzirc/target/stream/status Status of target stream reports, see Getting video stream and target report status std_msgs/msg/String

Phase

The /mbzirc/phase phase topic provides status on the current phase of the simulation. Current phase is published to this topic at 1Hz. The phases are:

  • setup: Initial phase of the competition in which the simulator starts spawning robots in the start gate. The default time allowed for setup is 10 mins and the /mbzirc/run_clock topic outputs the time remaining in this phase.
  • started: The run officially starts once the setup time counts down to 0 or when a robot moves for more than 5 meters from its spawn location. The default time for the competition is 60 mins, and the /mbzirc/run_clock topic will now output the time remaining in this phase.
  • vessel_id_success: The target vessel has been successfully identified.
  • small_object_id_success: The small target object has been successfully identified.
  • large_object_id_success: The large target object has been successfully identified.
  • small_object_retrieve_success: The small target object has been successfully retrieved.
  • large_object_retrieve_success: The large target object has been successfully retrieved.
  • finished: Competition ended. All targets have been identified / retrieved. Simulation should now be paused.

The tasks in simulation must be completed in the following sequence:

Identify target vessel -> Identify small object -> Identify large object -> Retrieve small object -> Retrieve large object -> Move onto the next target vessel

Everytime a task is successfully completed, a different phase string should be published to the /mbzirc/phase topic. One the last last large object is retrieved (there may be up to 2 target vessels), simulation ends and the time is recorded. The total score is the completion time + time penalties.

Identifying Targets

As per rulebook, the teams should stream live video to the operator who will in turn provide a boolean true / false response to indicate if identification is successful or not. The following sections illustrate how this interaction is done in simulation.

Transmitting video stream to operator

/<robot_name>/mbzirc/target/stream/start is the endpoint for streaming live video images to. Each robot will have its namespaced topic for streaming video images. Make sure that the robot streaming the video to the base station is using its own topic. During final evaluation, each robot will will only be able to access stream topics in its namespace.

The video stream will be transmitted over the inter-robot communication channel so ensure you are sending images within a reasonable range from the base station located next to the start gate otherwise image data will start dropping. One strategy is to relay the image data to another robot in the field that is closer to the base station and let it be the one sending the live video stream, see Communications. As you can see, the robot capturing the live stream of the target can be different from the robot sending the video images to the base station. However, it is important that the frame_id in the Header field of the Image message corresponds to the robot capturing the images of the targets. The simulator will verify the image frame_id when validating targets reports.

For testing, here is an example of republishing the image data from a quadrotor camera to this API:

ros2 run image_transport republish raw --ros-args --remap in:=/quadrotor_1/slot3/optical/image_raw --remap out:=/quadrotor_1/mbzirc/target/stream/start

The above command subscribes to the images from the downward looking camera (in slot3, see UAV and USV Payload Configurations) on quadrotor_1 and republishes them to the /quadrotor_1/mbzirc/target/stream/start topic.

There is a ROS2 C++ example code showing how to subscribe to an image topic, optionally updates its frame_id message field (if it has changed due to image processing), and republishes the image data to the base station. The command achieves the same effect as using the image_transport method above.

ros2 run mbzirc_ros video_stream_publisher quadrotor_1 /quadrotor_1/slot3/image_raw quadrotor_1/sensor_3/sensor_link/camera_optical

Reporting targets in video stream

/<robot_name>/mbzirc/target/stream/report is the endpoint for reporting targets. A live video stream must be started, see Transmitting video stream to operator. Like the video stream, the target reports will also be transmitted over the inter-robot communication channel so make sure you are within a reasonable range from the base station.

This API takes a String Vector data message. The elements in the string vector are: [<target_type>, <image_x_pos>, <image_y_pos>]

  • target_type: Type of target. Valid strings are:
    • vessel: target being identified is a vessel
    • small: target being identified is a small object on the vessel
    • large: target being identified is a large object on the vessel
  • image_x_pos: X position in the 2D image. The 2D position must be specified with respect to the original resolution of the camera and not the resolution of the image stream.
  • image_y_pos: Y position in the 2D image. The 2D position must be specified with respect to the original resolution of the camera and not the resolution of the image stream.

Here is an example of reporting a target using the command line:

ros2 topic pub --once /quadrotor_1/mbzirc/target/stream/report ros_ign_interfaces/msg/StringVec '{data: ["vessel", "640", "480"]}'

The above command illustrates transmits a target report from quadrotor_1 to the base station. The message data indicates that a target vessel is currently located at [640, 480] in the image stream.

Getting video stream and target report status

To get feedback on video stream and target reports, you can subscribe to the /mbzirc/target/stream/status topic. Data are only published to this topic in response to video stream start requests and target reports. Here are the status outputs:

  • stream_started: Video stream successfully received on the /mbzirc/target/stream/start
  • stream_start_failed: Video stream received on the /mbzirc/target/stream/start but failed to validate images. It is likely that the image's frame_id field is incorrect.
  • target_reported_run_not_active: Target identification report received on the /mbzirc/target/stream/report topic but the run has not officially started yet.
  • vessel_id_success: The target vessel has been successfully identified.
  • small_object_id_success: The small target object has been successfully identified.
  • large_object_id_success: The large target object has been successfully identified.
  • vessel_id_failure: The target vessel identification was incorrect.
  • small_object_id_failure: The small target object identification was incorrect.
  • large_object_id_failure: The large target object identification was incorrect.

Score and Time Penalties

The score of a run is the combined value of elapsed time + time penalties in seconds. This value is published to the /mbzirc/score topic every second.

Here are the time penalties from the rule book that are implemented in simulation:

  • Failure to identify the target vessel
  • Failure to identify objects for intervention
  • Failure to retrieve or place objects on USV
  • Crossing the demonstration boundary area

See the Competition Tasks and Time Penalties page for a tutorial on how to test and trigger different time penalties.

Ignition Topics and Services

A note on Ignition Transport: the simulator uses a number of ignition topics and services. These are meant for use during local development and testing. These Ignition topics and services will not be available during the competition run.

⚠️ **GitHub.com Fallback** ⚠️