Skip to content

Commit db5f3c1

Browse files
Ability to set a robot_description that is not within the drake_models package (#69)
* Ability to set a robot_description that is not within the drake_models package * Fix typo * Add instructions on how to use external_robot_description to the README
1 parent 047dfd3 commit db5f3c1

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

Diff for: README.md

+18
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,24 @@ ros2 launch moveit_drake constrained_planning_demo.launch.py
8585
```
8686

8787

88+
## Configuration
89+
90+
### Use another robot
91+
92+
By default, Drake uses descriptions located within the [drake_models](https://github.com/RobotLocomotion/models) package. Modify the `drake_robot_description` parameter if you want to use a different description:
93+
```yaml
94+
drake_robot_description: "package://drake_models/pr2_description/urdf/pr2_simplified.urdf"
95+
```
96+
97+
In case you want to use other robots, you can specify the global path to the description package using the `external_robot_description` parameter:
98+
```yaml
99+
external_robot_description: ["/home/user/xarm_ws/src/xarm_ros2/xarm_description"]
100+
```
101+
Drake will crawl down the directory tree starting at the given path. You can also specify multiple paths in the array.
102+
103+
If you already provide the transform `world->base_frame` you might also want to leave the parameter `base_frame` empty.
104+
105+
88106
## Development
89107

90108
### Formatting

Diff for: parameters/ktopt_moveit_parameters.yaml

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@ ktopt_interface:
44
description: "Robot description to be loaded by the internal Drake MultibodyPlant.",
55
default_value: "package://drake_models/franka_description/urdf/panda_arm_hand.urdf",
66
}
7+
external_robot_description: {
8+
type: string_array,
9+
description: "If your robot description is not available within the drake_models package, you can specify an array of global paths to search for the URDFs.",
10+
default_value: [],
11+
}
712
base_frame: {
813
type: string,
9-
description: "Base frame of the robot that is attached to whatever the robot is mounted on.",
14+
description: "Base frame of the robot that is attached to whatever the robot is mounted on. Leave it empty in case you already provide the transform.",
1015
default_value: "panda_link0",
1116
}
1217
num_iterations: {

Diff for: src/ktopt_planning_context.cpp

+8-3
Original file line numberDiff line numberDiff line change
@@ -371,10 +371,15 @@ void KTOptPlanningContext::setRobotDescription(const std::string& robot_descript
371371

372372
// Drake cannot handle stl files, so we convert them to obj. Make sure these files are available in your moveit config!
373373
const auto description_with_obj = moveit::drake::replaceSTLWithOBJ(robot_description);
374-
auto robot_instance =
375-
drake::multibody::Parser(&plant, &scene_graph).AddModelsFromString(description_with_obj, ".urdf");
374+
auto robot_instance = drake::multibody::Parser(&plant, &scene_graph);
376375

377-
plant.WeldFrames(plant.world_frame(), plant.GetFrameByName(params_.base_frame));
376+
for (const auto& path : params_.external_robot_description)
377+
robot_instance.package_map().PopulateFromFolder(path);
378+
379+
robot_instance.AddModelsFromString(description_with_obj, ".urdf");
380+
381+
if (!params_.base_frame.empty())
382+
plant.WeldFrames(plant.world_frame(), plant.GetFrameByName(params_.base_frame));
378383

379384
// planning scene transcription
380385
const auto scene = getPlanningScene();

0 commit comments

Comments
 (0)