Use servo_move() for Tracking Motion
servo_move(SOCKETFD socketFd, ServoMovePara servoMove) can receive a set of waypoints, then perform smoothing based on timeStamp and send them to the servo for motion.
ServoMovePara struct description:
cpp
struct ServoMovePara {
///< Transfer parameters
int robotNum; ///< Which robot to control
bool clearBuffer; ///< Whether to clear previously sent waypoints that have not started interpolation calculation
int targetMode; ///< 0-Independent point 1-Continuous trajectory
int sendMode; ///< 0-Transmit all trajectory waypoints at once 1-Transmit partial waypoints at once
int runMode; ///< 0-Move after receiving all 1-Move while receiving
int sum; ///< Total number of transmissions
int count; ///< Current transmission number
///< Motion parameters
int coord; ///< 0-Joint 1-Cartesian
int size; ///< Number of waypoints in this transmission
std::vector<std::vector<double>> pos; ///< 2D array, first dimension is number of waypoints in this transmission, second dimension length is 7, each joint angle or Cartesian coordinate
std::vector<std::vector<double>> axisvel; ///< 2D array, first dimension is number of waypoints in this transmission, second dimension length is 7, velocity of each axis
std::vector<std::vector<double>> axisacc; ///< 2D array, first dimension is number of waypoints in this transmission, second dimension length is 7, acceleration of each axis
std::vector<double> timeStamp; ///< Length is number of waypoints in this transmission, time to reach each waypoint, unit ms
};Example: Using continuous waypoint trajectory, transmitting all trajectory waypoints at once
Note: When using the servo_move interface, you need to run a job file containing the external point command in run mode (the external point command receives data transmitted by servo_move)
py
def test_7000(socketFd):
print('Starting test 7000...')
socket_7000 = aa.connect_robot("192.168.1.13", "7000")
servomovepara = aa.ServoMovePara()
pos = aa.VectorVectorDouble()
time = aa.VectorDouble()
time_pos = [50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550] #Timestamp for reaching target waypoints
for value in time_pos:
time.append(value)
axis_pos = [[0,0,0,0,0,0,0],
[0,0,0,0,0,1,0],
[0,0,0,0,0,2,0],
[0,0,0,0,0,3,0],
[0,0,0,0,0,4,0],
[0,0,0,0,0,5,0],
[0,0,0,0,0,6,0],
[0,0,0,0,0,7,0],
[0,0,0,0,0,8,0],
[0,0,0,0,0,9,0],
[0,0,0,0,0,10,0]] #Target waypoints
for value in axis_pos:
pos.append(value)
for k in range(11):
servomovepara.pos = pos
for j in range(11):
servomovepara.timeStamp = time
servomovepara.runMode = 0 #Default fixed transmission 0
servomovepara.clearBuffer = True #When using continuous motion, clearBuffer, targetMode, sendMode, runMode must be assigned according to this fixed format
servomovepara.targetMode = 1 #Continuous trajectory
servomovepara.coord = 0 # 0-Joint coordinates 1-Cartesian coordinates
servomovepara.size = 11 #Length of target waypoints to transmit
result = aa.servo_move(socket_7000, servomovepara)
print("return " , result)