Skip to content

Commit

Permalink
proper handling of date/time for taken pictures
Browse files Browse the repository at this point in the history
  • Loading branch information
martind committed Mar 2, 2015
1 parent bd8fad4 commit 2df80fd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 2 deletions.
15 changes: 15 additions & 0 deletions apyros/metalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,20 @@ def createLoggedInput( self, prefix, function ):
self.f.flush()
return SourceLogger( function, filename )

def now( self ):
"get logged datetime"
if self. replay:
dt = None
for line in self.f:
print "LINE", line.strip()
if line.startswith( "now:" ):
dt = eval(line[4:].strip())
break
else:
dt = datetime.datetime.now()
self.f.write( "now: " + repr(dt) + "\n")
self.f.flush()
return dt

# vim: expandtab sw=4 ts=4

7 changes: 5 additions & 2 deletions bebop.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ def update( self, cmd ):

def config( self ):
# initial cfg
dt = self.metalog.now()
self.update( cmd=setDateCmd( date=dt.date() ) )
self.update( cmd=setTimeCmd( time=dt.time() ) )
self.update( videoAutorecordingCmd( enabled=True ) )


Expand Down Expand Up @@ -312,8 +315,8 @@ def testVideoProcessing( robot ):
# testEmergency( robot )
# testTakeoff( robot )
# testManualControlException( robot )
# testTakePicture( robot )
testFlying( robot )
testTakePicture( robot )
# testFlying( robot )
# testVideoProcessing( robot )
print "Battery:", robot.battery

Expand Down
16 changes: 16 additions & 0 deletions commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,5 +69,21 @@ def videoRecording( on=True ):
return struct.pack("BBHBB", 1, 7, 1, 0, massStorageId)


def setDateCmd( date ):
# ARCOMMANDS_ID_PROJECT_COMMON = 0,
# ARCOMMANDS_ID_COMMON_CLASS_COMMON = 4,
# ARCOMMANDS_ID_COMMON_COMMON_CMD_CURRENTDATE = 1,
# Date with ISO-8601 format
return struct.pack("BBH", 0, 4, 1) + date.isoformat() + '\0'

def setTimeCmd( time ):
# ARCOMMANDS_ID_PROJECT_COMMON = 0,
# ARCOMMANDS_ID_COMMON_CLASS_COMMON = 4,
# ARCOMMANDS_ID_COMMON_COMMON_CMD_CURRENTTIME = 2,
# Time with ISO-8601 format
# note, that "time.isoformat()" did not work '19:39:22.887000' milisec??
return struct.pack("BBH", 0, 4, 2) + time.strftime("T%H%M%S+0000") + '\0'


# vim: expandtab sw=4 ts=4

4 changes: 4 additions & 0 deletions navdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def parseData( data, robot, verbose=False ):
robot.battery = battery
if verbose:
print "Battery", battery
elif (commandProject, commandClass, commandId) == (0,5,4):
print "Date:", data[11:frameSize-1]
elif (commandProject, commandClass, commandId) == (0,5,5):
print "Time:", data[11:frameSize-1]
elif (commandProject, commandClass) == (0,14):
# ARCOMMANDS_ID_COMMON_CLASS_CALIBRATIONSTATE = 14,
if commandId == 0:
Expand Down

0 comments on commit 2df80fd

Please sign in to comment.