Continuing on with our example, we can start to add forces to the robot arm. All forces, either constant forces, linear springs, or nonlinear forces, are modeled as energy storage modes. The Add_ES_Mode method can be used to create energy storage modes that are either constant, quadratic potential functions, or arbitrary symbolic functions. Here we will start with a constant force:
% Define an energy storage mode corresponding to force at the endpoint of % the manipulator. r.Add_ES_Mode('tip', 'const_force', Link2_Dist); r.ES_Mode('tip').SetForce([1; -1; 0]);
The generalized forces on the object, found by taking the gradient of each energy storage mode with respect to the generalized coordinates, are computed by the Force method, which takes in as an argument the configuration of the robot,
% For the moment, we'll assume that the manipulator is actuated serially, % at each joint. Thus, the actuator forces corresponding to this coordinate % system are the generalized forces. Here we calculate it for the % configuration q1 used above. f_gen = r.Force(q1);
There is also a method to minimize energy, starting from some initial configuration. For any force at the tip, this will correspond to a straightened configuration aligned with the force vector,
% We can also find the minimum energy configuration corresponding to this % force (should be extended at -45 degrees, straight out) q_min = r.MinimizeEnergy(q1);
Currently the MinimizeEnergy method uses Matlab's fmincon function to find an energy minimum. There is planned support for non-conservative energy storage modes in the future. These modes will not have a closed form potential function, and therefore energy minimization will fall back to a more localized energy minimization method.
The script for this tutorial can be downloaded here: tutorial2.txt