RoArm-M3-S Step Recording and Reproduction

From Waveshare Wiki
Jump to: navigation, search

Step Recording and Reproduction

You can achieve recording and reproduction of steps for the robotic arm by configuring mission files with the .mission format stored in the ESP32 Flash file system. In the mission file, you can store various JSON commands to enable batch recording and reproduction of JSON commands.

The JSON commands in this chapter are designed to operate mission files stored in the ESP32 FLASH, including creating new mission files, reading file content, editing mission file content, etc. It enables multifunctional automation operations for the robotic arm.

Note: The distinction between this chapter and RoArm-M3-S_FLASHA file system operations is that this chapter is exclusively used for operating mission files, while FLASH file system operations can be applied to all files.


Create Mission File

{"T":220,"name":"mission_a","intro":"test mission created in flash."}
  • 220: indicates this command is CMD_CREATE_MISSION for creating a mission file.
  • name: The name of the mission file to be created.
  • intro: The brief introduction about the mission file.

Note: The operation on the related mission file is mostly based on the function package of the FLASH file system. Therefore, the file name entered in this section does not need to be additionally named with the ".mission" file suffix.


Read Mission File

{"T":221,"name":"mission_a"}
  • 221: This command is CMD_MISSION_CONTENT for reading the specific content of the mission file.
  • name: The name of the mission file to be read.

The mission file read is mission_a.mission, and the return value is shown below:

{"T":221,"name":"mission_a"}

---=== File Content ===---
reading file: [mission_a] starts:

{"name":"mission_a","intro":"test mission created in flash."}
[StepNum: 1 ] - {"T":104,"x":235,"y":0,"z":234,"t":3.14,"spd":0.25}
[StepNum: 2 ] - {"T":104,"x":104.3172406,"y":-112.6415887,"z":65.13450799,"t":0,"r":0,"g":3.14,"spd":0.25}
[StepNum: 3 ] - {"T":114,"led":155}
[StepNum: 4 ] - {"T":104,"x":-163.7763876,"y":-138.2353466,"z":105.0922663,"t":0,"r":0,"g":3.14,"spd":0.5}
[StepNum: 5 ] - {"T":114,"led":0}
[StepNum: 6 ] - {"T":114,"led":255}
[StepNum: 7 ] - {"T":104,"x":156.428798,"y":40.20501586,"z":76.68339473,"t":0,"r":0,"g":3.14,"spd":0.25}
[StepNum: 8 ] - {"T":111,"cmd":3000}
[StepNum: 9 ] - {"T":114,"led":0}
^^^ ^^^ ^^^ reading file: mission_a.mission ends. ^^^ ^^^ ^^^

Note: The content of the first line in the mission file is the name and the brief introduction of the mission file. The first JSON command to be executed starts from the second line, and the above content read will be labeled out the serial number of each step.


The content of the actual mission file is shown below:

{"name":"mission_a","intro":"test mission created in flash."}
{"T":104,"x":235,"y":0,"z":234,"t":3.14,"spd":0.25}
{"T":104,"x":104.3172406,"y":-112.6415887,"z":65.13450799,"t":0,"r":0,"g":3.14,"spd":0.25}
{"T":114,"led":155}
{"T":104,"x":-163.7763876,"y":-138.2353466,"z":105.0922663,"t":0,"r":0,"g":3.14,"spd":0.5}
{"T":114,"led":0}
{"T":114,"led":255}
{"T":104,"x":156.428798,"y":40.20501586,"z":76.68339473,"t":0,"r":0,"g":3.14,"spd":0.25}
{"T":111,"cmd":3000}
{"T":114,"led":0}


Edit Mission File

Add New JSON Command at End of Mission File

{"T":222,"name":"mission_a","step":"{\"T\":104,\"x\":235,\"y\":0,\"z\":234,\"t\":3.14,\"r\":0,\"g\":3.14,\"spd\":0.25}"}
  • 222: This command is CMD_APPEND_STEP_JSON for adding new JSON Command directly at the end of the specified mission file.
  • name: The name of the mission file to be edited.
  • step: The new JSON command to be added. The above example adds the command {"T":104,"x":235,"y":0,"z":234,"t":3.14,"r":0,"g":3.14,"spd":0.25}. Note that in the new JSON command added, you need to add the "\" backslash symbol in front of each " quotation mark. Please refer to the above example for the specific format.

Entering this command outputs the original content of the mission file and the contents of the new file with the addition of the JSON command.


Add New JSON Command to Move to Current Position at End of File

{"T":223,"name":"mission_a","spd":0.25}
  • 223: This command is CMD_APPEND_STEP_FB. Using this command, the robotic arm will set its current position as the target position, generate a JSON command to move to the current position and add this command to the end of the mission file.
  • name: The name of the mission file to be edited.
  • spd: The speed for the robotic arm moving to the target position.

After inputting this command, the robotic arm will output the current position, and the original content of the mission file and the content of the new file with the addition of the JSON command.


Add New Delay Command at End of Mission File

