Robowflex  v0.1
Making MoveIt Easy
ur5_ompl_interface.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
10 
12 
13 using namespace robowflex;
14 
15 int main(int argc, char **argv)
16 {
17  // Startup ROS
18  ROS ros(argc, argv);
19 
20  // Create the default UR5 robot.
21  auto ur5 = std::make_shared<UR5Robot>();
22  ur5->initialize();
23 
24  // Create an empty scene.
25  auto scene = std::make_shared<Scene>(ur5);
26 
27  // Create an OMPL interface planner for the ur5.
28  auto planner = std::make_shared<OMPL::OMPLInterfacePlanner>(ur5);
29  planner->initialize("package://ur5_robotiq85_moveit_config/config/ompl_planning.yaml");
30 
31  // Create a motion planning request with a pose goal.
32  MotionRequestBuilder request(planner, "manipulator");
33  request.setStartConfiguration({0.0677, -0.8235, 0.9860, -0.1624, 0.0678, 0.0});
34 
35  RobotPose pose = RobotPose::Identity();
36  pose.translate(Eigen::Vector3d{-0.268, -0.826, 1.313});
37  Eigen::Quaterniond orn{0, 0, 1, 0};
38 
39  auto sphere = std::make_shared<Geometry>(Geometry::ShapeType::SPHERE, Eigen::Vector3d{0.01, 0, 0});
40  request.setGoalRegion("ee_link", "world", // links
41  pose, sphere, // position
42  orn, {0.01, 0.01, 0.01} // orientation
43  );
44 
45  // Do motion planning!
46  planning_interface::MotionPlanResponse res = planner->plan(scene, request.getRequest());
47  if (res.error_code_.val != moveit_msgs::MoveItErrorCodes::SUCCESS)
48  return 1;
49 
50  return 0;
51 }
@ SPHERE
Solid primitive sphere. Uses one dimension (radius).
Definition: geometry.h:46
A helper class to build motion planning requests for a robowflex::Planner.
Definition: builder.h:34
void setStartConfiguration(const std::vector< double > &joints)
Set the start configuration from a vector joints. All joints are assumed to be specified and in the d...
Definition: builder.cpp:189
planning_interface::MotionPlanRequest & getRequest()
Get a reference to the currently built motion planning request.
Definition: builder.cpp:493
void setGoalRegion(const std::string &ee_name, const std::string &base_name, const RobotPose &pose, const GeometryConstPtr &geometry, const Eigen::Quaterniond &orientation, const Eigen::Vector3d &tolerances)
Set a goal region for an end-effector ee_name. Sets the position constraint from geometry at a pose p...
Definition: builder.cpp:403
RAII-pattern for starting up ROS.
Definition: util.h:52
Main namespace. Contains all library classes and functions.
Definition: scene.cpp:25
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.
Definition: adapter.h:24
Functions for loading and animating scenes in Blender.
moveit_msgs::MoveItErrorCodes error_code_
int main(int argc, char **argv)