Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Published Topics:
/aruco_boards (interfaces.msg.ArucoBoard)
Pose of detected ArUco boards
/aruco_debug (sensor_msgs.msg.Image)
Debug image with detected boards and axes drawn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
Published Topics:
/camera/image_raw (sensor_msgs.msg.Image)
Raw camera images

/camera/camera_info (sensor_msgs.msg.CameraInfo)
Camera calibration information

Expand Down
41 changes: 29 additions & 12 deletions src/Nav/gps/gps/antenna_pointing_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ def __init__(self):
self.zero_offset = 0
self.calibrated = False

# manual mode
self.manual_value = 0
self.manual = False
self.create_subscription(Bool, "/antenna/manual", self.manual_cb, 10)
self.create_subscription(
Float32, "/antenna/manual_value", self.manual_value_cb, 10
)

# ROS things
self.create_subscription(NavSatFix, "/base_station/fix", self.base_cb, 10)
self.create_subscription(NavSatFix, "/gps/fix", self.rover_cb, 10)
Expand All @@ -38,22 +46,31 @@ def base_cb(self, msg):
def rover_cb(self, msg):
self.rover_fix = msg

def update(self):
if self.svin_valid == -2 or not self.base_fix or not self.rover_fix:
return
def manual_cb(self, msg):
self.manual = msg.data

# ----- HANDLE IMU HERE
def manual_value_cb(self, msg):
self.manual_value = msg.data

# ----- HANDLE CALIBRATION HERE (maybe)
def update(self):

bearing = self.bearing(
self.base_fix.latitude,
self.base_fix.longitude,
self.rover_fix.latitude,
self.rover_fix.longitude,
)
# ----- HANDLE CALIBRATION HERE (maybe)

self.publish_bearing(bearing)
# if not manual, proceed as usual
if not self.manual:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From a pure teaching perspective:
The code is more readable to flip this check and a early return for the manual code path. Keeps indentation bloat down and reduces the cognitive complexity of the inverted logic ("is not" is usually marginally harder to reason than is)

if self.svin_valid == -2 or not self.base_fix or not self.rover_fix:
return

bearing = self.bearing(
self.base_fix.latitude,
self.base_fix.longitude,
self.rover_fix.latitude,
self.rover_fix.longitude,
)

self.publish_bearing(bearing)
else: # is manual mode
self.publish_bearing(self.manual_value)

def publish_bearing(self, bearing):
msg = Float32()
Expand Down
Loading