Record and Playback Plugin

RecordPlaybackService

In record_playback.proto, a RecordPlaybackService is defined, providing the following interfaces:

  • StartRecord: Start recording;

  • StopRecord: Stop recording;

  • StartPlayback: Start playback;

  • StopPlayback: Stop playback;

  • UpdateMetadata: Update the ext_attributes field of the recording package;

StartRecord

The StartRecord interface is used to start a signal-mode record action. Its interface definition is as follows:

message StartRecordReq {
  string action_name = 1;
  uint32 preparation_duration_s = 2;
  uint32 record_duration_s = 3;  // record forever if value is 0
}

message CommonRsp {
  uint32 code = 1;
  string msg = 2;
}

message StartRecordRsp {
  CommonRsp common_rsp = 1;
  string filefolder = 2;
}

service RecordPlaybackService {
  // ...
  rpc StartRecord(StartRecordReq) returns (StartRecordRsp);
  // ...
}

Developers can fill in the following parameters in the request package StartRecordReq:

  • action_name: The name of the record action to be started;

  • preparation_duration_s: The time to look back and record when the request is received, in seconds. The maximum cannot exceed the max_preparation_duration_s value configured in the action;

  • record_duration_s: The duration of the recording, in seconds. If it is 0, it will keep recording until the process stops;

Below is an example of calling this interface via HTTP using the curl tool, based on the http RPC backend in net_plugin:

data='{
    "action_name": "my_signal_record",
    "preparation_duration_s": 5,
    "record_duration_s": 10
}'

curl -i \
    -H 'content-type:application/json' \
    -X POST 'http://127.0.0.1:50080/rpc/aimrt.protocols.record_playback_plugin.RecordPlaybackService/StartRecord' \
    -d "$data"

This example command can start a record action named my_signal_record, looking back and recording 5s of data, with a recording duration of 10s. If the call is successful, the command returns the following, where filefolder indicates the folder path where the data is saved:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{
  "common_rsp": {
    "code": 0,
    "msg": ""
  },
  "filefolder": "/path/to/record/aimrtbag_YYYYMMDD_HHMMSS"
}

StopRecord

The StopRecord interface is used to stop a running signal-mode record action. Its interface definition is as follows:

message StopRecordReq {
  string action_name = 1;
}

message CommonRsp {
  uint32 code = 1;
  string msg = 2;
}

service RecordPlaybackService {
  // ...
  rpc StopRecord(StopRecordReq) returns (CommonRsp);
  // ...
}

Developers can fill in the following parameters in the request package StartRecordReq:

  • action_name: The name of the record action to be stopped;

Below is an example of calling this interface via HTTP using the curl tool, based on the http RPC backend in net_plugin:

data='{
    "action_name": "my_signal_record"
}'

curl -i \
    -H 'content-type:application/json' \
    -X POST 'http://127.0.0.1:50080/rpc/aimrt.protocols.record_playback_plugin.RecordPlaybackService/StopRecord' \
    -d "$data"

This example command can stop the record action named my_signal_record. If the call is successful, the command returns the following:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{"code":0,"msg":""}

StartPlayback

The StartPlayback interface is used to start a signal-mode playback action. Its interface definition is as follows:

message StartPlaybackReq {
  string action_name = 1;
  uint32 skip_duration_s = 2;
  uint32 play_duration_s = 3;  // playback to end if value is 0
}

message CommonRsp {
  uint32 code = 1;
  string msg = 2;
}

service RecordPlaybackService {
  // ...
  rpc StartPlayback(StartPlaybackReq) returns (CommonRsp);
  // ...
}

Developers can fill in the following parameters in the request package StartPlaybackReq:

  • action_name: The name of the playback action to be started;

  • skip_duration_s: The time to skip, in seconds;

  • play_duration_s: The duration of the playback, in seconds;

Below is an example of calling this interface via HTTP using the curl tool, based on the http RPC backend in net_plugin:

