Skip to content
Snippets Groups Projects
Commit 924209b2 authored by Davis, Duane T's avatar Davis, Duane T
Browse files

LIB: Changed search order parser in bitmapped_bytes.py

Also fixed a ShortParser parsing error introduced in the last merge and
cleaned up some spacing in bitmapped_bytes.py and ap_enumerations.py
parent 63a57384
No related branches found
No related tags found
No related merge requests found
# autonomy-payload : a ROS-based stack for cooperative aerial robot autonomy
# swarm-autonomy : a ROS-based stack for cooperative aerial robot autonomy
## License
......@@ -16,19 +16,19 @@ A collection of ROS nodes for perception, path planning, safety monitoring, etc,
## Requirements
_Note: Typically this software is installed using a script (see deploy/odroid-installer.sh or the acs-installer repository). The following instructions won't generally be used and are only provided for reference._
This is currently being developed against ROS Indigo (Ubuntu 14.04) and Kinetic (Ubuntu 16.06) on an Ubuntu-esque system. For best compatibility, use Ubuntu 14.04 LTS or newer (Xubuntu, etc should be fine as well).
This is currently being developed against ROS Hydro on an Ubuntu-esque system. For best compatibility, use Ubuntu 12.04 LTS or newer (Xubuntu, etc should be fine as well).
_Note: Typically this software is installed using a script (see deploy/odroid-installer-14.04.sh, deploy/odroid-installer-16.04 or the acs-installer repository). The following instructions won't generally be used and are only provided for reference._
You will need the following ROS packages for your distribution:
sudo apt-get install ros-hydro-ros-base ros-hydro-sensor-msgs ros-hydro-robot-pose-ekf
sudo apt-get install ros-[distro]-ros-base ros-[distro]-sensor-msgs ros-[distro]-robot-pose-ekf
See your distribution's ROS documentation for install instructions. The short version, which generally works:
sudo rosdep init
rosdep update
echo "source /opt/ros/hydro/setup.bash" >> ~/.bashrc
echo "source /opt/ros/[distro]/setup.bash" >> ~/.bashrc
source /opt/ros/hydro/setup.bash
In addition, to interface with MAVLink-based autopilots, you will need:
......
......@@ -277,17 +277,16 @@ GAME_MODE_VALUES = { 'Inactive': GAME_INACTIVE,
# Battle Arena Parameters
BATTLE_CUBE_SW_LAT = 35.721147 # Latitude of the battle cube SW corner
BATTLE_CUBE_SW_LON = -120.773008 # Longitude of the battle cube SW corner
BATTLE_CUBE_LENGTH = 575 # N/S dimension (meters) of the battle cube
BATTLE_CUBE_WIDTH = 750 # E/W dimension (meters) of the battle cube
BATTLE_CUBE_ORIENT = 25.183537917993224
BATTLE_CUBE_MIN_ALT = 354 # Battle cube floor (meters MSL)
BATTLE_CUBE_MAX_ALT = 854 # Battle cube ceiling (meters MSL)
BATTLE_CUBE_LENGTH = 575 # N/S dimension (meters) of the battle cube
BATTLE_CUBE_WIDTH = 750 # E/W dimension (meters) of the battle cube
BATTLE_CUBE_ORIENT = 25.183537917993224 # Orientation (degrees) of the battle cube
BATTLE_CUBE_MIN_ALT = 354 # Battle cube floor (meters MSL)
BATTLE_CUBE_MAX_ALT = 854 # Battle cube ceiling (meters MSL)
BATTLE_CUBE_CTR_LAT, BATTLE_CUBE_CTR_LON = \
gps.gps_newpos(BATTLE_CUBE_SW_LAT, BATTLE_CUBE_SW_LON, \
math.radians(BATTLE_CUBE_ORIENT) + math.pi/2.0, \
BATTLE_CUBE_WIDTH / 2.0)
STAGE_CUBE_WIDTH = 200
BLUE_STAGE_SW_LAT = 35.721911488829534
BLUE_STAGE_SW_LON = -120.77501064637208
......
......@@ -197,7 +197,7 @@ class ShortParser(BitmappedBytes):
''' Sets parameter values from a bitmapped byte array
@param bytes: bitmapped byte array
'''
self.value = struct.unpack_from(type(self).fmt, bytes, 0)
self.value, = struct.unpack_from(type(self).fmt, bytes, 0)
class UShortParser(ShortParser):
......@@ -466,7 +466,7 @@ class BoxPatrolParser(BitmappedBytes):
class SearchOrderParser(BitmappedBytes):
''' Parser swarm search orders
'''
fmt = ">ffffBB"
fmt = ">fffff"
def __init__(self):
''' Initializes parameters with default values
......@@ -475,8 +475,7 @@ class SearchOrderParser(BitmappedBytes):
self.lon = 0.0
self.areaLength = 0.0
self.areaWidth = 0.0
self.masterID = 0
self.algorithmNumber = 0
self.areaOrientation = 0.0
def pack(self):
......@@ -485,16 +484,16 @@ class SearchOrderParser(BitmappedBytes):
'''
return struct.pack(type(self).fmt, self.lat, self.lon, \
self.areaLength, self.areaWidth, \
self.masterID, self.algorithmNumber)
self.areaOrientation)
def unpack(self, bytes):
''' Sets parameter values from a bitmapped byte array
@param bytes: bitmapped byte array
'''
self.lat, self.lon, self.areaLength, self.areaWidth, \
self.masterID, self.algorithmNumber = \
struct.unpack_from(type(self).fmt, bytes, 0)
self.lat, self.lon, \
self.areaLength, self.areaWidth, self.areaOrientation = \
struct.unpack_from(type(self).fmt, bytes, 0)
class SearchWaypointParser(VariableLengthBitmappedBytes):
......@@ -1020,7 +1019,6 @@ class WingmanParser(BitmappedBytes):
#------------------------------------------------
class AuctionSearchBasicAreaParser(BitmappedBytes):
'''
Parser for an AuctionSearch geobox message (specifies a rectangular box
......@@ -1036,12 +1034,14 @@ class AuctionSearchBasicAreaParser(BitmappedBytes):
self.width = 0
self.orientation = 0.0
def pack(self):
tupl = (int(self.latitude * 1e07), \
int(self.longitude * 1e07), \
int(self.length), int(self.width), self.orientation)
return struct.pack(type(self).fmt, *tupl)
def unpack(self, bytes):
fields = struct.unpack_from(type(self).fmt, bytes, 0)
self.latitude = fields[0] / 1e07
......@@ -1051,7 +1051,6 @@ class AuctionSearchBasicAreaParser(BitmappedBytes):
self.orientation = fields[4]
class NewAuctionParser(BitmappedBytes):
fmt = ">BB???"
......@@ -1062,14 +1061,15 @@ class NewAuctionParser(BitmappedBytes):
self.claim_next_cell= False
self.target_found = False
def pack(self):
return struct.pack(type(self).fmt, self.source_id, self.next_cell_id, self.search_auction, self.claim_next_cell, self.target_found)
def unpack(self, bytes):
self.source_id, self.next_cell_id, self.search_auction, self.claim_next_cell, self.target_found = struct.unpack_from(type(self).fmt, bytes, 0)
class AuctionSearchBidParser(BitmappedBytes):
fmt = '>BBbf'
......@@ -1079,14 +1079,15 @@ class AuctionSearchBidParser(BitmappedBytes):
self.bid_cell_id = 0
self.bid_value = 0.0
def pack(self):
return struct.pack(type(self).fmt, self.source_id, self.round_id, self.bid_cell_id, self.bid_value)
def unpack(self, bytes):
self.source_id, self.round_id, self.bid_cell_id, self.bid_value = struct.unpack_from(type(self).fmt, bytes, 0)
class AuctionSearchCellsParser(BitmappedBytes):
fmt_base = ">HHH"
fmt_base_sz = struct.calcsize(fmt_base)
......@@ -1098,6 +1099,7 @@ class AuctionSearchCellsParser(BitmappedBytes):
self.round_id = 0
self.cell_list = [ ] # format: [ [cell_id, cell_status, cell_owner, cell_cost], ... ]
def pack(self):
num_cells = len(self.cell_list)
tupl = (self.source_id, self.round_id, num_cells)
......@@ -1106,6 +1108,7 @@ class AuctionSearchCellsParser(BitmappedBytes):
fmt = type(self).fmt_base + num_cells * type(self).data_fmt.lstrip('>')
return struct.pack(fmt, *tupl)
def unpack(self, bytes):
[self.source_id, self.round_id, num_cells] = struct.unpack_from(type(self).fmt_base, bytes, 0)
self.cell_list = [ ]
......@@ -1115,12 +1118,3 @@ class AuctionSearchCellsParser(BitmappedBytes):
self.cell_list.append( [data[0], data[1], data[2], data[3]] )
offset += type(self).data_fmt_sz
'''
BONEYARD
'''
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment