Skip to content

Commit

Permalink
navigator_robotx_comms: Add UAV replenishment message for 2024, other…
Browse files Browse the repository at this point in the history
… message fixups
  • Loading branch information
cbrxyz committed Nov 5, 2024
1 parent 522d1a3 commit 8fb04f3
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 26 deletions.
3 changes: 3 additions & 0 deletions NaviGator/utils/navigator_msgs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ find_package(catkin REQUIRED COMPONENTS
std_msgs
message_generation
geometry_msgs
geographic_msgs
genmsg
actionlib_msgs
actionlib
Expand Down Expand Up @@ -75,6 +76,7 @@ add_action_files(
generate_messages(
DEPENDENCIES
std_msgs
geographic_msgs
geometry_msgs
actionlib_msgs
sensor_msgs
Expand All @@ -83,6 +85,7 @@ generate_messages(
catkin_package(
CATKIN_DEPENDS
std_msgs
geographic_msgs
geometry_msgs
sensor_msgs
)
Expand Down
2 changes: 2 additions & 0 deletions NaviGator/utils/navigator_msgs/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<build_depend>actionlib</build_depend>
<build_depend>actionlib_msgs</build_depend>
<build_depend>actionlib_msgs</build_depend>
<build_depend>geographic_msgs</build_depend>
<build_depend>geometry_msgs</build_depend>
<build_depend>message_generation</build_depend>
<build_depend>message_runtime</build_depend>
Expand All @@ -19,6 +20,7 @@
<run_depend>actionlib</run_depend>
<run_depend>actionlib_msgs</run_depend>
<run_depend>std_msgs</run_depend>
<run_depend>geographic_msgs</run_depend>
<run_depend>geometry_msgs</run_depend>
<run_depend>message_runtime</run_depend>
<run_depend>actionlib_msgs</run_depend>
Expand Down
3 changes: 2 additions & 1 deletion NaviGator/utils/navigator_msgs/srv/MessageDetectDock.srv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
string color # color of docking bay R, G, B
string color # color of docking bay to park in ('R' for example)
int8 ams_status # 1=docking, 2=complete
int8 status_of_delivery # S = 'scanning', D = 'delivering'
---
string message
1 change: 1 addition & 0 deletions NaviGator/utils/navigator_msgs/srv/MessageFollowPath.srv
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
string entry_color # color of the entry buoy ('R' for example)
int8 finished # 1=in progress 2=completed
---
string message
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
int8 uav_status # 1=stowed, 2=deployed, 3=faulted
int8 item_status # 0=not picked up, 1=picked up, 2=delivered
string item_color # color of the item ('R' for example)
---
string message
12 changes: 3 additions & 9 deletions NaviGator/utils/navigator_msgs/srv/MessageUAVSearchReport.srv
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
string object1
float64 object1_latitude
string object1_n_s
float64 object1_longitude
string object1_e_w
string object1 # 'R' for the R pad, 'N' for the N pad
geographic_msgs/GeoPoint object1_location
string object2
float64 object2_latitude
string object2_n_s
float64 object2_longitude
string object2_e_w
geographic_msgs/GeoPoint object2_location
int8 uav_status # 1=manual, 2=autonomous, 3=faulted
---
string message
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
string[] buoy_array # list of buoys (R,G,B), up to three buoys
string circling_wildlife # which animal to circle ('P' for example (python))
bool clockwise # whether to circle clockwise or counter-clockwise
int8 number_of_circles # how many circles to do
---
string message
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
of messages for the RobotX Communication Protocol
"""

from __future__ import annotations

import math
from typing import Any, List, Optional, Tuple
from typing import Any

import tf.transformations as trans
from geographic_msgs.msg import GeoPoint
from mil_tools import rosmsg_to_numpy
from nav_msgs.msg import Odometry
from navigator_msgs.srv import (
Expand Down Expand Up @@ -50,7 +53,7 @@ def __init__(self):
self.message_id = "RXHRB"
self.timestamp_last = None

def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
def from_string(self, delim: bytes, string: str) -> tuple[list[str], list[str]]:
"""
From a message representing a message as a string, return the data and checksum
lists encoded in the string.
Expand All @@ -73,10 +76,10 @@ def to_string(
delim: str,
team_id: str,
edt_date_time: Any,
gps_array: Optional[Any],
odom: Optional[Odometry],
uav_status: Optional[int],
system_mode: Optional[int],
gps_array: Any,
odom: Odometry | None,
uav_status: int | None,
system_mode: int | None,
use_test_data: bool,
) -> str:
"""
Expand Down Expand Up @@ -176,7 +179,7 @@ class RobotXEntranceExitGateMessage:
def __init__(self):
self.message_id = "RXGAT"

def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
def from_string(self, delim: bytes, string: str) -> tuple[list[str], list[str]]:
"""
Constructs a list of data values and a checksum list from a provided message.
Expand Down Expand Up @@ -254,7 +257,7 @@ class RobotXFollowPathMessage:
def __init__(self):
self.message_id = "RXPTH"

def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
def from_string(self, delim: bytes, string: str) -> tuple[list[str], list[str]]:
"""
Constructs a list of data values and a checksum list from a provided message.
Expand Down Expand Up @@ -331,7 +334,7 @@ class RobotXWildlifeEncounterMessage:
def __init__(self):
self.message_id = "RXENC"

def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
def from_string(self, delim: bytes, string: str) -> tuple[list[str], list[str]]:
"""
Constructs a list of data values and a checksum list from a provided message.
Expand Down Expand Up @@ -411,7 +414,7 @@ class RobotXScanCodeMessage:
def __init__(self):
self.message_id = "RXCOD"

def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
def from_string(self, delim: bytes, string: str) -> tuple[list[str], list[str]]:
"""
Returns the information encoded in a message.
Expand Down Expand Up @@ -484,7 +487,7 @@ class RobotXDetectDockMessage:
def __init__(self):
self.message_id = "RXDOK"

def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
def from_string(self, delim: bytes, string: str) -> tuple[list[str], list[str]]:
"""
Constructs a list of data values and a checksum list from a provided message.
Expand Down Expand Up @@ -561,7 +564,7 @@ class RobotXFindFlingMessage:
def __init__(self):
self.message_id = "RXFLG"

def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
def from_string(self, delim: bytes, string: str) -> tuple[list[str], list[str]]:
"""
Constructs a list of data values and a checksum list from a provided message.
Expand Down Expand Up @@ -638,7 +641,7 @@ class RobotXUAVReplenishmentMessage:
def __init__(self):
self.message_id = "RXUAV"

def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
def from_string(self, delim: bytes, string: str) -> tuple[list[str], list[str]]:
"""
Constructs a list of data values and a checksum list from a provided message.
Expand Down Expand Up @@ -715,7 +718,7 @@ class RobotXUAVSearchReportMessage:
def __init__(self):
self.message_id = "RXSAR"

def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
def from_string(self, delim: bytes, string: str) -> tuple[list[str], list[str]]:
"""
Constructs a list of data values and a checksum list from a provided message.
Expand All @@ -732,6 +735,14 @@ def from_string(self, delim: bytes, string: str) -> Tuple[List[str], List[str]]:
checksum_list = string.split(b"*")
return data_list, checksum_list

def lat_lon_ns(self, point: GeoPoint) -> tuple[float, str, float, str]:
return (
abs(point.latitude),
"N" if point.latitude >= 0 else "S",
abs(point.longitude),
"E" if point.longitude >= 0 else "W",
)

def to_string(
self,
delim: str,
Expand All @@ -758,7 +769,10 @@ def to_string(
str: The encoded message.
"""

data = f"{self.message_id}{delim}{edt_date_time}{delim}{data.object1!s}{delim}{data.object1_latitude!s}{delim}{data.object1_n_s!s}{delim}{data.object1_longitude!s}{delim}{data.object1_e_w!s}{delim}{data.object2!s}{delim}{data.object2_latitude!s}{delim}{data.object2_n_s!s}{delim}{data.object2_longitude!s}{delim}{data.object2_e_w!s}{delim}{team_id}{delim}{data.uav_status!s}"
o1_lat, o1_ns, o1_lon, o1_ew = self.lat_lon_ns(data.object1_location)
o2_lat, o2_ns, o2_lon, o2_ew = self.lat_lon_ns(data.object2_location)

data = f"{self.message_id}{delim}{edt_date_time}{delim}{data.object1!s}{delim}{o1_lat!s}{delim}{o1_ns!s}{delim}{o1_lon!s}{delim}{o1_ew!s}{delim}{data.object2!s}{delim}{o2_lat!s}{delim}{o2_ns!s}{delim}{o2_lon!s}{delim}{o2_ew!s}{delim}{team_id}{delim}{data.uav_status!s}"

# test data
if use_test_data:
Expand Down

0 comments on commit 8fb04f3

Please sign in to comment.