-
Notifications
You must be signed in to change notification settings - Fork 1
/
resumedrive.txt
122 lines (108 loc) · 5.4 KB
/
resumedrive.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
///////////////
// ResumeDrive
// ------------
// a copy of BeginDrive but uses local data already
// in place from a previous drive that was stopped
/////////////////////////////////////////////////////
// environment variables. Don't touch!
set wheelsUp to false. // are we off the ground?
set currentSlopeType to 0. // 0 = level, 1 = upslope, 2 = downslope
set currentSlopeAngle to 0. // the degree of up/down pitch the rover is currently experiencing
set brakesOn to false. // braking recently activated or not
set lastBrake to -1. // when to let off the brakes
set currentSpeed to 0. // for various drive functions, the speed used can be any of the ones defined below
set currentOverSpeed to overSpeedCruise. // how fast we shouldn't be going, currently
set slopeAbortDelay to 0. // used to delay a slope abort event
set currentBrakeTime to cruiseSpeedBrakeTime. // current amount of braking time in seconds
clearscreen.
abort off.
if yesterday < time:day {
set recentLogList:add to "<" + time:calendar + ">".
log "<" + time:calendar + ">" to RoverLog.
}.
set recentLogList:add to "<" + time:clock + "> program using existing state".
log "<" + time:clock + "> program using existing state" to RoverLog.
// time to head for the waypoint
set target to waypointName + currentWaypoint.
set recentLogList:add to "<" + time:clock + "> target " + waypointName + currentWaypoint + " selected".
log "<" + time:clock + "> target " + waypointName + currentWaypoint + " selected" to RoverLog.
// let the program gather data on the target we just acquizired
wait 0.001.
set recentLogList:add to "<" + time:clock + "> driving " + round(target:distance, 2) + "m to " + waypointName + currentWaypoint.
log "<" + time:clock + "> driving " + round(target:distance, 2) + "m to " + waypointName + currentWaypoint to RoverLog.
brakes off.
lock wheelsteering to target.
set currentSpeed to cruiseSpeed.
lock wheelthrottle to currentspeed.
// only need to print the output screen once, in full, then we just change values
print "=================================================".
print "|---------------Rover Variables-----------------|".
print "| |".
print "| currentBrakeTime: 00.0 currentSpeed: 00.00 |".
print "| currentOverspeed: 00.0 currentSlopeType: 0 |".
print "| currentWaypoint: 0/0 brakeUseCount: 0 |".
print "| currentSlopeAngle: -00.00 abortDrive: False |".
print "| |".
print "|------------Environment Information------------|".
print "| |".
print "| Height over ground: 0.00m |".
print "| Surface speed: 0.00m/s |".
print "| Distance remaining to target: 0.00m |".
print "| ETA: 0h 0m |".
print "| |".
print "|--------------Recent Log Entries---------------|".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "| |".
print "|===============================================|".
print "Rover Driver v1.0 (c)Drew Kerman".
// only need to print the log once
set index to 0.
until index = maxLogEntries or index = recentLogList:length {
print recentLogList[index] at (2, logLineStart + index).
set index to index + 1.
}.
// let's not immediately hop into monitoring mode but give the slope detection time to smooth out
set rollOut to time:seconds.
until time:seconds - rollOut > driveMonitorWaitTime {
set upvec to up:vector.
set velvec to ship:velocity:surface:normalized.
set dp to vdot(velvec,upvec).
set currentSlopeAngle to 90 - arccos(dp).
wait 0.001.
print " " at (20,3).
print currentBrakeTime at (20,3).
print " " at (42,3).
print round(currentSpeed, 2) at (42,3).
print " " at (20,4).
print currentOverSpeed at (20,4).
wait 0.001.
print currentSlopeType at (46,4).
print currentWaypoint + "/" + numWaypoints at (19,5).
print brakeUseCount at (43,5).
print " " at (21,6).
print round(currentSlopeAngle, 2) at (21,6).
print " " at (22,10).
print round(alt:radar - groundHeight, 2) + "m" at (22,10).
wait 0.001.
print " " at (17,11).
print round(surfacespeed, 2) + "m/s" at (17,11).
print " " at (32,12).
print round(target:distance, 2) + "m" at (32,12).
}.
if autoWarp = true { set warp to 1. }.
run MonitorDrive.