15 transform = json.load(f)
19 position = [transform[
"Translation"][0] / 1000,
20 transform[
"Translation"][1] / 1000,
21 transform[
"Translation"][2] / 1000]
22 axis = (transform[
"Rotation"][
"Axis"][0], transform[
"Rotation"][
"Axis"][1], transform[
"Rotation"][
"Axis"][2])
23 orientation = tf.transformations.quaternion_about_axis(transform[
"Rotation"][
"Angle"], axis)
25 return cls(position, orientation)
29 position = [message.position.x,
32 orientation = [message.orientation.x,
33 message.orientation.y,
34 message.orientation.z,
35 message.orientation.w]
37 return cls(position, orientation)
41 Get the inverse of the pose. 43 translation = tf.transformations.translation_matrix(self.
position)
44 rotation = tf.transformations.quaternion_matrix(self.
orientation)
45 transform = tf.transformations.concatenate_matrices(translation, rotation)
47 inverse_transform = tf.transformations.inverse_matrix(transform)
48 translation = tf.transformations.translation_from_matrix(inverse_transform)
49 rotation = tf.transformations.quaternion_from_matrix(inverse_transform)
51 return Pose(translation, rotation)
53 def equals(self, other, tolerance=0.001):
55 Check whether this pose is equal to another one. The poses are 56 considered equal, when all of the entries are within the given tolerance 59 for a, b
in zip(self.
position, other.position):
60 if abs(a - b) > tolerance:
62 for a, b
in zip(self.
orientation, other.orientation):
63 if abs(a - b) > tolerance:
75 return cls(message.x, message.y)
78 return math.sqrt((self.
x - other.x) ** 2 + (self.
y - other.y) ** 2)
80 def equals(self, other, tolerance=1):
82 Check whether the points are the same, up to the given distance. 94 return self.
x * other_point.x + self.
y * other_point.y + self.
z * other_point.z
104 lower = [message.lower.x, message.lower.y, message.lower.z]
105 upper = [message.upper.x, message.upper.y, message.upper.z]
107 return cls(lower, upper)
110 message.lower.x = self.
lower[0]
111 message.lower.y = self.
lower[1]
112 message.lower.z = self.
lower[2]
114 message.upper.x = self.
upper[0]
115 message.upper.y = self.
upper[1]
116 message.upper.z = self.
upper[2]
125 for a, b
in zip(self.
lower, other.lower):
126 if abs(a - b) > tolerance:
128 for a, b
in zip(self.
upper, other.upper):
129 if abs(a - b) > tolerance:
def equals(self, other, tolerance=0)
def write_to_message(self, message)
def __init__(self, x=0, y=0, z=0)
def equals(self, other, tolerance=0.001)
def distance_to(self, other)
def equals(self, other, tolerance=1)
def dot_prod(self, other_point)
def from_message(cls, message)
def __init__(self, lower, upper)
def from_message(cls, message)
def __init__(self, position, orientation)
def from_message(cls, message)