Skip to content

Commit 4e7b3c1

Browse files
committed
Merged update
2 parents 98b3d99 + 2b413fa commit 4e7b3c1

3 files changed

Lines changed: 28 additions & 5 deletions

File tree

GEMstack/mathutils/dubins.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def derivative(self,x,u):
4444
right = [-fwd[1],fwd[0]]
4545
phi = u[1]
4646
d = u[0]
47-
return np.array([fwd[0]*d,fwd[1]*d,phi])
47+
return np.array([fwd[0]*d,fwd[1]*d,phi*d])
4848

4949

5050
class DubinsCarIntegrator(ControlSpace):

GEMstack/mathutils/transforms.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@ def vector_dist(v1, v2) -> float:
3636
"""Euclidean distance between two vectors"""
3737
return vo.distance(v1,v2)
3838

39+
def vector_dot(v1, v2) -> float:
40+
"""Dot product between two vectors"""
41+
return vo.dot(v1,v2)
42+
43+
def vector_cross(v1, v2) -> float:
44+
"""Cross product between two 2D vectors"""
45+
return vo.cross(v1,v2)
46+
3947
def vector2_angle(v1, v2 = None) -> float:
4048
"""find the ccw angle bewtween two 2d vectors"""
4149
if v2 is None:
@@ -123,3 +131,16 @@ def xy_to_lat_lon(x_east : float, y_north : float, lat_reference : float, lon_re
123131
# convert GNSS waypoints into local fixed frame reprented in x and y
124132
lat, lon = axy.xy2ll(x_east, y_north, lat_reference, lon_reference)
125133
return lat, lon
134+
135+
def quaternion_to_euler(x : float, y : float, z : float, w : float):
136+
t0 = +2.0 * (w * x + y * z)
137+
t1 = +1.0 - 2.0 * (x * x + y * y)
138+
roll = np.arctan2(t0, t1)
139+
t2 = +2.0 * (w * y - z * x)
140+
t2 = +1.0 if t2 > +1.0 else t2
141+
t2 = -1.0 if t2 < -1.0 else t2
142+
pitch = np.arcsin(t2)
143+
t3 = +2.0 * (w * z + x * y)
144+
t4 = +1.0 - 2.0 * (y * y + z * z)
145+
yaw = np.arctan2(t3, t4)
146+
return [roll, pitch, yaw]

GEMstack/onboard/interface/gem_hardware.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from .gem import *
22
from ...utils import settings
33
import math
4+
import time
45

56
# ROS Headers
67
import rospy
@@ -153,6 +154,7 @@ def subscribe_sensor(self, name, callback, type = None):
153154
if name == 'gnss':
154155
topic = self.ros_sensor_topics[name]
155156
if topic.endswith('inspva'):
157+
#GEM e2 uses Novatel GNSS
156158
if type is not None and (type is not Inspva and type is not GNSSReading):
157159
raise ValueError("GEMHardwareInterface GEM e2 only supports Inspva/GNSSReading for GNSS")
158160
if type is Inspva:
@@ -171,17 +173,17 @@ def callback_with_gnss_reading(inspva_msg: Inspva):
171173
callback(GNSSReading(pose,speed,inspva_msg.status))
172174
self.gnss_sub = rospy.Subscriber(topic, Inspva, callback_with_gnss_reading)
173175
else:
174-
#assume it's septentrio
176+
#assume it's septentrio on GEM e4
175177
if type is not None and (type is not INSNavGeod and type is not GNSSReading):
176178
raise ValueError("GEMHardwareInterface GEM e4 only supports INSNavGeod/GNSSReading for GNSS")
177179
if type is INSNavGeod:
178180
self.gnss_sub = rospy.Subscriber(topic, INSNavGeod, callback)
179181
else:
180182
def callback_with_gnss_reading(msg: INSNavGeod):
181183
pose = ObjectPose(ObjectFrameEnum.GLOBAL,
182-
t = 0,
183-
x=msg.longitude,
184-
y=msg.latitude,
184+
t=time.time(),
185+
x=math.degrees(msg.longitude), #Septentrio GNSS uses radians rather than degrees
186+
y=math.degrees(msg.latitude),
185187
z=msg.height,
186188
yaw=math.radians(msg.heading), #heading from north in degrees (TODO: maybe?? check this)
187189
roll=math.radians(msg.roll),

0 commit comments

Comments
 (0)