Skip to content

Commit f226955

Browse files
authored
Update the displayed tutorial robot (#720)
* Update Quickstart Guide * Update your first c++ project * Update Visualizing in rviz * Update Planning Around Objects tutorial * missed a couple updates * pre-commit * Needs to be demo.launch.py * add kinova 7dof moveit config dependency * update unit test * pre-commit again * update test pose * update trajectory_execution param
1 parent a7a1b89 commit f226955

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1855
-36
lines changed
662 KB
Binary file not shown.
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
#include <moveit/move_group_interface/move_group_interface.h>
2+
#include <moveit/planning_scene_interface/planning_scene_interface.h>
3+
#include <moveit_visual_tools/moveit_visual_tools.h>
4+
5+
#include <memory>
6+
#include <rclcpp/rclcpp.hpp>
7+
#include <thread>
8+
9+
int main(int argc, char* argv[])
10+
{
11+
// Initialize ROS and create the Node
12+
rclcpp::init(argc, argv);
13+
auto const node = std::make_shared<rclcpp::Node>(
14+
"hello_moveit", rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true));
15+
16+
// Create a ROS logger
17+
auto const logger = rclcpp::get_logger("hello_moveit");
18+
19+
// We spin up a SingleThreadedExecutor for the current state monitor to get
20+
// information about the robot's state.
21+
rclcpp::executors::SingleThreadedExecutor executor;
22+
executor.add_node(node);
23+
auto spinner = std::thread([&executor]() { executor.spin(); });
24+
25+
// Create the MoveIt MoveGroup Interface
26+
using moveit::planning_interface::MoveGroupInterface;
27+
auto move_group_interface = MoveGroupInterface(node, "manipulator");
28+
29+
// Construct and initialize MoveItVisualTools
30+
auto moveit_visual_tools =
31+
moveit_visual_tools::MoveItVisualTools{ node, "base_link", rviz_visual_tools::RVIZ_MARKER_TOPIC,
32+
move_group_interface.getRobotModel() };
33+
moveit_visual_tools.deleteAllMarkers();
34+
moveit_visual_tools.loadRemoteControl();
35+
36+
// Create a closure for updating the text in rviz
37+
auto const draw_title = [&moveit_visual_tools](auto text) {
38+
auto const text_pose = [] {
39+
auto msg = Eigen::Isometry3d::Identity();
40+
msg.translation().z() = 1.0;
41+
return msg;
42+
}();
43+
moveit_visual_tools.publishText(text_pose, text, rviz_visual_tools::WHITE, rviz_visual_tools::XLARGE);
44+
};
45+
auto const prompt = [&moveit_visual_tools](auto text) { moveit_visual_tools.prompt(text); };
46+
auto const draw_trajectory_tool_path =
47+
[&moveit_visual_tools, jmg = move_group_interface.getRobotModel()->getJointModelGroup("manipulator")](
48+
auto const trajectory) { moveit_visual_tools.publishTrajectoryLine(trajectory, jmg); };
49+
50+
// Set a target Pose with updated values !!!
51+
auto const target_pose = [] {
52+
geometry_msgs::msg::Pose msg;
53+
msg.orientation.y = 0.8;
54+
msg.orientation.w = 0.6;
55+
msg.position.x = 0.1;
56+
msg.position.y = 0.4;
57+
msg.position.z = 0.4;
58+
return msg;
59+
}();
60+
move_group_interface.setPoseTarget(target_pose);
61+
62+
// Create collision object for the robot to avoid
63+
auto const collision_object = [frame_id = move_group_interface.getPlanningFrame()] {
64+
moveit_msgs::msg::CollisionObject collision_object;
65+
collision_object.header.frame_id = frame_id;
66+
collision_object.id = "box1";
67+
shape_msgs::msg::SolidPrimitive primitive;
68+
69+
// Define the size of the box in meters
70+
primitive.type = primitive.BOX;
71+
primitive.dimensions.resize(3);
72+
primitive.dimensions[primitive.BOX_X] = 0.5;
73+
primitive.dimensions[primitive.BOX_Y] = 0.1;
74+
primitive.dimensions[primitive.BOX_Z] = 0.5;
75+
76+
// Define the pose of the box (relative to the frame_id)
77+
geometry_msgs::msg::Pose box_pose;
78+
box_pose.orientation.w = 1.0;
79+
box_pose.position.x = 0.2;
80+
box_pose.position.y = 0.2;
81+
box_pose.position.z = 0.25;
82+
83+
collision_object.primitives.push_back(primitive);
84+
collision_object.primitive_poses.push_back(box_pose);
85+
collision_object.operation = collision_object.ADD;
86+
87+
return collision_object;
88+
}();
89+
90+
// Add the collision object to the scene
91+
moveit::planning_interface::PlanningSceneInterface planning_scene_interface;
92+
planning_scene_interface.applyCollisionObject(collision_object);
93+
94+
// Create a plan to that target pose
95+
prompt("Press 'next' in the RvizVisualToolsGui window to plan");
96+
draw_title("Planning");
97+
moveit_visual_tools.trigger();
98+
auto const [success, plan] = [&move_group_interface] {
99+
moveit::planning_interface::MoveGroupInterface::Plan msg;
100+
auto const ok = static_cast<bool>(move_group_interface.plan(msg));
101+
return std::make_pair(ok, msg);
102+
}();
103+
104+
// Execute the plan
105+
if (success)
106+
{
107+
draw_trajectory_tool_path(plan.trajectory);
108+
moveit_visual_tools.trigger();
109+
prompt("Press 'next' in the RvizVisualToolsGui window to execute");
110+
draw_title("Executing");
111+
moveit_visual_tools.trigger();
112+
move_group_interface.execute(plan);
113+
}
114+
else
115+
{
116+
draw_title("Planning Failed!");
117+
moveit_visual_tools.trigger();
118+
RCLCPP_ERROR(logger, "Planning failed!");
119+
}
120+
121+
// Shutdown ROS
122+
rclcpp::shutdown();
123+
spinner.join();
124+
return 0;
125+
}
File renamed without changes.
222 KB
Loading