{"T":224,"name":"mission_a","delay":3000}
  • 224: This command is CMD_APPEND_DELAY for delaying the steps of the mission file.
  • name: The name of the mission file to be edited.
  • delay: Set the delay time in ms.

After inputting this command, a new delay command will be added at the end of the mission file.


Insert New JSON Command in Mission File

{"T":225,"name":"mission_a","stepNum":3,"step":"{\"T\":114,\"led\":255}"}
  • 225: This command is CMD_INSERT_STEP_JSON, which means inserting the new JSON command at the specified step in the mission file.
  • name: The name of the mission file to be edited.
  • stepNum: The serial number of specified step. For example, by setting stepNum as 3, the new command will be inserted at step 3, and executed at step 3.
  • step: The new JSON command to be inserted. The above example adds the command {"T":114,"led":255}. Note that in the new JSON command added, you need to add the "\" backslash symbol in front of each " quotation mark. Please refer to the above example for the specific format.

Note: In this command and the following commands, the given stepNum value is the serial number of the step where the JSON command to be executed rather than the serial number of the line. That is, if the given stepNum value is 3, then in the mission file, the JSON command will be executed in the 3rd step, but it is displayed as the 4th line.


Insert JSON Command to Move to Current Position in File

{"T":226,"name":"mission_a","stepNum":3,"spd":0.25}
  • 226: This command is CMD_INSERT_STEP_FB. Using this command, the robotic arm will set its current position as the target position, generate a JSON command to move to the current position and insert this command into the mission file.
  • name: The name of the mission file to be edited.
  • stepNum: The serial number of specified step. For example, by setting stepNum as 3, the new JSON command will be inserted at step 3, and executed at step 3.
  • spd: The speed for the robotic arm moving to the target position.


Insert New Delay Command in Mission File

{"T":227,"name":"mission_a","stepNum":3,"spd":3000}
  • 227: This command is CMD_INSERT_DELAY, which means inserting the new delay command at the specified step in the mission file.
  • name: The name of the mission file to be edited.
  • stepNum: The serial number of specified step. For example, by setting stepNum as 3, the new JSON command will be inserted at step 3, and the newly inserted delay command will be executed as step 3.
  • spd: Set delay time in ms.


Replace a Command at Specified Step in Mission File

{"T":228,"name":"mission_a","stepNum":3,"step":"{\"T\":114,\"led\":255}"}
  • 228: This command is CMD_REPLACE_STEP_JSON that replaces the next line of the specified line with a newly inserted JSON command.
  • name: The name of the mission file to be edited.
  • stepNum: The serial number of specified step. For example, by setting stepNum as 3, the new JSON command will be inserted at step 3, and the newly inserted delay command will be executed as step 3.
  • step: The new JSON command to be inserted. The above example adds the command {"T":114,"led":255}. Note that in the new JSON command added, you need to add the "\" backslash symbol in front of each " quotation mark. Please refer to the above example for the specific format.


Replace a Step in Mission File with a Command to Move to Current Position

{"T":229,"name":"mission_a","stepNum":3,"spd":0.25}
  • 229: This command is CMD_REPLACE_STEP_FB. Using this command, the robotic arm will automatically set its current position as the target position to generate a new command. It will then replace the content of the specified step in the mission file with this new command. You need to set a speed for this position.
  • name: The name of the mission file to be edited.
  • stepNum: The serial number of specified step. For example, by setting stepNum as 3, the new JSON command will be inserted at step 3, and the newly inserted delay command will be executed as step 3.
  • spd: The speed for the robotic arm moving to the target position.


Replace a Command at Specified Step in Mission File with New Delay Command

{"T":230,"name":"mission_a","stepNum":3,"delay":3000}
  • 230: This command is CMD_REPLACE_DELAY for replacing the content of specified step in the specified file with a new delay command..
  • name: The name of the mission file to be edited.
  • stepNum: The serial number of specified step. For example, by setting stepNum as 3, the new delay command will be inserted at step 3, and executed at step 3.
  • delay: the delay time in ms.


Delete a Step in Mission File

{"T":231,"name":"mission_a","stepNum":3}
  • 231: This command is CMD_DELETE_STEP for deleting one step in the specified file.
  • name: The name of the mission file to be edited.
  • stepNum: The specified step to be deleted.


Execute a Command at Specified Step in Mission File

{"T":241,"name":"mission_a","stepNum":3}
  • 241: This command is CMD_MOVE_TO_STEP, which means executing the command at the specified step in the mission file.
  • name: The name of the mission file to be executed.
  • stepNum: The specified step to be executed.

Note: Whether the function blocks or not depends on whether the specific command will cause a block. If you want to execute an command that causes a block in the inverse kinematics control of the robotic arm, the function will block the process.


Playback Mission

{"T":242,"name":"mission_a","times":3}
  • 242: This command is CMD_MISSION_PLAY for playing all JSON commands in the mission file and can be executed in loops.
  • name: The name of the mission file to be played.
  • times: The number of loops to be played, is infinite when the value is -1.

During playback, the process can exit as soon as the serial port receives any new signal and the currently executing command is completed.

RoArm-M3-S Tutorial