Robowflex  v0.1
Making MoveIt Easy
cob4_test.cpp File Reference

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Variables

static const std::string LEFT_ARM = "arm_left"
 
static const std::string RIGHT_ARM = "arm_right"
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 27 of file cob4_test.cpp.

28 {
29  // Startup ROS
30  ROS ros(argc, argv);
31 
32  // Create the default Care-O-Bot4 robot.
33  auto cob4 = std::make_shared<Cob4Robot>();
34  cob4->initialize();
35 
36  // Create an empty scene.
37  auto scene = std::make_shared<Scene>(cob4);
38 
39  // Load kinematics for the COB4 robot.
40  cob4->loadKinematics(RIGHT_ARM);
41  cob4->loadKinematics(LEFT_ARM);
42 
43  // Extend the arms.
44  cob4->setGroupState(RIGHT_ARM, {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0});
45  cob4->setGroupState(LEFT_ARM, {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0});
46 
47  // Create the default planner for the COB4.
48  auto planner = std::make_shared<OMPL::Cob4OMPLPipelinePlanner>(cob4);
49  planner->initialize();
50 
51  // Create a motion planning request with a joint position goal for the right arm.
52  MotionRequestBuilder request_right_arm(planner, RIGHT_ARM);
53  request_right_arm.setStartConfiguration(cob4->getScratchState());
54 
55  // Create a motion planning request with a pose goal to fold the right arm.
56  cob4->setGroupState(RIGHT_ARM, {2.69, 1.70, -0.91, 1.50, -2.14, -2.35, 1.06});
57  request_right_arm.setGoalConfiguration(cob4->getScratchState());
58 
59  request_right_arm.setConfig("RRTConnect");
60 
61  // Do motion planning!
62  planning_interface::MotionPlanResponse res = planner->plan(scene, request_right_arm.getRequest());
63  if (res.error_code_.val != moveit_msgs::MoveItErrorCodes::SUCCESS)
64  return 1;
65 
66  // Create a trajectory object for better manipulation.
67  auto right_arm_trajectory = std::make_shared<Trajectory>(res.trajectory_);
68 
69  // Output path to a file for visualization.
70  right_arm_trajectory->toYAMLFile("cob4_right_arm_path.yml");
71 
72  // Create a motion planning request with a joint position goal for the left arm.
73  MotionRequestBuilder request_left_arm(planner, LEFT_ARM);
74  request_left_arm.setStartConfiguration(cob4->getScratchState());
75 
76  // Create a motion planning request with a pose goal to fold the left arm.
77  cob4->setGroupState(LEFT_ARM, {-1.14, -1.50, 0.34, -1.50, 0.43, -1.56, -1.20});
78  request_left_arm.setGoalConfiguration(cob4->getScratchState());
79 
80  request_left_arm.setConfig("RRTConnect");
81 
82  // Do motion planning!
83  res = planner->plan(scene, request_left_arm.getRequest());
84  if (res.error_code_.val != moveit_msgs::MoveItErrorCodes::SUCCESS)
85  return 1;
86 
87  // Create a trajectory object for better manipulation.
88  auto left_arm_trajectory = std::make_shared<Trajectory>(res.trajectory_);
89 
90  // Output path to a file for visualization.
91  left_arm_trajectory->toYAMLFile("cob4_left_arm_path.yml");
92 
93  return 0;
94 }
A helper class to build motion planning requests for a robowflex::Planner.
Definition: builder.h:34
RAII-pattern for starting up ROS.
Definition: util.h:52
static const std::string LEFT_ARM
Definition: cob4_test.cpp:24
static const std::string RIGHT_ARM
Definition: cob4_test.cpp:25
Functions for loading and animating scenes in Blender.
moveit_msgs::MoveItErrorCodes error_code_
robot_trajectory::RobotTrajectoryPtr trajectory_

Variable Documentation

◆ LEFT_ARM

const std::string LEFT_ARM = "arm_left"
static

Definition at line 24 of file cob4_test.cpp.

◆ RIGHT_ARM

const std::string RIGHT_ARM = "arm_right"
static

Definition at line 25 of file cob4_test.cpp.