doc/tutorials/planning_around_objects/planning_around_objects.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ This code block should directly follow the code block that creates the collision
100100

101101
Just as we did in the last tutorial, start RViz using the ``demo.launch.py`` script and run our program. If you're using one of the Docker tutorial containers, you can specify a different RViz configuration that already has the RvizVisualToolsGui panel added using: ::
102102

103-
ros2 launch moveit2_tutorials demo.launch.py rviz_config:=panda_hello_moveit.rviz
103+
ros2 launch moveit2_tutorials demo.launch.py rviz_config:=kinova_hello_moveit.rviz
104104

105105
.. image:: planning_around_object.png
106106

107107
Summary
108108
-------
109109

110110
- You extended the program you wrote with MoveIt to plan around an object in the scene.
111-
- :codedir:`Here is a copy of the full hello_moveit.cpp source<tutorials/planning_around_objects/hello_moveit.cpp>`.
111+
- :codedir:`Here is a copy of the full hello_moveit.cpp source<tutorials/planning_around_objects/hello_moveit_kinova.cpp>`.
112112

113113
Further Reading
114114
---------------

doc/tutorials/quickstart_in_rviz/launch/demo.launch.py

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def generate_launch_description():
1616
declared_arguments.append(
1717
DeclareLaunchArgument(
1818
"rviz_config",
19-
default_value="panda_moveit_config_demo.rviz",
19+
default_value="kinova_moveit_config_demo.rviz",
2020
description="RViz configuration file",
2121
)
2222
)
@@ -28,15 +28,24 @@ def generate_launch_description():
2828

2929
def launch_setup(context, *args, **kwargs):
3030

31+
launch_arguments = {
32+
"robot_ip": "xxx.yyy.zzz.www",
33+
"use_fake_hardware": "true",
34+
"gripper": "robotiq_2f_85",
35+
"dof": "7",
36+
}
37+
3138
moveit_config = (
32-
MoveItConfigsBuilder("moveit_resources_panda")
33-
.robot_description(file_path="config/panda.urdf.xacro")
34-
.trajectory_execution(file_path="config/gripper_moveit_controllers.yaml")
39+
MoveItConfigsBuilder(
40+
"gen3", package_name="kinova_gen3_7dof_robotiq_2f_85_moveit_config"
41+
)
42+
.robot_description(mappings=launch_arguments)
43+
.trajectory_execution(file_path="config/moveit_controllers.yaml")
3544
.planning_scene_monitor(
3645
publish_robot_description=True, publish_robot_description_semantic=True
3746
)
3847
.planning_pipelines(
39-
pipelines=["ompl", "chomp", "pilz_industrial_motion_planner"]
48+
pipelines=["ompl", "stomp", "pilz_industrial_motion_planner"]
4049
)
4150
.to_moveit_configs()
4251
)
@@ -76,7 +85,7 @@ def launch_setup(context, *args, **kwargs):
7685
executable="static_transform_publisher",
7786
name="static_transform_publisher",
7887
output="log",
79-
arguments=["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "world", "panda_link0"],
88+
arguments=["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "world", "base_link"],
8089
)
8190

8291
# Publish TF
@@ -90,7 +99,7 @@ def launch_setup(context, *args, **kwargs):
9099

91100
# ros2_control using FakeSystem as hardware
92101
ros2_controllers_path = os.path.join(
93-
get_package_share_directory("moveit_resources_panda_moveit_config"),
102+
get_package_share_directory("kinova_gen3_7dof_robotiq_2f_85_moveit_config"),
94103
"config",
95104
"ros2_controllers.yaml",
96105
)
@@ -106,8 +115,6 @@ def launch_setup(context, *args, **kwargs):
106115
executable="spawner",
107116
arguments=[
108117
"joint_state_broadcaster",
109-
"--controller-manager-timeout",
110-
"300",
111118
"--controller-manager",
112119
"/controller_manager",
113120
],
@@ -116,13 +123,13 @@ def launch_setup(context, *args, **kwargs):
116123
arm_controller_spawner = Node(
117124
package="controller_manager",
118125
executable="spawner",
119-
arguments=["panda_arm_controller", "-c", "/controller_manager"],
126+
arguments=["joint_trajectory_controller", "-c", "/controller_manager"],
120127
)
121128

122129
hand_controller_spawner = Node(
123130
package="controller_manager",
124131
executable="spawner",
125-
arguments=["panda_hand_controller", "-c", "/controller_manager"],
132+
arguments=["robotiq_gripper_controller", "-c", "/controller_manager"],
126133
)
127134
nodes_to_start = [
128135
rviz_node,

0 commit comments

Comments
 (0)