Recording 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 initiate a record action in signal mode. 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;
}

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

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

  • action_name: The name of the record action to start;

  • preparation_duration_s: The duration to record backward from the time the request is received, in seconds. This value cannot exceed the max_preparation_duration_s configured for the action;

  • record_duration_s: The duration of the recording, in seconds. If set to 0, recording will continue indefinitely until the process stops;

Here 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 starts a record action named my_signal_record, recording 5 seconds of data backward and continuing for 10 seconds. 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":""}

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 specify the following parameter in the request package StartRecordReq:

  • action_name: The name of the record action to stop;

Here 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 stops 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 initiate a playback action in signal mode. 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 specify the following parameters in the request package StartPlaybackReq:

  • action_name: The name of the playback action to start;

  • skip_duration_s: The duration to skip, in seconds;

  • play_duration_s: The duration of playback, in seconds;

Here 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 starts a playback action named my_signal_playback, skipping 5 seconds of data and playing for 10 seconds. 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 currently running signal-mode playback action. 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 packet StopPlaybackReq:

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

Here 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 can stop the playback action named my_signal_playback. If the call is successful, the command returns the following value:

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 restricted by recording mode, and 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 packet UpdateMetadataReq:

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

  • kv_pairs: A map containing key-value pairs of metadata 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 the key is duplicated, only the last updated value will be retained.

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

      • If the parsing succeeds, the value string is considered valid YAML data. The parsed YAML structure (which could be a Map, List, or simple scalar values like strings, numbers, booleans, etc.) will be stored as the metadata item. This means you can pass in a serialized complex YAML structure string, which will be stored as the corresponding structured data.

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

Here 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 can update the metadata of the record action named my_signal_record. If the call is successful, the command returns the following value:

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

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