42 ref_state_ = std::make_shared<robot_state::RobotState>(*start_state);
48 auto pci = std::make_shared<trajopt::ProblemConstructionInfo>(env_);
49 problemConstructionInfo(pci);
55 addStartState(start_state, pci);
60 return solve(
scene, pci);
68 for (
const auto &term : constraints_)
70 Eigen::Quaterniond rotation(term.pose.linear());
71 auto pose_constraint = std::make_shared<trajopt::CartPoseTermInfo>();
72 pose_constraint->term_type = trajopt::TT_CNT;
73 pose_constraint->link = term.link;
74 pose_constraint->timestep = term.timestep;
75 pose_constraint->xyz = term.pose.translation();
76 pose_constraint->wxyz = Eigen::Vector4d(rotation.w(), rotation.x(), rotation.y(), rotation.z());
77 pose_constraint->pos_coeffs = Eigen::Vector3d::Constant(term.pos_coeffs);
78 pose_constraint->rot_coeffs = Eigen::Vector3d::Constant(term.rot_coeffs);
79 pose_constraint->name =
"pose_cnt_link_" + term.link +
std::to_string(term.timestep);
81 pci->cnt_infos.push_back(pose_constraint);
86 int main(
int argc,
char **argv)
92 auto ur5 = std::make_shared<UR5Robot>();
96 ur5->setGroupState(
GROUP, {0.0677, -0.8235, 0.9860, -0.1624, 0.0678, 0.0});
97 const auto &ee = ur5->getModel()->getEndEffectors()[0]->getLinkModelNames()[0];
102 RBX_INFO(
"RViz Initialized! Press enter to continue (after your RViz is setup)...");
106 auto scene = std::make_shared<Scene>(ur5);
107 scene->getCurrentState() = *ur5->getScratchState();
111 auto planner = std::make_shared<CustomTrajOptPlanner>(ur5,
GROUP);
112 planner->initialize(
GROUP);
113 planner->options.num_waypoints = 17;
116 EigenSTL::vector_Vector3d directions = {
117 {0.0, -0.3, 0.0}, {0.0, 0.0, -0.2}, {0.0, 0.3, 0.0}, {0.0, 0.0, 0.2}};
120 for (
size_t i = 0; i < directions.size(); ++i)
123 pose.translate(directions[i]);
130 planner->constraints_.push_back(term);
134 auto response = planner->plan(
scene, ur5->getScratchState());
137 RBX_INFO(
"Optimization did not converge");
146 scene->getCurrentState() = *ur5->getScratchState();
PlannerResult plan(const SceneConstPtr &scene, const robot_state::RobotStatePtr &start_state)
Plan a motion using custom terms specified by the user.
void addCartTerms(std::shared_ptr< trajopt::ProblemConstructionInfo > pci) const
CustomTrajOptPlanner(const RobotPtr &robot, const std::string &group_name)
RVIZ visualization helper. See Live Visualization with RViz for more information.
void updateScene(const SceneConstPtr &scene)
Updates the scene being visualized.
void updateTrajectory(const planning_interface::MotionPlanResponse &response)
Updates the trajectory being visualized.
RAII-pattern for starting up ROS.
A shared pointer wrapper for robowflex::Robot.
A const shared pointer wrapper for robowflex::Scene.
Robowflex Tesseract TrajOpt Planner.
The Trajectory class is a wrapper around MoveIt!'s robot_trajectory::RobotTrajectory,...
#define RBX_INFO(fmt,...)
Output a info logging message.
Functions for loading and animating robots in Blender.
bool sceneToTesseractEnv(const robowflex::SceneConstPtr &scene, tesseract::tesseract_ros::KDLEnvPtr env)
Add scene collision objects to a (previously initialized) KDL environment.
Main namespace. Contains all library classes and functions.
std::decay< decltype(std::declval< moveit::core::Transforms >().getTransform("")) >::type RobotPose
A pose (point in SE(3)) used in various functions. Defined from what MoveIt! uses.
Functions for loading and animating scenes in Blender.
robot_trajectory::RobotTrajectory trajectory(rmodel,"right_arm")
int main(int argc, char **argv)
static const std::string GROUP