MATLAB File Help: HebiTrajectoryGenerator
HebiTrajectoryGenerator
  HebiTrajectoryGenerator provides support for creating trajectories
 
  For series elastic actuators such as the X-series modules it is
  important to command smooth trajectories to avoid oscillations
  induced by the spring element. Additionally, it helps significantly
  to not only command positions, but also velocities and if possible
  efforts (torques). 
 
    HebiTrajectoryGenerator Methods (non-blocking):
 
       newJointMove   - Creates a trajectory through joint waypoints
                        that does not make use of kinematics.
 
       newLinearMove  - Creates a trajectory through xyz waypoints
                        that uses knowledge of kinematics to travel in
                        straight lines in workspace.
 
       setMinDuration - Sets the minimum duration that gets used when
                        relying on the trajectory generator's internal
                        timing heuristic.
       getMinDuration - Returns the currently set minimum trajectory
                        duration.
 
       setSpeedFactor - Sets a scalar that adjusts the speed of all
                        trajectories. A value of 1.0 will run at full
                        speed, and smaller values proportionally
                        slow down the timing of the trajectory. This
                        applies to both the internal timing heuristic
                        as well as user supplied time vectors.
       getSpeedFactor - Returns currently set speed factor.
 
       setAlgorithm   - Allows use of legacy trajectory algorithms.
       getAlgorithm   - Returns the active trajectory algorithm.
 
    HebiTrajectoryGenerator Methods (blocking):
 
       moveJoint         - Creates and executes a joint space trajectory 
                           using newJointMove() and commands a group to 
                           execute the trajectory until it is complete.
                           This is a convenience function that will only
                           move between 2 waypoints, starting and
                           stopping at zero velocity and acceleration.
 
       moveLinear        - Creates and executes a workspace trajectory
                           using newLinearMove() and commands a group to 
                           execute the trajectory until it is complete.
                           This is a convenience function that will only
                           move between 2 waypoints, starting and
                           stopping at zero velocity and acceleration.
 
       executeTrajectory - Executes a trajectory that is generated with
                           either newJointMove or newLinearMove.  This
                           method provides more control on how the
                           trajectory is setup, allowing multiple
                           intermediate waypoints and additional
                           constraints such as user-defined waypoint
                           timing and non-zero waypoint velocities and
                           accelerations.                   
 
  Note that the following parts of the API require additional knowledge 
  about the hardware:
 
    - The internal heuristic to automatically determine an appropriate
      time vector requires knowledge of joint velocity limits
 
    - Linear movements (newLinearMove/moveLinear) require a fully 
      specified kinematic model (HebiKinematics object) for IK
 
    - executeTrajectory requires a fully specified kinematic model
      (HebiKinematics object) if gravity or acceleration compensation 
      are enabled.
 
  Execution of a trajectory using the simplified 'blocking' API
  additionally requires a HebiGroup in order to communicate with the
  actuator hardware.
 
    Example
       % Initialize with a kinematic model (3-DoF arm)
       kin = HebiKinematics();
       kin.addBody('X5-4');
       kin.addBody('X5-Link', 'ext', 0.325, 'twist', 0);
       kin.addBody('X5-1');
       kin.addBody('X5-Link', 'ext', 0.325, 'twist', 0);
       kin.addBody('X5-1');
       trajGen = HebiTrajectoryGenerator(kin);
 
       % Move between a set of waypoints using blocking calls
       numWaypoints = 20;
       positions = rand(numWaypoints, kin.getNumDoF);
       for i = 2:numWaypoints
            start = positions(i-1, :);
            finish = positions(i, :);
            trajGen.moveJoint(group, [start; finish]);
       end
 
    Example
       % Initialize without a kinematic model (e.g. delta arm, where
       % the parallel kinematics cannot use HEBIKINEMATICS )
       velocityLimit = [ -9.5 9.5
                         -9.5 9.5
                         -9.5 9.5 ];
       trajGen = HebiTrajectoryGenerator(velocityLimit);
 
       % Alternatively you can setup a 'dummy' HebiKinematics object to  
       % get the velocity limits programmatically.
       kin = HebiKinematics();
       kin.addBody('X5-1');
       kin.addBody('X5-1');
       kin.addBody('X5-1');
       velocityLimits = kin.getJointInfo().velocityLimit;
       trajGen = HebiTrajectoryGenerator(velocityLimits);
 
    Example
       % Generate a trajectory for XY velocities of a mobile base where
       % speeds are limited to 1 m/s (or whatever units you are using).
       velocityLimits = [ -1 1;
                          -1 1 ];
       trajGen = HebiTrajectoryGenerator(velocityLimits);
       positions = [ 0 0;
                    -2 1 ];
       trajectory = trajGen.newJointMove(positions);
 
       % Visualize points along the trajectory
       HebiUtils.plotTrajectory(trajectory);
 
       % Execute trajectory open-loop in position and velocity
       cmd = CommandStruct();
       t0 = tic();
       t = toc(t0);
       while t < trajectory.getDuration()
           t = toc(t0);
           [cmd.position, cmd.velocity, ~] = trajectory.getState(t);
           group.send(cmd);
           pause(0.001);
       end
See also
Class Details
Sealed true
Construct on load false
Constructor Summary
HebiTrajectoryGenerator Provides methods to generate trajectories 
Method Summary
  executeTrajectory executes a trajectory and returns when done 
  getAlgorithm gets the trajectory algorithm that is currently 
  getMinDuration returns the minimum auto-determined duration. 
  getSpeedFactor gets the speed factor that adjusts the speed 
  moveJoint creates a joint-space trajectorythat moves  
  moveLinear moves between waypoints in straight lines in 
  newJointMove creates a trajectory through joint waypoints 
  newLinearMove creates a trajectory through xyz waypoints 
  setAlgorithm sets the trajectory algorithm 
  setMinDuration sets the minimum duration that gets used when  
  setSpeedFactor sets the speed factor that adjusts the speed