Master Thesis Code
by Simon Moser
Loading...
Searching...
No Matches
Trajectory Class Reference

Trajectory Class for generating and manipulating trajectories from waypoints. More...

+ Inheritance diagram for Trajectory:

Public Member Functions

function Trajectory (in options)
 Trajectory Class constructor.
 
function copy (in obj)
 get a copy of the Trajectory object
 
function addWaypoints (in obj, in t_start, in t_stay, in pos, in ori)
 Add waypoints to the trajectory.
 
function setSamplingFrequency (in obj, in fs)
 set the sampling frequency
 
function getSamplingFrequency (in obj)
 get the sampling frequency
 
function plotWaypoints (in obj, in ax, in options)
 plot the waypoints
 
function reduce (in obj)
 return the waypoints table in a reduced format
 
function importTab (in obj, in tab)
 import a waypoints table
 
function getTab (in obj)
 export the waypoints table
 
function setTab (in obj, in tab)
 set the waypoints table
 
function sortTab (in obj)
 sort the waypoints table in ascending order of start time
 
function cleanTab (in obj)
 clean the waypoints table
 
function getInterpMethods (in obj)
 get the interpolation methods
 
function setInterpMethods (in obj, in methods)
 set the interpolation methods
 
function generateTrajectory (in obj, in options)
 Generate the trajectory from the waypoints table.
 
function getTrajectory (in obj)
 get the trajectory timetable
 
function getIsGenerated (in obj)
 

Static Private Member Functions

static function quaternionFillMissing (in q)
 fill missing values in a quaternion array
 

Private Attributes

