Skip to content

Commit

Permalink
add comments to writeup around settings and FPS, add FPS calc to driv…
Browse files Browse the repository at this point in the history
…e_rover.py
  • Loading branch information
ryan-keenan committed May 26, 2017
1 parent 0d69000 commit a3a275f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
24 changes: 20 additions & 4 deletions code/drive_rover.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,31 @@ def __init__(self):
self.worldmap = np.zeros((200, 200, 3), dtype=np.float)
self.samples_pos = None # To store the actual sample positions
self.samples_found = 0 # To count the number of samples found
self.near_sample = False # Set to True if within reach of a rock sample
self.pick_up = False # Set to True to trigger rock pickup
self.near_sample = 0 # Will be set to telemetry value data["near_sample"]
self.picking_up = 0 # Will be set to telemetry value data["picking_up"]
self.send_pickup = False # Set to True to trigger rock pickup
# Initialize our rover
Rover = RoverState()

# Variables to track frames per second (FPS)
# Intitialize frame counter
frame_counter = 0
# Initalize second counter
second_counter = time.time()


# Define telemetry function for what to do with incoming data
@sio.on('telemetry')
def telemetry(sid, data):

global frame_counter, second_counter
frame_counter+=1
# Do a rough calculation of frames per second (FPS)
if (time.time() - second_counter) > 1:
print ("Current FPS: {}".format(frame_counter))
frame_counter = 0
second_counter = time.time()

if data:
global Rover
# Initialize / update Rover with current telemetry
Expand All @@ -100,10 +116,10 @@ def telemetry(sid, data):
send_control(commands, out_image_string1, out_image_string2)

# If in a state where want to pickup a rock send pickup command
if Rover.pick_up:
if Rover.send_pickup:
send_pickup()
# Reset Rover flags
Rover.pick_up = False
Rover.send_pickup = False
# In case of invalid telemetry, send null commands
else:

Expand Down
4 changes: 3 additions & 1 deletion code/supporting_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ def update_rover(Rover, data):
Rover.steer = np.float(data["steering_angle"])
# Near sample flag
Rover.near_sample = np.int(data["near_sample"])

# Picking up flag
Rover.picking_up = np.int(data["picking_up"])

print('speed =',Rover.vel, 'position =', Rover.pos, 'throttle =',
Rover.throttle, 'steer_angle =', Rover.steer, 'near_sample', Rover.near_sample, data["picking_up"])

Expand Down
2 changes: 2 additions & 0 deletions writeup_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ And another!

#### 2. Launching in autonomous mode your rover can navigate and map autonomously. Explain your results and how you might improve them in your writeup.

**Note: running the simulator with different choices of resolution and graphics quality may produce different results, particularly on different machines! Make a note of your simulator settings (resolution and graphics quality set on launch) and frames per second (FPS output to terminal by `drive_rover.py`) in your writeup when you submit the project so your reviewer can reproduce your results.**

Here I'll talk about the approach I took, what techniques I used, what worked and why, where the pipeline might fail and how I might improve it if I were going to pursue this project further.


Expand Down

0 comments on commit a3a275f

Please sign in to comment.