Robowflex
v0.1
Making MoveIt Easy
|
The Trajectory class is a wrapper around MoveIt!'s robot_trajectory::RobotTrajectory, with extra convenience functions such interpolation and collision checking. There are also utilities to load and save trajectories from YAML files (toYAMLFile() and fromYAMLFile()). More...
#include <trajectory.h>
Public Member Functions | |
Trajectory (const RobotConstPtr &robot, const std::string &group) | |
Constructor for an empty trajectory. More... | |
Trajectory (const robot_trajectory::RobotTrajectory &trajectory) | |
Constructor from moveit trajectory. More... | |
Trajectory (const robot_trajectory::RobotTrajectoryPtr trajectory) | |
Constructor from moveit trajectory. More... | |
IO | |
void | useMessage (const robot_state::RobotState &reference_state, const moveit_msgs::RobotTrajectory &msg) |
Set the trajectory to be the same as a message. More... | |
void | useMessage (const robot_state::RobotState &reference_state, const trajectory_msgs::JointTrajectory &msg) |
Set the trajectory to be the same as a message. More... | |
bool | toYAMLFile (const std::string &filename) const |
Dump a trajectory to a file. More... | |
bool | fromYAMLFile (const robot_state::RobotState &reference_state, const std::string &filename) |
Load a trajectory from a YAML file. More... | |
Getters and Setters | |
const robot_trajectory::RobotTrajectoryPtr & | getTrajectoryConst () const |
Get a const reference to the trajectory. More... | |
robot_trajectory::RobotTrajectoryPtr & | getTrajectory () |
Get a reference to the trajectory. More... | |
moveit_msgs::RobotTrajectory | getMessage () const |
Get the message that describes the trajectory. More... | |
std::size_t | getNumWaypoints () const |
Returns the number of waypoints of the trajectory. More... | |
Adding and Modifying States | |
void | addSuffixWaypoint (const robot_state::RobotState &state, double dt=1.) |
Add a waypoint at the end of the trajectory. More... | |
Metrics | |
double | getLength (const PathMetric &metric={}) const |
Get the length of a path. Optionally, a metric can be specified other than the default (the L2 norm). More... | |
bool | isCollisionFree (const SceneConstPtr &scene) const |
Checks if a path is collsion free. More... | |
std::tuple< double, double, double > | getClearance (const SceneConstPtr &scene) const |
Get the average, minimum, and maximum clearance of a path. More... | |
double | getSmoothness (const PathMetric &metric={}) const |
Get the smoothness of a path relative to some metric. See internal function documentation for details. More... | |
std::map< std::string, double > | getFinalPositions () const |
Returns the joint positions from the last state in a planned trajectory in response. More... | |
Protected Attributes | |
robot_trajectory::RobotTrajectoryPtr | trajectory_ |
Processing Functions | |
bool | computeTimeParameterization (double max_velocity=1., double max_acceleration=1.) |
Computes the time parameterization of a path according to a desired max velocity or acceleration. More... | |
void | interpolate (unsigned int count) |
Insert a number of states in a path so that the path is made up of exactly count states. States are inserted uniformly (more states on longer segments). Changes are performed only if a path has less than count states. More... | |
std::vector< std::vector< double > > | vectorize () const |
Converts a trajectory into a vector of position vectors. The values are in the same order as reported by getJointNames(), which is consistent within MoveIt. More... | |
std::vector< std::string > | getJointNames () const |
Get the names of the variables that make up this trajectory, in the same order as in MoveIt JointModelGroup. More... | |
Trajectory & | append (const Trajectory &source, double dt, size_t start_index=0, size_t end_index=std::numeric_limits< std::size_t >::max()) |
Adds a specified part of a trajectory to the end of the current trajectory. The default, when start_index or end_index are ommitted, is to add the whole trajectory. More... | |
static bool | computeTimeParameterization (robot_trajectory::RobotTrajectory &trajectory, double max_velocity=1., double max_acceleration=1.) |
Computes the time parameterization of a path according to a desired max velocity or acceleration. More... | |
The Trajectory class is a wrapper around MoveIt!'s robot_trajectory::RobotTrajectory, with extra convenience functions such interpolation and collision checking. There are also utilities to load and save trajectories from YAML files (toYAMLFile() and fromYAMLFile()).
Definition at line 42 of file trajectory.h.
Trajectory::Trajectory | ( | const RobotConstPtr & | robot, |
const std::string & | group | ||
) |
Constructor for an empty trajectory.
[in] | robot | Robot to construct trajectory for. |
[in] | group | Planning group of the trajectory. |
Definition at line 18 of file trajectory.cpp.
Trajectory::Trajectory | ( | const robot_trajectory::RobotTrajectory & | trajectory | ) |
Constructor from moveit trajectory.
[in] | trajectory | Trajectory to initialize with. |
Definition at line 23 of file trajectory.cpp.
Trajectory::Trajectory | ( | const robot_trajectory::RobotTrajectoryPtr | trajectory | ) |
Constructor from moveit trajectory.
[in] | trajectory | Trajectory to initialize with. |
Definition at line 28 of file trajectory.cpp.
void Trajectory::addSuffixWaypoint | ( | const robot_state::RobotState & | state, |
double | dt = 1. |
||
) |
Add a waypoint at the end of the trajectory.
[in] | state | State to add at end of trajectory. |
[in] | dt | Time to this waypoint from previous. |
Definition at line 64 of file trajectory.cpp.
Trajectory & Trajectory::append | ( | const Trajectory & | source, |
double | dt, | ||
size_t | start_index = 0 , |
||
size_t | end_index = std::numeric_limits<std::size_t>::max() |
||
) |
Adds a specified part of a trajectory to the end of the current trajectory. The default, when start_index or end_index are ommitted, is to add the whole trajectory.
[in] | source | The trajectory containing the part to append to the end of current trajectory. |
[in] | dt | Time step between last point in current traj and first point of append traj. |
[in] | start_index | Index of first traj point of the part to append from the source traj. |
[in] | end_index | Index of last traj point of the part to append from the source traj. |
Definition at line 172 of file trajectory.cpp.
bool Trajectory::computeTimeParameterization | ( | double | max_velocity = 1. , |
double | max_acceleration = 1. |
||
) |
Computes the time parameterization of a path according to a desired max velocity or acceleration.
[in] | max_velocity | Maximum path velocity. |
[in] | max_acceleration | Maximum path acceleration. |
Definition at line 91 of file trajectory.cpp.
|
static |
Computes the time parameterization of a path according to a desired max velocity or acceleration.
[in] | trajectory | to compute time parameterization. |
[in] | max_velocity | Maximum path velocity. |
[in] | max_acceleration | Maximum path acceleration. |
Definition at line 97 of file trajectory.cpp.
bool Trajectory::fromYAMLFile | ( | const robot_state::RobotState & | reference_state, |
const std::string & | filename | ||
) |
Load a trajectory from a YAML file.
[in] | reference_state | A full state that contains the values for all the joints. |
[in] | filename | Trajectory filename. |
Definition at line 54 of file trajectory.cpp.
std::tuple< double, double, double > Trajectory::getClearance | ( | const SceneConstPtr & | scene | ) | const |
Get the average, minimum, and maximum clearance of a path.
[in] | scene | Scene to compute clearance to. |
Definition at line 214 of file trajectory.cpp.
std::map< std::string, double > Trajectory::getFinalPositions | ( | ) | const |
Returns the joint positions from the last state in a planned trajectory in response.
Definition at line 284 of file trajectory.cpp.
std::vector< std::string > Trajectory::getJointNames | ( | ) | const |
Get the names of the variables that make up this trajectory, in the same order as in MoveIt JointModelGroup.
Definition at line 167 of file trajectory.cpp.
double Trajectory::getLength | ( | const PathMetric & | metric = {} | ) | const |
Get the length of a path. Optionally, a metric can be specified other than the default (the L2 norm).
[in] | metric | An optional metric to use to compute the length of the path. |
Definition at line 178 of file trajectory.cpp.
moveit_msgs::RobotTrajectory Trajectory::getMessage | ( | ) | const |
Get the message that describes the trajectory.
Definition at line 79 of file trajectory.cpp.
std::size_t Trajectory::getNumWaypoints | ( | ) | const |
Returns the number of waypoints of the trajectory.
Definition at line 86 of file trajectory.cpp.
double Trajectory::getSmoothness | ( | const PathMetric & | metric = {} | ) | const |
Get the smoothness of a path relative to some metric. See internal function documentation for details.
[in] | metric | An optional metric to use to compute the length of the path segments. |
(a + b);
Definition at line 237 of file trajectory.cpp.
robot_trajectory::RobotTrajectoryPtr & Trajectory::getTrajectory | ( | ) |
Get a reference to the trajectory.
Definition at line 74 of file trajectory.cpp.
const robot_trajectory::RobotTrajectoryPtr & Trajectory::getTrajectoryConst | ( | ) | const |
Get a const reference to the trajectory.
Definition at line 69 of file trajectory.cpp.
void Trajectory::interpolate | ( | unsigned int | count | ) |
Insert a number of states in a path so that the path is made up of exactly count states. States are inserted uniformly (more states on longer segments). Changes are performed only if a path has less than count states.
[in] | count | number of states to insert. |
Definition at line 104 of file trajectory.cpp.
bool Trajectory::isCollisionFree | ( | const SceneConstPtr & | scene | ) | const |
Checks if a path is collsion free.
[in] | scene | Scene to collision check the path with. |
Definition at line 196 of file trajectory.cpp.
bool Trajectory::toYAMLFile | ( | const std::string & | filename | ) | const |
Dump a trajectory to a file.
[in] | filename | Trajectory filename. |
Definition at line 45 of file trajectory.cpp.
void Trajectory::useMessage | ( | const robot_state::RobotState & | reference_state, |
const moveit_msgs::RobotTrajectory & | msg | ||
) |
Set the trajectory to be the same as a message.
[in] | reference_state | A full state that contains the values for all the joints |
[in] | msg | Message used to set the trajectory |
Definition at line 33 of file trajectory.cpp.
void Trajectory::useMessage | ( | const robot_state::RobotState & | reference_state, |
const trajectory_msgs::JointTrajectory & | msg | ||
) |
Set the trajectory to be the same as a message.
[in] | reference_state | A full state that contains the values for all the joints. |
[in] | msg | Message used to set the trajectory |
Definition at line 39 of file trajectory.cpp.
std::vector< std::vector< double > > Trajectory::vectorize | ( | ) | const |
Converts a trajectory into a vector of position vectors. The values are in the same order as reported by getJointNames(), which is consistent within MoveIt.
Definition at line 157 of file trajectory.cpp.
|
protected |
Definition at line 218 of file trajectory.h.