forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SE3MotionPlanningTree.m
81 lines (70 loc) · 2.46 KB
/
SE3MotionPlanningTree.m
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
classdef SE3MotionPlanningTree < CompositeVertexArrayTree
properties
rbm
min_distance = 0.2;
end
methods
function obj = SE3MotionPlanningTree()
T_R3 = R3MotionPlanningTree();
T_SO3 = SO3MotionPlanningTree();
obj = obj@CompositeVertexArrayTree({T_R3, T_SO3},{'R3', 'SO3'});
obj = obj.setLCMGL('SE3MotionPlanningTree',[0, 0, 0]);
urdf = fullfile(getDrakePath, 'systems', 'plants', 'test', 'FallingBrick.urdf');
options.floating = true;
obj.rbm = RigidBodyManipulator(urdf, options);
obj.rbm = obj.rbm.removeCollisionGroupsExcept({});
% TODO: Switch to something like the below.
%obj.rbm = RigidBodyManipulator();
%obj.rbm.name{1} = 'robot';
%body = RigidBody();
%body = body.setInertial(1, zeros(3,1), eye(3));
%body.linkname = 'body';
%body.robotnum = 1;
%obj.rbm = obj.rbm.addLink(body);
%obj.rbm = obj.rbm.addFloatingBase(1, 2, [0;0;0], [0;0;0],'quat');
%obj.rbm = obj.rbm.addFloatingBase(1, 2, [0;0;0], [0;0;0]);
obj = obj.compile();
end
function obj = compile(obj)
obj.rbm = obj.rbm.compile();
end
function valid = checkConstraints(obj, q)
valid = checkConstraints@CompositeVertexArrayTree(obj, q);
valid = valid && obj.isCollisionFree(q);
end
function valid = isCollisionFree(obj, q)
xyz = q(1:3);
quat = q(4:7);
rpy = quat2rpy(quat);
phi = obj.rbm.collisionDetect([xyz; rpy]);
valid = all(phi > obj.min_distance);
end
function obj = addGeometryToRobot(obj, geom)
obj.rbm = obj.rbm.addGeometryToBody(2, geom);
end
function obj = addGeometryToWorld(obj, geom)
obj.rbm = obj.rbm.addGeometryToBody(1, geom);
end
function obj = setOrientationWeight(obj, orientation_weight)
obj.weights(2) = orientation_weight;
end
function obj = setTranslationSamplingBounds(obj, lb, ub)
obj.trees{1}.sampling_lb = lb;
obj.trees{1}.sampling_ub = ub;
end
function obj = setLCMGL(obj, varargin)
obj = setLCMGL@CompositeVertexArrayTree(obj, varargin{:});
obj.trees{1} = obj.trees{1}.setLCMGL(varargin{:});
end
function obj = drawTree(obj, varargin)
obj.trees{1}.drawTree(varargin{:});
end
function drawPath(objA, path_ids_A, objB, path_ids_B)
if nargin > 2
drawPath(objA.trees{1}, path_ids_A, objB.trees{1}, path_ids_B);
else
drawPath(objA.trees{1}, path_ids_A);
end
end
end
end