|
1 | 1 | #include "models.h"
|
2 |
| -#include <moveit/robot_model/robot_model.h> |
| 2 | +#include <moveit/utils/robot_model_test_utils.h> |
3 | 3 | #include <moveit/robot_model_loader/robot_model_loader.h>
|
4 |
| -#include <urdf_parser/urdf_parser.h> |
5 | 4 |
|
6 | 5 | using namespace moveit::core;
|
7 |
| -namespace { |
8 |
| - |
9 |
| -const std::string R_MODEL0 = "<?xml version=\"1.0\" ?>" |
10 |
| - "<robot name=\"one_robot\">" |
11 |
| - "<link name=\"base_link\">" |
12 |
| - " <inertial>" |
13 |
| - " <mass value=\"2.81\"/>" |
14 |
| - " <origin rpy=\"0 0 0\" xyz=\"0.0 0.0 .0\"/>" |
15 |
| - " <inertia ixx=\"0.1\" ixy=\"-0.2\" ixz=\"0.5\" iyy=\"-.09\" iyz=\"1\" izz=\"0.101\"/>" |
16 |
| - " </inertial>" |
17 |
| - " <collision name=\"my_collision\">" |
18 |
| - " <origin rpy=\"0 0 0\" xyz=\"0 0 0\"/>" |
19 |
| - " <geometry>" |
20 |
| - " <box size=\"1 2 1\" />" |
21 |
| - " </geometry>" |
22 |
| - " </collision>" |
23 |
| - " <visual>" |
24 |
| - " <origin rpy=\"0 0 0\" xyz=\"0.0 0 0\"/>" |
25 |
| - " <geometry>" |
26 |
| - " <box size=\"1 2 1\" />" |
27 |
| - " </geometry>" |
28 |
| - " </visual>" |
29 |
| - "</link>" |
30 |
| - "<joint name=\"joint_a\" type=\"continuous\">" |
31 |
| - " <axis xyz=\"0 0 1\"/>" |
32 |
| - " <parent link=\"base_link\"/>" |
33 |
| - " <child link=\"link_a\"/>" |
34 |
| - " <origin rpy=\" 0.0 0 0 \" xyz=\"0.0 0 0 \"/>" |
35 |
| - "</joint>" |
36 |
| - "<link name=\"link_a\">" |
37 |
| - " <inertial>" |
38 |
| - " <mass value=\"1.0\"/>" |
39 |
| - " <origin rpy=\"0 0 0\" xyz=\"0.0 0.0 .0\"/>" |
40 |
| - " <inertia ixx=\"0.1\" ixy=\"-0.2\" ixz=\"0.5\" iyy=\"-.09\" iyz=\"1\" izz=\"0.101\"/>" |
41 |
| - " </inertial>" |
42 |
| - " <collision>" |
43 |
| - " <origin rpy=\"0 0 0\" xyz=\"0 0 0\"/>" |
44 |
| - " <geometry>" |
45 |
| - " <box size=\"1 2 1\" />" |
46 |
| - " </geometry>" |
47 |
| - " </collision>" |
48 |
| - " <visual>" |
49 |
| - " <origin rpy=\"0 0 0\" xyz=\"0.0 0 0\"/>" |
50 |
| - " <geometry>" |
51 |
| - " <box size=\"1 2 1\" />" |
52 |
| - " </geometry>" |
53 |
| - " </visual>" |
54 |
| - "</link>" |
55 |
| - "<joint name=\"joint_b\" type=\"fixed\">" |
56 |
| - " <parent link=\"link_a\"/>" |
57 |
| - " <child link=\"link_b\"/>" |
58 |
| - " <origin rpy=\" 0.0 -0.42 0 \" xyz=\"0.0 0.5 0 \"/>" |
59 |
| - "</joint>" |
60 |
| - "<link name=\"link_b\">" |
61 |
| - " <inertial>" |
62 |
| - " <mass value=\"1.0\"/>" |
63 |
| - " <origin rpy=\"0 0 0\" xyz=\"0.0 0.0 .0\"/>" |
64 |
| - " <inertia ixx=\"0.1\" ixy=\"-0.2\" ixz=\"0.5\" iyy=\"-.09\" iyz=\"1\" izz=\"0.101\"/>" |
65 |
| - " </inertial>" |
66 |
| - " <collision>" |
67 |
| - " <origin rpy=\"0 0 0\" xyz=\"0 0 0\"/>" |
68 |
| - " <geometry>" |
69 |
| - " <box size=\"1 2 1\" />" |
70 |
| - " </geometry>" |
71 |
| - " </collision>" |
72 |
| - " <visual>" |
73 |
| - " <origin rpy=\"0 0 0\" xyz=\"0.0 0 0\"/>" |
74 |
| - " <geometry>" |
75 |
| - " <box size=\"1 2 1\" />" |
76 |
| - " </geometry>" |
77 |
| - " </visual>" |
78 |
| - "</link>" |
79 |
| - " <joint name=\"joint_c\" type=\"prismatic\">" |
80 |
| - " <axis xyz=\"1 0 0\"/>" |
81 |
| - " <limit effort=\"100.0\" lower=\"0.0\" upper=\"0.09\" velocity=\"0.2\"/>" |
82 |
| - " <safety_controller k_position=\"20.0\" k_velocity=\"500.0\" soft_lower_limit=\"0.0\" " |
83 |
| - "soft_upper_limit=\"0.089\"/>" |
84 |
| - " <parent link=\"link_b\"/>" |
85 |
| - " <child link=\"link_c\"/>" |
86 |
| - " <origin rpy=\" 0.0 0.42 0.0 \" xyz=\"0.0 -0.1 0 \"/>" |
87 |
| - " </joint>" |
88 |
| - "<link name=\"link_c\">" |
89 |
| - " <inertial>" |
90 |
| - " <mass value=\"1.0\"/>" |
91 |
| - " <origin rpy=\"0 0 0\" xyz=\"0.0 0 .0\"/>" |
92 |
| - " <inertia ixx=\"0.1\" ixy=\"-0.2\" ixz=\"0.5\" iyy=\"-.09\" iyz=\"1\" izz=\"0.101\"/>" |
93 |
| - " </inertial>" |
94 |
| - " <collision>" |
95 |
| - " <origin rpy=\"0 0 0\" xyz=\"0 0 0\"/>" |
96 |
| - " <geometry>" |
97 |
| - " <box size=\"1 2 1\" />" |
98 |
| - " </geometry>" |
99 |
| - " </collision>" |
100 |
| - " <visual>" |
101 |
| - " <origin rpy=\"0 0 0\" xyz=\"0.0 0 0\"/>" |
102 |
| - " <geometry>" |
103 |
| - " <box size=\"1 2 1\" />" |
104 |
| - " </geometry>" |
105 |
| - " </visual>" |
106 |
| - "</link>" |
107 |
| - " <joint name=\"mim_f\" type=\"prismatic\">" |
108 |
| - " <axis xyz=\"1 0 0\"/>" |
109 |
| - " <limit effort=\"100.0\" lower=\"0.0\" upper=\"0.19\" velocity=\"0.2\"/>" |
110 |
| - " <parent link=\"link_c\"/>" |
111 |
| - " <child link=\"link_d\"/>" |
112 |
| - " <origin rpy=\" 0.0 0.1 0.0 \" xyz=\"0.1 0.1 0 \"/>" |
113 |
| - " <mimic joint=\"joint_f\" multiplier=\"1.5\" offset=\"0.1\"/>" |
114 |
| - " </joint>" |
115 |
| - " <joint name=\"joint_f\" type=\"prismatic\">" |
116 |
| - " <axis xyz=\"1 0 0\"/>" |
117 |
| - " <limit effort=\"100.0\" lower=\"0.0\" upper=\"0.19\" velocity=\"0.2\"/>" |
118 |
| - " <parent link=\"link_d\"/>" |
119 |
| - " <child link=\"link_e\"/>" |
120 |
| - " <origin rpy=\" 0.0 0.1 0.0 \" xyz=\"0.1 0.1 0 \"/>" |
121 |
| - " </joint>" |
122 |
| - "<link name=\"link_d\">" |
123 |
| - " <collision>" |
124 |
| - " <origin rpy=\"0 0 0\" xyz=\"0 0 0\"/>" |
125 |
| - " <geometry>" |
126 |
| - " <box size=\"1 2 1\" />" |
127 |
| - " </geometry>" |
128 |
| - " </collision>" |
129 |
| - " <visual>" |
130 |
| - " <origin rpy=\"0 1 0\" xyz=\"0 0.1 0\"/>" |
131 |
| - " <geometry>" |
132 |
| - " <box size=\"1 2 1\" />" |
133 |
| - " </geometry>" |
134 |
| - " </visual>" |
135 |
| - "</link>" |
136 |
| - "<link name=\"link_e\">" |
137 |
| - " <collision>" |
138 |
| - " <origin rpy=\"0 0 0\" xyz=\"0 0 0\"/>" |
139 |
| - " <geometry>" |
140 |
| - " <box size=\"1 2 1\" />" |
141 |
| - " </geometry>" |
142 |
| - " </collision>" |
143 |
| - " <visual>" |
144 |
| - " <origin rpy=\"0 1 0\" xyz=\"0 0.1 0\"/>" |
145 |
| - " <geometry>" |
146 |
| - " <box size=\"1 2 1\" />" |
147 |
| - " </geometry>" |
148 |
| - " </visual>" |
149 |
| - "</link>" |
150 |
| - "</robot>"; |
151 |
| - |
152 |
| -const std::string S_MODEL0 = |
153 |
| - "<?xml version=\"1.0\" ?>" |
154 |
| - "<robot name=\"one_robot\">" |
155 |
| - "<virtual_joint name=\"base_joint\" child_link=\"base_link\" parent_frame=\"odom_combined\" type=\"planar\"/>" |
156 |
| - "<group name=\"base_from_joints\">" |
157 |
| - "<joint name=\"base_joint\"/>" |
158 |
| - "<joint name=\"joint_a\"/>" |
159 |
| - "<joint name=\"joint_c\"/>" |
160 |
| - "</group>" |
161 |
| - "<group name=\"mim_joints\">" |
162 |
| - "<joint name=\"joint_f\"/>" |
163 |
| - "<joint name=\"mim_f\"/>" |
164 |
| - "</group>" |
165 |
| - "<group name=\"base_with_subgroups\">" |
166 |
| - "<group name=\"base_from_base_to_tip\"/>" |
167 |
| - "<joint name=\"joint_c\"/>" |
168 |
| - "</group>" |
169 |
| - "<group name=\"base_from_base_to_tip\">" |
170 |
| - "<chain base_link=\"base_link\" tip_link=\"link_b\"/>" |
171 |
| - "<joint name=\"base_joint\"/>" |
172 |
| - "</group>" |
173 |
| - "<group name=\"base_with_bad_subgroups\">" |
174 |
| - "<group name=\"error\"/>" |
175 |
| - "</group>" |
176 |
| - "<end_effector name=\"eef\" parent_link=\"link_b\" group=\"mim_joints\" parent_group=\"base_from_base_to_tip\"/>" |
177 |
| - "</robot>"; |
178 |
| -} // namespace |
179 | 6 |
|
180 | 7 | RobotModelPtr getModel() {
|
181 |
| - urdf::ModelInterfaceSharedPtr urdf_model = urdf::parseURDF(R_MODEL0); |
182 |
| - srdf::ModelSharedPtr srdf_model(new srdf::Model()); |
183 |
| - srdf_model->initString(*urdf_model, S_MODEL0); |
184 |
| - return RobotModelPtr(new RobotModel(urdf_model, srdf_model)); |
| 8 | + // suppress RobotModel errors and warnings |
| 9 | + ros::console::set_logger_level(ROSCONSOLE_ROOT_LOGGER_NAME ".moveit_core.robot_model", ros::console::levels::Fatal); |
| 10 | + |
| 11 | + // create dummy robot model |
| 12 | + moveit::core::RobotModelBuilder builder("robot", "base"); |
| 13 | + builder.addChain("base->link1->link2->tip", "continuous"); |
| 14 | + builder.addGroupChain("base", "link2", "group"); |
| 15 | + builder.addGroupChain("link2", "tip", "eef_group"); |
| 16 | + builder.addEndEffector("eef", "link2", "group", "eef_group"); |
| 17 | + return builder.build(); |
185 | 18 | }
|
186 | 19 |
|
187 | 20 | moveit::core::RobotModelPtr loadModel() {
|
|
0 commit comments