Skip to content

Commit

Permalink
update rover_coords()
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan-keenan committed Jun 5, 2017
1 parent dbbfd81 commit 04c52c6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 9 additions & 8 deletions code/Rover_Project_Test_Notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -5795,13 +5795,14 @@
{
"cell_type": "code",
"source": [
"# Define a function to convert from image coords to rover coords\n",
"def rover_coords(binary_img):\n",
" # Identify nonzero pixels\n",
" ypos, xpos = binary_img.nonzero()\n",
" # Calculate pixel positions with reference to the rover position being at the \n",
" # center bottom of the image. \n",
" x_pixel = np.absolute(ypos - binary_img.shape[0]).astype(np.float)\n",
" y_pixel = -(xpos - binary_img.shape[0]).astype(np.float)\n",
" x_pixel = -(ypos - binary_img.shape[0]).astype(np.float)\n",
" y_pixel = -(xpos - binary_img.shape[1]/2 ).astype(np.float)\n",
" return x_pixel, y_pixel\n",
"\n",
"# Define a function to convert to radial coords in rover space\n",
Expand Down Expand Up @@ -9261,16 +9262,16 @@
"display_name": "Python 3"
},
"language_info": {
"pygments_lexer": "ipython3",
"nbconvert_exporter": "python",
"version": "3.5.2",
"file_extension": ".py",
"name": "python",
"mimetype": "text/x-python",
"pygments_lexer": "ipython3",
"codemirror_mode": {
"version": 3,
"name": "ipython"
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"nbconvert_exporter": "python"
"mimetype": "text/x-python"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions code/perception.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ def color_thresh(img, rgb_thresh=(160, 160, 160)):
# Return the binary image
return color_select

# Define a function to convert to rover-centric coordinates
# Define a function to convert from image coords to rover coords
def rover_coords(binary_img):
# Identify nonzero pixels
ypos, xpos = binary_img.nonzero()
# Calculate pixel positions with reference to the rover position being at the
# center bottom of the image.
x_pixel = np.absolute(ypos - binary_img.shape[0]).astype(np.float)
y_pixel = -(xpos - binary_img.shape[0]).astype(np.float)
x_pixel = -(ypos - binary_img.shape[0]).astype(np.float)
y_pixel = -(xpos - binary_img.shape[1]/2 ).astype(np.float)
return x_pixel, y_pixel


Expand Down

0 comments on commit 04c52c6

Please sign in to comment.