The inverse kinematics of a robotic arm tells us the required joint angles for a given end effector pose (XYZ position and orientation). Given that there are 7 degrees of freedom on the Sawyer Robot, there are multiple solutions that each joint can be at given a pose. Typically we would use a IK solver that is available, such as a rosservice available through the Sawyer SDK.
In the other direction, the forward kinematics of a robotic arm can tell us the end-effector pose given the angles of each joint. This is computed by computing the twists of each joint in the zero configuration of the robot. We followed the algorithm on the right to calculate the inverse kinematics.
Source: UC Berkeley, EECS106A, Lab 3: Forward Kinematics
This approach uses the readily available endpoint pose and velocity through the Limb SDK of the Sawyer arm to use the end effector as a state. It would change by the end-effector velocity, and we would forecast the dynamics in our horizon by calculating the spatial manipulator Jacobian.
Source: Richard Murray, Zexiang Li and S. Shankar Sastry's A Mathematical Introduction to Robotic Manipulation
Limb SDK
Top Right Figure: Data vs. Forecast with Provided Endpoint Velocity
Bottom Right Figure: Data vs. Forecast with Calculated Spatial Jacobian
With this approach, we would define our own trajectory in 3D and use the inverse kinematics solver to computer the joint angles required for each point. The output is getting a series of reference joint angles for our MPC to follow.
With this approach, we use the same dynamic model for the joint states. However, our cost function will be in terms of the forward kinematics of the joint angles.
Enforcing self collision avoidance as a function of the joint angles is difficult as there may not be a convex region to confine them in. Although there may be a way to utilize built-in tools, the Pyomo variables were not able to be used in external libraties. In this case, we decided to move the joint angles ourselves until we saw a collision warning in MoveIt and defined our own set of joint states to ensure collisions would never happen.
Our robot gives us a quaternion that starts close to [0, -1, 0, 0]. This results in an end-effector, or in other words our gripper, that is pointed downwards. We found the resulting rotation matrix to match this quaternion as can be seen on the screen. We then impose constraints on this rotation matrix because that is what we can control. Like with the state and input constraints, the actual position is close to the desired, however, it isn’t perfect.
Model Verification: Finding a dynamic model that provides us with an accurate forecast was fairly difficult for this project. There was limited documentation for the Sawyer arm. Another method we saw in E. Guechi, S. Bouzoualegh, Y. Zennir, and S. Blazic MPC Control and LQ Optimal Control of A Two-Link Robot Arm: A Comparative Study is to derive the Lagrangian model of the Sawyer robot using its gravity, inertial, and Coriolis matrices. This is another method we would like to try if given more time.
Joint Angle Restrictions: Since we experimentally found joint angles that would prevent self-collisions ourselves, this made them very restrictive and is not representative of all possible joint angles.
Forward Kinematics: Since numpy cannot operate on Pyomo variables, we had to rewrite much of the standard matrix-vector operation ourselves using list comprehensions.
Although we saw that the constrained finite-time optimal control (CFTOC) problem was able to be solved, it took longer as we added more constraints, with the longest being 3.5 seconds for the orientation constraints. We believe we may be able to provide a warm start to the ipopt solver by linearly interpolating joint angles between the current and desired end effector position using IK.
A suggestion given to us is to possibly train a neural network to detect joint collisions. This may give us more joint angle possibilities while keeping computation fast.
We did not end up using terminal constraints in this project, but we would like to use incorporate invariant sets to guarantee recursive feasibility. This was difficult because we were unsure how to compute the maximal invariant set without a standard Q matrix that is the same size as our A matrix.
For possible extensions, we would also like the end effector to avoid obstacles. The simplest case is to avoid spheres and ensure that the end effector remains at least a radius away from its center.