Servo commands, while being intimidating and complex at first, are a low level way to control your robot while getting precise movements and are ideal for low level control and accuracy.
When using these servo commands with the SDK, you may notice a lot of variables, some of which you don't understand or care about. You can actually ignore these for most cases and only give the necessary arguments. A minimal example of a single ServoJ call can look like this:
robot.ServoJ(joint_pos, epos, vel=20)
Where joint_pos is just a target joint position formatted as an array. As long as the target joint values are all within 1mm of the current joint values, it will make a successful command.
The following are requirements for Servo commands to work using the Python SDK:
ServoCart():
1) Description position (target position represented by a 6 value array representing 3D coordinates).
2) Extended axis position (epos)
3) Velocity.
ServoJ():
1) Description position
2) Velocity
3) Acceleration.
Below are some of the frequently asked questions on how to make these work as well as a couple of small examples.
Q: Why do my ServoCart()/ServoJ() commands look jerky?
A: Jerky Servo commands are often due to improper command time or command frequency
These commands cannot be made at a frequency outside of 60hz - 1000 hz (1ms - 16ms between each command).
Command time is not needed for either command to run and as long as there is a 1-16ms sleep after each command call, it will work. Below are examples of each.
ServoJ loop example:
epos = [0.0, 0.0, 0.0, 0.0]
er, joint_pos = robot.GetActualJointPosDegree()
for i in range(70):
robot.ServoJ(joint_pos, epos, vel=20)
joint_pos[0] -= 0.5
time.sleep(0.008)
EXAMPLE USING SERVO CART TO PROBE A SURFACE WITH A FORCE SENSOR:
while(True):
force = robot.FT_GetForceTorqueRCS()[1]
fz = force[2]
if(abs(fz) > 1):
break
robot.ServoCart(1, [0,0, -0.1, 0, 0, 0], vel=20, acc=20)
time.sleep(0.008)
Q: When running my Servo commands, I get "joint command speed command error". What does this mean and how do I fix it?
A:
The command speed joint error occurs when you send a ServoCart or ServoJ command with target values that are too large per step. For example, ServoJ calls need a maximum change of 1 deg per joint per call. So for example, if you send a ServoJ with more than a 1 degree difference on any joint, it will return that error.