Loading...
Searching...
No Matches
vamp_state_space.py
1from ompl import base as ob
2import vamp
3
4
6 """Motion validator using VAMP collision checking"""
7
8 def __init__(
9 self, si: ob.SpaceInformation, env: vamp.Environment, robot: vamp.robot
10 ):
11 super().__init__(si)
12 self.env = env
13 self.robot = robot
14 self.dimension = robot.dimension()
15
16 def checkMotion(
17 self, s1: ob.RealVectorStateType, s2: ob.RealVectorStateType
18 ) -> bool:
19 config1 = s1[0 : self.dimension]
20 config2 = s2[0 : self.dimension]
21 return self.robot.validate_motion(config1, config2, self.env)
22
23
25 def __init__(
26 self, si: ob.SpaceInformation, env: vamp.Environment, robot: vamp.robot
27 ):
28 super().__init__(si)
29 self.env = env
30 self.robot = robot
31 self.dimension = robot.dimension()
32
33 def isValid(self, s: ob.RealVectorStateType) -> bool:
34 config = s[0 : self.dimension]
35 return self.robot.validate(config, self.env)
36
37
38def isStateValid(
39 s: ob.RealVectorStateType, env: vamp.Environment, robot: vamp.robot, dimension: int
40) -> bool:
41 """Check if a state is valid (collision-free)"""
42 config = s[0:dimension]
43 return robot.validate(config, env)
44
45
47 """State Space class using VAMP's robot methods"""
48
49 def __init__(self, robot: vamp.robot):
50 super().__init__(robot.dimension())
51 self.robot = robot
52 self.dimension = robot.dimension()
53 bounds = ob.RealVectorBounds(self.dimension)
54 upper_bounds = robot.upper_bounds()
55 lower_bounds = robot.lower_bounds()
56
57 for i in range(self.dimension):
58 bounds.setLow(i, lower_bounds[i])
59 bounds.setHigh(i, upper_bounds[i])
60 self.setBounds(bounds)
Abstract definition for a class checking the validity of motions – path segments between states....
The lower and upper bounds for an Rn space.
A state space representing Rn. The distance function is the L2 norm.
void setBounds(const RealVectorBounds &bounds)
Set the bounds of this state space. This defines the range of the space in which sampling is performe...
Abstract definition for a class checking the validity of states. The implementation of this class mus...