data='{
    "action_name": "my_signal_playback",
    "skip_duration_s": 5,
    "play_duration_s": 10
}'

curl -i \
    -H 'content-type:application/json' \
    -X POST 'http://127.0.0.1:50080/rpc/aimrt.protocols.record_playback_plugin.RecordPlaybackService/StartPlayback' \
    -d "$data"

This example command can start a playback action named my_signal_playback, skipping 5s of data, with a playback duration of 10s. If the call is successful, the command returns the following:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{"code":0,"msg":""}

StopPlayback

The StopPlayback interface is used to stop a running playback action in signal mode. Its interface definition is as follows:

message StopPlaybackReq {
  string action_name = 1;
}

message CommonRsp {
  uint32 code = 1;
  string msg = 2;
}

service RecordPlaybackService {
  // ...
  rpc StopPlayback(StopPlaybackReq) returns (CommonRsp);
  // ...
}

Developers can fill in the following parameters in the request package StopPlaybackReq:

  • action_name: the name of the playback action to be stopped;

Below is an example of calling this interface via HTTP using the curl tool, based on the http RPC backend in net_plugin:

data='{
    "action_name": "my_signal_playback"
}'

curl -i \
    -H 'content-type:application/json' \
    -X POST 'http://127.0.0.1:50080/rpc/aimrt.protocols.record_playback_plugin.RecordPlaybackService/StopPlayback' \
    -d "$data"

This example command stops the playback action named my_signal_playback. If the call succeeds, the command returns the following:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{"code":0,"msg":""}

UpdateMetadata

The UpdateMetadata interface is used to update custom metadata (extra attributes) associated with a specified record action. This interface is not limited to any recording mode. Its interface definition is as follows:

message UpdateMetadataReq {
  string action_name = 1;
  map<string, string> kv_pairs = 2;
}

service RecordPlaybackService {
  // ...
  rpc UpdateMetadata(UpdateMetadataReq) returns (CommonRsp);
  // ...
}

Developers can fill in the following parameters in the request package UpdateMetadataReq:

  • action_name: the name of the record action to be updated;

  • kv_pairs: a map containing the metadata key-value pairs to be updated or added.

    • key: the name of the metadata. Note: when the key is an empty string, the key-value pair will be ignored; when keys are duplicated, only the last updated value is kept.

    • value: the value of the metadata. The server-side implementation of this interface will attempt to parse each value string as YAML:

      • If parsing succeeds, the value string is treated as valid YAML data. The parsed YAML structure (which may be a Map, List, or simple scalar such as string, number, boolean, etc.) will be stored as the metadata item. This means you can pass a serialized complex YAML structure string, and it will be stored as the corresponding structured data.

      • If parsing fails, the system will catch the parsing exception and store the original value string itself as a plain text string as the metadata item.

Below is an example of calling this interface via HTTP using the curl tool, based on the http RPC backend in net_plugin:

data='{
    "action_name": "my_signal_record",
    "kv_pairs":{ "key": "timestamp: '2023-10-25T12:34:56.789Z'\nposition:\n  x: 1.2\n  y: 3.4\n  z: 0.0\norientation:\n  roll: 0.0\n  pitch: 0.0\n  yaw: 1.57\nsensor_temperature: 25.5C\nsensor_distance_front: 1.8m\nbattery_voltage: 12.4V\nbattery_level: 85%\nmotor_speed_left: 100rpm\nmotor_speed_right: 102rpm\nstatus: active\nmode: autonomous\nlog_message: Navigation started."}
}'
curl -i \
    -H 'content-type:application/json' \
    -X POST 'http://127.0.0.1:50080/rpc/aimrt.protocols.record_playback_plugin.RecordPlaybackService/UpdateMetadata' \
    -d "$data"

This example command updates the metadata of the record action named my_signal_record. If the call succeeds, the command returns the following:

HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 19

{"code":0,"msg":""}