User Tools

Site Tools


ece4560:piktul:05resratepos

Piktul: Resolved Rate Position Movement


This module explores trajectory generation using the Jacobian. The objective here is to create a trajectory for the arm to follow, at only the position level. As the piktul manipulator space has equal dimension to the $R^3$ output position space, tracking a Euclidean position is feasible. It is possible to specify the 3D position as a function of time and get it to follow the trajectory, presuming that the trajectory is within the reachable workspace (for position).

Create a resolved rate trajectory generation member function that will do so for the piktul. Call the function genPositionTrajectory where it is assumed that some kind of position function of time and linear velocity function of time is given in a structure built with traj.position, traj.velocity, and traj.tspan fields. The output of the function should be a set of joint angles versus time that will move the arm to follow the specified trajectories. It can be in the output format of ode45 and should be in a structure with the fields as per: jtraj.alpha and jtraj.time.

Furthermore, write a function called followJointTrajectory that takes in a structure whose fields are alpha and time much like the output of genPositionTrajectory. The function will then command the arm to follow the specified trajectory. Doing this should be like a combination of the arm display as a movie code plus the joint angle command code for the piktul from earlier homeworks. You should also write a piktul member function called posJacobian that computes the linear velocity of the end effector (in world coordinates, not body coordinates) as a function of the \alpha coordinates. For completeness, you should include all $\alpha$ coordinates in it (the last two will just have zero columns since they don't contribute to linear movement).

The Member Functions

To make the narrative clearer, the following functions should be written:

  function alphaTraj = genPositionTrajectory(ptraj, tspan, alpha0)
  end
  
  function followJointTrajectory(jtraj, tspan, nsteps)
  end
  
  function mJ = posJacobian(alpha)
  end

Since the genPositionTrajectory function will have to numerically integrate using ode45 or a similar function, a resolved rate differential equation function will be needed to:

  function alphaDot = posODE(t, alpha)
  end

This can be a hidden function within the genPositionTrajectory member function or it can be a protected member function (the easiest would be to make it a public member function). It is the main part that has the resolved rate equations. Code stubs to insert into the piktul class can be found here: stubs. The code stubs have posODE as a hidden function within a function. The documentation of the code stub provides additional clues as to how to code the entire learning module up.

Overall, try to have functionality or code that seems inherent to the piktul actually reside in the piktul class. Some can be outside of it. I leave this as a judgement call, but definitely you should be considering what functionality should actually be implemented within the class and how it supports abstraction/encapsulation as per good coding design.

Playing Back as a Movie

Suppose you'd like to test it out without actually using the piktul. You can always use the piktul_display function to test out the code. If you can get the resolved rate code working to generate the joint angles versus time, then using piktul_display in a loop will display it as a movie in a Matlab figure. The easiest would be to write a modified version of the followJointTrajectory function called displayJointTrajectory

  function displayJointTrajectory(jtraj, tspan, nsteps)
  end

that uses the function piktul_display instead of setArm. Doing so will visualize the arm instead of commanding the arm. Remember to include the drawnow command at the end of the loop to force the figure to refresh.

Playing Back as a Command Sequence

For this version, you will have to actually use the optional time argument to setArm which is the time duration of the movement. Whatever time step you use in the for loop to move the arm, you will have to send a time duration that is 10\% longer, then pause for the actual duration before resuming the next loop iteration. The reason being that the little controller board actually implements spline smoothing to go from one joint angle to another, so if you specify the actual time, it will do the whole start and stop thing. If you specify a time that is a little bit longer, then it won't have yet stopped before moving the the next command. You must send an argument, otherwise it will use the default argument of 4 seconds, which you will not like and will not look good.

Radians versus Degrees

Be careful about the whole radians versus degrees thing. The piktul inputs are in degrees, so you'll probably need to use Matlab's cosd and sind functions, which take the angular arguments in degrees. Also, the angular velocities will have to be scaled by $180/\pi$ to convert them to degrees since the pseudo-inverse of the Jacobian will give results that are sensible in radians per second (not degrees per second). Within the position Jacobian function, the conversion to degrees for the output should already be done.

Creating the Position Trajectory

To make a constant function to pass as an argument in a trajectory structure, here is a simple example:

> posTraj.position = @(t) 2 + 5*t;
> posTraj.velocity = @(t) 5;

Your version will have to be vector valued with the correct values.


Back Main

ece4560/piktul/05resratepos.txt · Last modified: 2023/03/06 10:31 by 127.0.0.1