Skip to content

Commit

Permalink
fix time to nano-seconds conversion routines
Browse files Browse the repository at this point in the history
  • Loading branch information
schaubh committed Oct 31, 2023
1 parent a9c47c9 commit ad9090e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/BskSim/scenarios/scenario_AttModes.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def runScenario(scenario):
attitudeModeTime = macros.min2nano(10.)
attitudeMode = ["hillPoint", "inertial3D"]

currentSimulationTime = 0.
currentSimulationTime = 0
while currentSimulationTime < simulationTime:

# Configure alternating FSW mode
Expand Down
11 changes: 8 additions & 3 deletions src/utilities/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,30 @@

import math


# function to convert seconds to an integer nanoseconds value
def sec2nano(time):
"""convert seconds to nano-seconds"""
return int(time*1E9+0.5)


# function to convert minutes to an integer nanoseconds value
def min2nano(time):
"convert minutes to nano-seconds"
return int((time*1E9+0.5)*60)
return int(time*1E9*60 + 0.5)


# function to convert hours to an integer nanoseconds value
def hour2nano(time):
"""convert hours to nano-seconds"""
return int((time*1E9+0.5)*60*60)
return int(time*1E9*60*60 + 0.5)


# function to convert days to an integer nanoseconds value
def day2nano(time):
"""convert days to nano-seconds"""
return int((time*1E9+0.5)*60*60*24)
return int(time*1E9*60*60*24 + 0.5)


# variable to convert nano-seconds to seconds
NANO2SEC = 1E-9
Expand Down

0 comments on commit ad9090e

Please sign in to comment.