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

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Variables

static const std::string BOTH_ARMS = "both_arms"
 
static const std::string LEFT_ARM = "left_arm"
 
static const std::string LEFT_EE = "left_gripper_base"
 
static const std::string RIGHT_EE = "right_gripper_base"
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 25 of file baxter_multi_target.cpp.

26 {
27  // Startup ROS
28  ROS ros(argc, argv);
29 
30  // Create a Baxter robot.
31  auto baxter = std::make_shared<Robot>("baxter");
32  baxter->initializeFromYAML("package://robowflex_resources/baxter.yml");
33  baxter->loadKinematics(BOTH_ARMS);
34 
35  // Visualize the Baxter robot
36  IO::RVIZHelper rviz(baxter);
37  rviz.visualizeCurrentState();
38  RBX_INFO("Default robot state is visualized. Press enter to continue...");
39  std::cin.ignore();
40 
41  // EE offset that makes the arm point upwards.
42  const auto &ee_offset = TF::createPoseXYZ(0, 0, -1.3, constants::pi, 0, 0);
43 
44  // Use IK to shift robot arm over by desired amount.
45  const RobotPose &goal_pose_left = baxter->getLinkTF(LEFT_EE) * ee_offset;
46  const RobotPose &goal_pose_right = baxter->getLinkTF(RIGHT_EE) * ee_offset;
47 
48  // Visualizing the target poses.
49  rviz.addTransformMarker("pose_right", "map", goal_pose_right);
50  rviz.addTransformMarker("pose_left", "map", goal_pose_left);
51  rviz.updateMarkers();
52  RBX_INFO("Target IK poses are visualized. Press enter to continue...");
53  std::cin.ignore();
54 
55  Robot::IKQuery query(BOTH_ARMS, {goal_pose_left, goal_pose_right}, {LEFT_EE, RIGHT_EE});
56 
57  if (not baxter->setFromIK(query))
58  {
59  RBX_ERROR("IK query failed!");
60  return 1;
61  }
62 
63  // Visualize resulting state.
64  rviz.visualizeCurrentState();
65 
66  RBX_INFO("Robot IK solution visualized, Press enter to continue...");
67  std::cin.ignore();
68 
69  query = Robot::IKQuery(LEFT_ARM, goal_pose_left);
70  if (not baxter->setFromIK(query))
71  {
72  RBX_ERROR("Single IK query failed!");
73  return 1;
74  }
75 
76  // Visualize resulting state.
77  rviz.visualizeCurrentState();
78 
79  RBX_INFO("Robot left arm IK(ee:default) is visualized. Press enter to continue ...");
80  std::cin.ignore();
81 
82  query = Robot::IKQuery(LEFT_ARM, {goal_pose_left}, {LEFT_EE});
83  query.options.return_approximate_solution = true; // Enable approximate IK solutions.
84  query.validate = true; // Use to verify approximate solutions are within tolerance.
85  query.valid_distance = 0.05; // Tuned distance threshold that is appropriate for query.
86 
87  if (not baxter->setFromIK(query))
88  {
89  RBX_ERROR("Single Approximate IK query failed!");
90  return 1;
91  }
92 
93  // Visualize resulting state.
94  rviz.visualizeCurrentState();
95  RBX_INFO("Robot left arm IK(ee:left_gripper_base) is visualized. Press enter to exit...");
96  std::cin.ignore();
97 
98  return 0;
99 }
static const std::string LEFT_EE
static const std::string LEFT_ARM
static const std::string BOTH_ARMS
static const std::string RIGHT_EE
RVIZ visualization helper. See Live Visualization with RViz for more information.
Definition: visualization.h:38
RAII-pattern for starting up ROS.
Definition: util.h:52
#define RBX_ERROR(fmt,...)
Output a error logging message.
Definition: log.h:102
#define RBX_INFO(fmt,...)
Output a info logging message.
Definition: log.h:118
RobotPose createPoseXYZ(double x, double y, double z)
Creates a robot pose from a linear component and zero orientation.
Definition: tf.cpp:14
static const double pi
Definition: constants.h:21
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
Robot IK Query options. IK queries in Robowflex consist of: a) A position specified by some geometric...
kinematics::KinematicsQueryOptions options
Other query options.

Variable Documentation

◆ BOTH_ARMS

const std::string BOTH_ARMS = "both_arms"
static

Definition at line 20 of file baxter_multi_target.cpp.

◆ LEFT_ARM

const std::string LEFT_ARM = "left_arm"
static

Definition at line 21 of file baxter_multi_target.cpp.

◆ LEFT_EE

const std::string LEFT_EE = "left_gripper_base"
static

Definition at line 22 of file baxter_multi_target.cpp.

◆ RIGHT_EE

const std::string RIGHT_EE = "right_gripper_base"
static

Definition at line 23 of file baxter_multi_target.cpp.