Skip to content

Commit

Permalink
#9 ros_handler now updates submitted table once it publishes a target
Browse files Browse the repository at this point in the history
  • Loading branch information
len0rd committed Feb 4, 2019
1 parent 030ea63 commit 080e958
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 158 deletions.
158 changes: 1 addition & 157 deletions server/src/dao/model/submitted_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class submitted_target:

def __init__(self, sqlRow=None, outgoingManualOrAutonomous=None, autonomous=None):

# initialize all the attributes to None
self.target = None
self.autonomous = None
self.type = None
Expand Down Expand Up @@ -47,163 +48,6 @@ def __init__(self, sqlRow=None, outgoingManualOrAutonomous=None, autonomous=None
if key in outDict:
setattr(self, key, outDict[key])



# @property
# def target(self):
# """
# Target Id this classification is being bundled into. Generally this is an internal
# only column managed by the DAO, but can be manually modified if needed. Classifications
# that are similar enough are placed into a 'target bin'. Since it is likely multiple images
# will be taken of each target, this prevents us from submitting multiple images of the same
# target to AUVSI.
# """
# return self._target

# @target.setter
# def target(self, target):
# self._target = target

# @property
# def autonomous(self):
# return self._autonomous

# @autonomous.setter
# def autonomous(self, autonomous):
# self._autonomous = autonomous

# @property
# def type(self):
# """
# Type of classification. AUVSI currently specifies three possible types:
# 'standard', 'off_axis' or 'emergent'. Type must equal one of these to be
# successfully inserted or modified in the table
# """
# return self._type

# @type.setter
# def type(self, type):
# self._type = type

# @property
# def crop_path(self):
# """
# crop_path references the absolute server path of the cropped image
# to use for submission.
# """
# return self._crop_path

# @crop_path.setter
# def crop_path(self, crop_path):
# self._crop_path = crop_path

# @property
# def latitude(self):
# """
# Geolocation latitude of the object
# """
# return self._latitude

# @latitude.setter
# def latitude(self, latitude):
# self._latitude = latitude

# @property
# def longitude(self):
# """
# Geolocation longitude of the object
# """
# return self._longitude

# @longitude.setter
# def longitude(self, longitude):
# self._longitude = longitude

# @property
# def orientation(self):
# """
# Orientation of the character/object. AUVSI currently specifies 8 possible orientations:
# 'N', 'NE', 'E', 'SE', 'S', 'SW', 'W' or 'NW'. Orientation must equal one of these to be
# successfully inserted or modified in the table.
# """
# return self._orientation

# @orientation.setter
# def orientation(self, orientation):
# self._orientation = orientation

# @property
# def shape(self):
# """
# Shape of the object for standar/off-axis types. AUVSI currently specifies 13 possible shapes:
# 'circle', 'semicircle', 'quarter_circle', 'triangle', 'square', 'rectangle', 'trapezoid', 'pentagon', 'hexagon', 'heptagon', 'octagon', 'star' or 'cross'.
# Shape must equal one of these to be successfully inserted or modified in the table.
# """
# return self._shape

# @shape.setter
# def shape(self, shape):
# self._shape = shape

# @property
# def background_color(self):
# """
# Background color of the object for standard/off-axis types. AUVSI currently specifies 10 possible colors:
# 'white', 'black', 'gray', 'red', 'blue', 'green', 'yellow', 'purple', 'brown' or 'orange'.
# Background_color must equal one of these to be successfully inserted or modified in the table
# """
# return self._background_color

# @background_color.setter
# def background_color(self, background_color):
# self._background_color = background_color

# @property
# def alphanumeric(self):
# """
# Alphanumeric within the target for standard/off-axis target types. At present AUVSI specifies that
# any uppercase alpha character or number may be within a target. Through in practice they have historicall
# only done alpha characters. Checking that this column is given/contains valid values is left to the user.
# """
# return self._alphanumeric

# @alphanumeric.setter
# def alphanumeric(self, alphanumeric):
# self._alphanumeric = alphanumeric

# @property
# def alphanumeric_color(self):
# """
# Color of the alphanumeric for a standard/off-axis type. Color specs are the same as background_color.
# Alphanumeric_color must be equal to one of the specified colors to be successfully inserted or modified in the table.
# """
# return self._alphanumeric_color

# @alphanumeric_color.setter
# def alphanumeric_color(self, alphanumeric_color):
# self._alphanumeric_color = alphanumeric_color

# @property
# def description(self):
# """
# Description of the emergent object.
# """
# return self._description

# @description.setter
# def description(self, description):
# self._description = description

# @property
# def submitted(self):
# """
# Status of the target (either 'pending' submission or 'submitted')
# """
# return self._submitted

# @submitted.setter
# def submitted(self, submitted):
# self._submitted = submitted

# TODO: this is hacky and i hate it
def allProps(self):
Expand Down
8 changes: 7 additions & 1 deletion server/src/dao/submitted_target_dao.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def upsertTarget(self, targetModel):

def getTarget(self, target, autonomous):
getTarget = """SELECT * FROM submitted_target
WHERE target = %s and autonomous = %s LIMIT 1;"""
WHERE target = %s AND autonomous = %s LIMIT 1;"""

selectedTarget = super(SubmittedTargetDAO, self).basicTopSelect(getTarget, (target, autonomous))
if selectedTarget is not None:
Expand Down Expand Up @@ -75,6 +75,12 @@ def getAllPendingTargets(self, autonomous=None):

return super(SubmittedTargetDAO, self).getResultsAsModelList(getTarget, inputParams)

def setTargetSubmitted(self, target_id, autonomous):
updateTarget = """UPDATE submitted_target SET submitted = 'submitted'
WHERE target = %s AND autonomous = %s RETURNING target;"""

return -1 != super(SubmittedTargetDAO, self).getResultingId(updateTarget, (target_id, autonomous))

def removeTarget(self, target, autonomous):
removeSql = "DELETE FROM submitted_target WHERE target = %s and autonomous = %s;"

Expand Down
2 changes: 2 additions & 0 deletions server/src/ros_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ def publishPendingTargets(self):
for target in pending:
imageMsg = self.targetToInteropMsg(target)
self.target_pub_.publish(imageMsg)

target_dao.setTargetSubmitted(target.target, target.autonomous)

else: # some debug printing
print("no targets pending")
Expand Down

0 comments on commit 080e958

Please sign in to comment.