Constant Property tabVarNames = [
 names of the variables in the waypoints table
 
Constant Property tabVarTypes = [
 types of the variables in the waypoints table
 
Constant Property interpMethodsPos = [
 available interpolation methods for position
 
Constant Property interpMethodsOri = [
 available interpolation methods for orientation
 
Constant Property trajVarNames = [
 names of the variables in the trajectory table
 
Constant Property trajVarTypes = [
 types of the variables in the trajectory table
 
Constant Property trajVarUnits = [
 units of the variables in the trajectory table
 
Property fs
 sampling frequency in Hz
 
Property tab
 waypoints table
 
Property traj
 trajectory table
 
Property interpMethodPos
 interpolation method of the position
 
Property interpMethodOri
 interpolation method of the orientation
 
Property isGenerated
 flag if the trajectory is generated and up to date
 

Detailed Description

Trajectory Class for generating and manipulating trajectories from waypoints.

The Trajectory class is used to generate and manipulate trajectories from waypoints. The waypoints are defined by their start time, stay time, position, and orientation. The trajectory is generated by interpolating the position and orientation between the waypoints.

% Example usage:
% Create a Trajectory object
% Add waypoints to the trajectory
t_start = seconds([0, 5, 10, 15]);
t_stay = seconds([5, 5, 5, 5]);
pos = [0,0,0; 1,1,1; 2,2,2; 3,3,3];
ori = quaternion([1,0,0,0; 0.7071,0,0.7071,0; 0.7071,0,0,0.7071; 0,0,0,1]);
traj.addWaypoints(t_start, t_stay, pos, ori);
% Plot the waypoints
traj.plotWaypoints();
% Generate the trajectory
traj.generateTrajectory();
% Get the trajectory
traj.getTrajectory();
Trajectory Class for generating and manipulating trajectories from waypoints.
Definition Trajectory.m:37
function Trajectory(in options)
Trajectory Class constructor.
Property traj
trajectory table
Definition Trajectory.m:81

see also the more detailed example in trajectoryExample.m

Examples
derivation1KalmanFilter.m, derivation2KalmanFilter.m, derivation3RtsSmoother.m, derivation4ExtendedKalmanFilter.m, trajectoryExample.m, and waypointsToMeasurementsExample.m.

Definition at line 36 of file Trajectory.m.

Constructor & Destructor Documentation

◆ Trajectory()

function Trajectory ( in options)

Trajectory Class constructor.

Parameters
options(optional) - Structure specifying custom settings for the Trajectory object.
  • options.fs (optional) - Sampling frequency in Hz (default: 200)
Return values
obj- The created Trajectory object.

Member Function Documentation

◆ addWaypoints()

function addWaypoints ( in obj,
in t_start,
in t_stay,
in pos,
in ori )

Add waypoints to the trajectory.

addWaypoints(obj,t_start,t_stay,pos,ori) adds waypoints to the trajectory from the inputs. The waypoints are defined by their start time, stay time, position, and orientation.

Parameters
t_start- Start time of each waypoint (duration array)
t_stay- Duration of each waypoint (duration array)
pos- Position of each waypoint (Nx3 double array)
ori- Orientation of each waypoint (quaternion array)
Return values
None
Note
The inputs must have the same height.

◆ cleanTab()

function cleanTab ( in obj)

clean the waypoints table

cleanTab(obj) removes duplicate waypoints, rounds the start and stay times to the nearest multiple of the sampling time, and checks for time overlapping. The resulting table is sorted by start time.

Parameters
None
Return values
None

◆ copy()

function copy ( in obj)

get a copy of the Trajectory object

Parameters
None

Return values
obj- Copy of the Trajectory object

◆ generateTrajectory()

function generateTrajectory ( in obj,
in options )

Generate the trajectory from the waypoints table.

generateTrajectory(obj) generates the trajectory from the waypoints table using the default settings. For the generation of the trajectory, the position is interpolated to get a trajectory with the selected sampling frequency matching the waypoints.

generateTrajectory(obj, options) generates the trajectory from the waypoints table using custom settings specified by the options structure.

Parameters
options(optional) - Custom settings for the trajectory generation
options.pos(optional) - Interpolation method for position
options.ori(optional) - Interpolation method for orientation
options.fs(optional) - Sampling frequency in Hz
Examples
trajectoryExample.m, and waypointsToMeasurementsExample.m.

◆ getInterpMethods()

function getInterpMethods ( in obj)

get the interpolation methods

Parameters
None
Return values
methods- Structure containing the available interpolation methods for position and orientation, as well as the currently selected methods.

◆ getIsGenerated()

function getIsGenerated ( in obj)

◆ getSamplingFrequency()

function getSamplingFrequency ( in obj)

get the sampling frequency

Parameters
None
Return values
fs- Sampling frequency in Hz

◆ getTab()

function getTab ( in obj)

export the waypoints table

Parameters
None
Return values
tab- Waypoints table

◆ getTrajectory()

function getTrajectory ( in obj)

get the trajectory timetable

Parameters
None
Return values
traj- Trajectory timetable

◆ importTab()

function importTab ( in obj,
in tab )

import a waypoints table

Parameters
tab- Waypoints table
Return values
None
Note
this is used in the trajectoryGenerationApp. The table must have the same format as the one returned by the reduce method.

◆ plotWaypoints()

function plotWaypoints ( in obj,
in ax,
in options )

plot the waypoints

plotWaypoints(obj,ax,options) plots the waypoints on the specified axes using the custom settings specified by the options structure. The resulting plot is a 3D plot with the waypoints represented by a model of the JUMP sensor and a line connecting the waypoints.

Parameters
ax(optional) - Axes to plot the waypoints on
options(optional) - Structure specifying custom settings for the plot
  • options.scale (optional) - Scale factor for the waypoints (default: 10)
  • options.numbers (optional) - Flag to display the waypoint numbers (default: true)
  • options.line (optional) - Flag to display a line between the waypoints (default: true)
Return values
fig- Figure handle of the plot

◆ quaternionFillMissing()

static function quaternionFillMissing ( in q)
staticprivate

fill missing values in a quaternion array

Parameters
q- Quaternion array
Return values
qFilled- Quaternion array with filled missing values

◆ reduce()

function reduce ( in obj)

return the waypoints table in a reduced format

Parameters
None
Return values
tab- Waypoints table in a reduced format
Note
This format is used in the trajectoryGenerationApp.

◆ setInterpMethods()

function setInterpMethods ( in obj,
in methods )

set the interpolation methods

setInterpMethods(obj,methods) sets the interpolation methods for position and orientation.

Parameters
methods.pos(optional) - Interpolation method for position
methods.ori(optional) - Interpolation method for orientation
Return values
None
Note
The interpolation methods must be part of the available interpolation methods. The available interpolation methods can be obtained by calling the getInterpMethods() method.

◆ setSamplingFrequency()

function setSamplingFrequency ( in obj,
in fs )

set the sampling frequency

Parameters
fs- Sampling frequency in Hz (positive integer)
Return values
None
Note
The Sampling frequency is used to generate the trajectory

◆ setTab()

function setTab ( in obj,
in tab )

set the waypoints table

Parameters
tab- Waypoints table
Return values
None

◆ sortTab()

function sortTab ( in obj)

sort the waypoints table in ascending order of start time

Parameters
None
Return values
None

Member Data Documentation

◆ fs

Property fs
private

sampling frequency in Hz

Definition at line 73 of file Trajectory.m.

◆ interpMethodOri

Property interpMethodOri
private

interpolation method of the orientation

Definition at line 89 of file Trajectory.m.

◆ interpMethodPos

Property interpMethodPos
private

interpolation method of the position

Definition at line 85 of file Trajectory.m.

◆ interpMethodsOri

Constant Property interpMethodsOri = [
private

available interpolation methods for orientation

Definition at line 55 of file Trajectory.m.

◆ interpMethodsPos

Constant Property interpMethodsPos = [
private

available interpolation methods for position

Definition at line 51 of file Trajectory.m.

◆ isGenerated

Property isGenerated
private

flag if the trajectory is generated and up to date

Definition at line 93 of file Trajectory.m.

◆ tab

Property tab
private

waypoints table

Definition at line 77 of file Trajectory.m.

◆ tabVarNames

Constant Property tabVarNames = [
private

names of the variables in the waypoints table

Definition at line 43 of file Trajectory.m.

◆ tabVarTypes

Constant Property tabVarTypes = [
private

types of the variables in the waypoints table

Definition at line 47 of file Trajectory.m.

◆ traj

Property traj
private

trajectory table

Definition at line 81 of file Trajectory.m.

◆ trajVarNames

Constant Property trajVarNames = [
private

names of the variables in the trajectory table

Definition at line 59 of file Trajectory.m.

◆ trajVarTypes

Constant Property trajVarTypes = [
private

types of the variables in the trajectory table

Definition at line 63 of file Trajectory.m.

◆ trajVarUnits

Constant Property trajVarUnits = [
private

units of the variables in the trajectory table

Definition at line 67 of file Trajectory.m.


The documentation for this class was generated from the following file: