Robowflex  v0.1
Making MoveIt Easy
ur5_test.cpp
Go to the documentation of this file.
1 /* Author: Zachary Kingston */
2 
9 
10 using namespace robowflex;
11 
12 /* \file fetch_test.cpp
13  * A simple script that demonstrates motion planning with the UR5 robot. Here,
14  * two planners are created: the default OMPL planner, and the default OMPL
15  * planner but with simplified solutions disabled.
16  */
17 
18 int main(int argc, char **argv)
19 {
20  // Startup ROS
21  ROS ros(argc, argv);
22 
23  // Create the default UR5 robot.
24  auto ur5 = std::make_shared<UR5Robot>();
25  ur5->initialize();
26 
27  // Create an empty scene.
28  auto scene = std::make_shared<Scene>(ur5);
29 
30  // Create the default planner for the UR5.
31  auto default_planner = std::make_shared<OMPL::UR5OMPLPipelinePlanner>(ur5, "default");
32  default_planner->initialize();
33 
34  // Create the a planner for the UR5, and disable simplification.
35  auto simple_planner = std::make_shared<OMPL::UR5OMPLPipelinePlanner>(ur5, "simple");
36 
37  OMPL::Settings settings;
38  settings.simplify_solutions = false;
39 
40  simple_planner->initialize(settings);
41 
42  // Run a motion plan for each planner.
43  for (const auto &planner : {default_planner, simple_planner})
44  {
45  // Create a motion planning request with a pose goal.
46  MotionRequestBuilder request(planner, "manipulator");
47  request.setStartConfiguration({0.0677, -0.8235, 0.9860, -0.1624, 0.0678, 0.0});
48 
49  RobotPose pose = RobotPose::Identity();
50  pose.translate(Eigen::Vector3d{-0.268, -0.826, 1.313});
51  Eigen::Quaterniond orn{0, 0, 1, 0};
52 
53  request.setGoalRegion("ee_link", "world", // links
54  pose, Geometry::makeSphere(0.1), // position
55  orn, {0.01, 0.01, 0.01} // orientation
56  );
57 
58  // Do motion planning!
59  planning_interface::MotionPlanResponse res = planner->plan(scene, request.getRequest());
60  if (res.error_code_.val != moveit_msgs::MoveItErrorCodes::SUCCESS)
61  return 1;
62  }
63 
64  return 0;
65 }
static GeometryPtr makeSphere(double radius)
Create a sphere.
Definition: geometry.cpp:43
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
Settings descriptor for settings provided by the default MoveIt! OMPL planning pipeline.
bool simplify_solutions
Whether or not planner should simplify solutions.
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)
Definition: ur5_test.cpp:18