5 #include <moveit/trajectory_processing/iterative_time_parameterization.h>
34 const moveit_msgs::RobotTrajectory &msg)
36 trajectory_->setRobotTrajectoryMsg(reference_state, msg);
40 const trajectory_msgs::JointTrajectory &msg)
42 trajectory_->setRobotTrajectoryMsg(reference_state, msg);
47 moveit_msgs::RobotTrajectory msg;
56 moveit_msgs::RobotTrajectory msg;
81 moveit_msgs::RobotTrajectory msg;
98 double max_velocity,
double max_acceleration)
106 #if ROBOWFLEX_AT_LEAST_KINETIC
117 for (
int seg = 0; seg < n1; ++seg)
126 double segment_length = s0->distance(*s2);
127 int ns = (int)floor(0.5 + (
double)count * segment_length / total_length) + 1;
135 for (
int j = 1; j < ns; j++)
138 auto s1 = std::make_shared<robot_state::RobotState>(
trajectory_->getRobotModel());
139 double dt = double(j) / double(ns);
141 s0->interpolate(*s2, dt, *s1);
150 RBX_INFO(
"Added %d extra states in the trajectory", added);
161 for (
const auto &p : msg.joint_trajectory.points)
169 return getMessage().joint_trajectory.joint_names;
188 length += metric(s1, s2);
190 length += s1.distance(s2);
203 if (!s->satisfiesBounds())
206 const auto result =
scene->checkCollision(*s);
207 if (result.collision)
223 double clearance =
scene->distanceToCollision(*s);
226 average += clearance;
227 maximum = (maximum > clearance) ? maximum : clearance;
228 minimum = (minimum < clearance) ? minimum : clearance;
239 double smoothness = 0.0;
242 (metric) ? metric : [](
const robot_state::RobotState &a,
const robot_state::RobotState &b) {
243 return a.distance(b);
264 double acos_value = (a * a + b * b - cdist * cdist) / (2.0 * a * b);
265 if (acos_value > -1.0 && acos_value < 1.0)
271 double u = 2.0 * angle;
290 const auto &names = last.getVariableNames();
291 const auto &values = last.getVariablePositions();
294 map.
emplace(names[i], values[i]);
Exception that contains a message and an error code.
A const shared pointer wrapper for robowflex::Robot.
A const shared pointer wrapper for robowflex::Scene.
The Trajectory class is a wrapper around MoveIt!'s robot_trajectory::RobotTrajectory,...
Trajectory(const RobotConstPtr &robot, const std::string &group)
Constructor for an empty trajectory.
void interpolate(unsigned int count)
Insert a number of states in a path so that the path is made up of exactly count states....
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.
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,...
std::map< std::string, double > getFinalPositions() const
Returns the joint positions from the last state in a planned trajectory in response.
robot_trajectory::RobotTrajectoryPtr trajectory_
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...
bool fromYAMLFile(const robot_state::RobotState &reference_state, const std::string &filename)
Load a trajectory from a YAML file.
const robot_trajectory::RobotTrajectoryPtr & getTrajectoryConst() const
Get a const reference to the trajectory.
std::vector< std::string > getJointNames() const
Get the names of the variables that make up this trajectory, in the same order as in MoveIt JointMode...
void addSuffixWaypoint(const robot_state::RobotState &state, double dt=1.)
Add a waypoint at the end of the trajectory.
bool toYAMLFile(const std::string &filename) const
Dump a trajectory to a file.
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).
std::tuple< double, double, double > getClearance(const SceneConstPtr &scene) const
Get the average, minimum, and maximum clearance of a path.
bool isCollisionFree(const SceneConstPtr &scene) const
Checks if a path is collsion free.
robot_trajectory::RobotTrajectoryPtr & getTrajectory()
Get a reference to the trajectory.
double getSmoothness(const PathMetric &metric={}) const
Get the smoothness of a path relative to some metric. See internal function documentation for details...
void useMessage(const robot_state::RobotState &reference_state, const moveit_msgs::RobotTrajectory &msg)
Set the trajectory to be the same as a message.
moveit_msgs::RobotTrajectory getMessage() const
Get the message that describes the trajectory.
std::size_t getNumWaypoints() const
Returns the number of waypoints of the trajectory.
bool computeTimeStamps(robot_trajectory::RobotTrajectory &trajectory, const double max_velocity_scaling_factor=1.0, const double max_acceleration_scaling_factor=1.0) const
T emplace_back(T... args)
#define RBX_INFO(fmt,...)
Output a info logging message.
Functions for loading and animating robots in Blender.
bool YAMLToFile(const YAML::Node &node, const std::string &file)
Write the contents of a YAML node out to a potentially new file.
YAML::Node toNode(const geometry_msgs::Pose &msg)
Converts a pose message to YAML.
bool YAMLFileToMessage(T &msg, const std::string &file)
Load a message (or YAML convertable object) from a file.
Main namespace. Contains all library classes and functions.
Functions for loading and animating scenes in Blender.
robot_trajectory::RobotTrajectory trajectory(rmodel,"right_arm")