Instructions for pathBuffer
1. Introduction to pathBuffer
MovePathBuffer is a high-level path management interface. By pre-planning and storing multiple compound paths, and optimizing the execution efficiency and real-time adaptability of complex trajectories, it directly calls the complete path sequence in the cache during execution, supports the efficient and continuous execution of complex trajectories, significantly reduces the real-time computational overhead, and improves the speed of motion response.
It specifies the path name, path type and cache size through pathBufferAlloc. There are three path type parameters, as follows:
toppra (time-optimal path planning) is an optimization algorithm based on dynamic constraints to generate the shortest motion trajectory, which is suitable for high-speed and high-accuracy scenarios;
cubic_spline (recorded trajectory): Generating a smooth curve by teaching the recorded path point to maintain the continuity of the trajectory, which is often used to reproduce the manual teaching action;
Joint B-spline interpolation: At least 3 path points are required, and the smooth transition of the joint space is realized through the B-spline algorithm to reduce mechanical vibration.
This Guide introduces the instructions in the use of pathBuffer. Taking the use of cubic_spline parameter by pathBuffer to execute the cache path as an example, it is similar to the teach pendant trajectory recording function and is used to play the recorded trajectory application. The following describes the use steps.
pathBuffer demo is as follows: pathbuffer_armplay.py
2. Introduction to use steps
2.1 Establish connection
Connect the RPC service, the robot arm logs in, and set the RPC request timeout.

2.2 Read file
Open and read the JSON file to obtain the waypoint (represented by joint angle) and the sampling interval time of 10 ms.


2.3 Move to prepared point
The joint moves to the first waypoint in the JSON file.

2.4 Release cache
Release the path cache, and clear the cache to ensure that the path executed each time is up to date.
mc.pathBufferFree("rec") # interface call: release path cache
2.5 Create new path cache
Create a new path point cache "rec", add it to the "rec" cache, and use pathBufferAlloc to specify the type cubic_spline and size traj_sz. 
2.6. Add cache
Add the waypoint in the JSON file to the "rec" cache.

2.7 Judge validity
Time-consuming operations such as calculation and optimization will not be recalculated if the transfer parameters are the same. Judge whether the "rec" buffer is valid. If it is valid, go to the next step. Otherwise, blocking will exist all the time.
The pathBuffer needs to meet three valid conditions:
The buffer exists and the RAM has been allocated, that is, pathBufferAlloc;
The number of points transmitted to the buffer shall be less than or equal to the RAM allocated to the buffer;
One pathBufferEval shall be executed.

2.8 Execute path
Execute the cache path, blocking.

2.9 Disconnect after execution
Disconnect the RPC.
