-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmove_group_interface_coordinate.cpp
67 lines (53 loc) · 2.22 KB
/
move_group_interface_coordinate.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <moveit/move_group_interface/move_group.h>
#include <moveit/planning_scene_interface/planning_scene_interface.h>
#include <moveit_msgs/DisplayRobotState.h>
#include <moveit_msgs/DisplayTrajectory.h>
int main(int argc, char **argv)
{
ros::init(argc, argv, "move_group_interface");
ros::NodeHandle node_handle;
ros::AsyncSpinner spinner(1);
spinner.start();
//Sleep to allow Rviz to come up
sleep(20.0);
//----------------------------
//Setup
//----------------------------
//Setting up MoveGroup class with the group to control
moveit::planning_interface::MoveGroup group("arm");
//Using :planning_scene_interface:'PlanningSceneInterface' class to deal directly with the world
moveit::planning_interface::PlanningSceneInterface planning_Scene_interface;
//(Optional) Create a publisher for visualizing plans in Rviz
ros::Publisher display_publisher = node_handle.advertise<moveit_msgs::DisplayTrajectory>("/move_group/display_planned_path", 1, true);
moveit_msgs::DisplayTrajectory display_trajectory;
//-----------------------------
//Getting Basic Information
//-----------------------------
//Print name of reference frame for robot
ROS_INFO("Reference frame: %s", group.getPlanningFrame().c_str());
//Print name of end-effector link for this group
ROS_INFO("Reference frame: %s", group.getEndEffectorLink().c_str());
//-----------------------------
//Planning to a Pose Goal
//-----------------------------
//Plan a motion for this group to a desired pose for end-effector
geometry_msgs::Pose target_pose1;
target_pose1.orientation.w = 0.174627;
target_pose1.orientation.x = -0.043707;
target_pose1.orientation.y = 0.789749;
target_pose1.orientation.z = 0.586423;
target_pose1.position.x = -0.687822;
target_pose1.position.y = 0.316510;
target_pose1.position.z = 0.475076;
group.setPoseTarget(target_pose1);
group.setGoalTolerance(0.01);
//Call the planner to compute the plan and visualize it
//Just planning, not asking move_group to move the robot
moveit::planning_interface::MoveGroup::Plan my_plan;
bool success = group.plan(my_plan);
ROS_INFO("Visualizing plan 1 (pose goal) %s",success?"":"FAILED");
//Give Rviz time to visualize the plan
sleep(5.0);
ros::waitForShutdown();
return 0;
}