Difference between revisions of "Team R2D2"

From GcatWiki
Jump to: navigation, search
(Imaging)
 
(17 intermediate revisions by 3 users not shown)
Line 7: Line 7:
  
 
==Imaging==
 
==Imaging==
===Hardware===
+
===Hardware Setup===
 
====Summary====
 
====Summary====
 
*Camera will be attached and set - to move the camera left or right we will move the robot
 
*Camera will be attached and set - to move the camera left or right we will move the robot
Line 19: Line 19:
 
*[http://www.aztekcomputers.com/TVIP110-TRENDNET-426191.html For obtaining online images via MATLAB]
 
*[http://www.aztekcomputers.com/TVIP110-TRENDNET-426191.html For obtaining online images via MATLAB]
 
*[http://www.robotshop.com/4d-systems-microcam-serial-jpeg-camera-module-rs232-2.html Serial port integrated camera--looks good]
 
*[http://www.robotshop.com/4d-systems-microcam-serial-jpeg-camera-module-rs232-2.html Serial port integrated camera--looks good]
*[http://foscam.us/foscam-fi8918w-wireless-ip-camera-11.html Foscam]
+
*[http://foscam.us/foscam-fi8918w-wireless-ip-camera-11.html Foscam FI8918W]
 
**[http://www.chargerbuy.com/blog/files/2011/01/Foscam-FI8918W-Quick-Installation-User-Manual2.pdf Manual]
 
**[http://www.chargerbuy.com/blog/files/2011/01/Foscam-FI8918W-Quick-Installation-User-Manual2.pdf Manual]
 
**[http://www.dmcinfo.com/Blog/articleType/ArticleView/articleId/1327/Office-Autonomous-Robot.aspx Project that uses]
 
**[http://www.dmcinfo.com/Blog/articleType/ArticleView/articleId/1327/Office-Autonomous-Robot.aspx Project that uses]
Line 33: Line 33:
 
=====With VLC=====
 
=====With VLC=====
 
*See [http://forum.videolan.org/viewtopic.php?f=14&t=81119 this thread]
 
*See [http://forum.videolan.org/viewtopic.php?f=14&t=81119 this thread]
 +
*http://www.videolan.org/doc/play-howto/en/ch04.html
 
#Make VLC alias <pre>alias vlc='/Applications/VLC.app/Contents/MacOS/VLC'</pre>
 
#Make VLC alias <pre>alias vlc='/Applications/VLC.app/Contents/MacOS/VLC'</pre>
 
#Now connect, and up comes live feed! <pre>vlc -vvv "http://http://10.40.181.49/videostream.cgi?user=test&pwd=&rate=3"</pre>
 
#Now connect, and up comes live feed! <pre>vlc -vvv "http://http://10.40.181.49/videostream.cgi?user=test&pwd=&rate=3"</pre>
 +
 +
=====With Python/OpenCV=====
 +
*http://stackoverflow.com/questions/3001881/display-an-webcam-stream-in-pyqt4-using-opencv-camera-capture
 +
*https://www.dropbox.com/s/3el9e70y71f19ig/webcam.py
 +
 +
=====With MatLab=====
 +
We didn't want to have to pay money so we did a kinda joker work around.
 +
#Get webcam.py and configure it how you want
 +
#Put this line at the start of your matlab script. This will begin executing the python code. The python code will write an image to a file. I have "/opt/local/bin/python2.7" because the python interpreter that has Open CV installed (macports) resides there. <pre>system('/opt/local/bin/python2.7 /path/to/webcam.py')</pre>
 +
#Put this line at the end of matlab script to kill the infinite loop our python code is running. <pre>system('pkill -9 -f webcam.py')</pre>
  
 
====How to connect to IP camera====
 
====How to connect to IP camera====
Line 42: Line 53:
  
 
====Install Open CV on Mac====
 
====Install Open CV on Mac====
#If you don't use enthought python follow steps [http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port here]
+
#Install with MacPorts [http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port here]
 
##Use Command: <pre>sudo port -v install opencv +python27</pre>
 
##Use Command: <pre>sudo port -v install opencv +python27</pre>
 
##Now Check: <pre>port select python</pre>
 
##Now Check: <pre>port select python</pre>
 
##Again: <pre>port installed opencv</pre>
 
##Again: <pre>port installed opencv</pre>
##Then, depending on mac ports settings... <pre>/opt/local/bin/python2.6</pre>
+
##Then, depending on mac ports settings: <pre>/opt/local/bin/python2.7</pre>
 +
##If we want to set this as the default interpreter: <pre>sudo port select --set python python27</pre>
 
##To uninstall something: <pre>sudo port uninstall opencv @2.3.1a_3+python26</pre>
 
##To uninstall something: <pre>sudo port uninstall opencv @2.3.1a_3+python26</pre>
 +
##While we are at is go ahead and install pil <pre>sudo port install py27-pil</pre>
 +
##Also GStreamer python bindings <pre>sudo port install py27-gst-python</pre>
 +
##And if you don't have iterm2, you should get that <pre>sudo port install iTerm2</pre>
 +
##We need this for matlab stuff <pre>sudo port install proctools</pre>
 +
(Below are random notes)
 +
#Install with OpenCV
 +
##Otherwise, download latest open cv release for mac... nevermind this wont work for enthought, just give up.
 +
##Install ffmeg using [http://jungels.net/articles/ffmpeg-howto.html this tutorial]
 +
##Install [http://damien.douxchamps.net/ieee1394/libdc1394/ libdc1394]
 +
##PYTHON_PACKAGES_PATH=/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages PYTHON_LIBRARIES=/Library/Frameworks/EPD64.framework/Versions/7.2/Frameworks PYTHON_EXECUTABLE=/Library/Frameworks/EPD64.framework/Versions/Current/bin/python PYTHON_INCLUDE_DIR=/Library/Frameworks/EPD64.framework/Versions/7.2/include/python2.7 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON /Users/lelandtaylor/Downloads/OpenCV-2.4.0.tar/OpenCV-2.4.0/ <path to the OpenCV source directory>
 +
##Run sudo make install
 +
 +
====Issues====
 +
*How do we connect to the camera wirelessly?
 +
**http://www.youtube.com/watch?v=LG8zX68lxI0
 +
**http://www.jbprojects.net/projects/wifirobot/
 +
 +
*New leads:
 +
**http://bitshift.bi.funpic.de/en/dslr-remote/manual/bluetooth.php
 +
**http://www.informationweek.com/news/cloud-computing/software/228800042
 +
**Pros: we can use almost any dslr camera.
 +
**Cons: A lot of (potentially very difficult) coding. And we still need how to send the photo back to our laptop.
 +
 +
*MATLAB approach:
 +
**http://www.mathworks.com/matlabcentral/newsreader/view_thread/154601
 +
**Pros: it's been done before (though maybe not without the acquisition toolbox, but I think it's possible). It looks very straightforward.
 +
**Cons: Acquisition toolbox is a lot of money. Couldn't find anything about using newer versions of MATLAB to do this. Have to use low res webcam.
 +
  
#Otherwise, download latest open cv release for mac... nevermind this wont work for enthought, just give up.
 
#Install ffmeg using [http://jungels.net/articles/ffmpeg-howto.html this tutorial]
 
#Install [http://damien.douxchamps.net/ieee1394/libdc1394/ libdc1394]
 
#PYTHON_PACKAGES_PATH=/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages PYTHON_LIBRARIES=/Library/Frameworks/EPD64.framework/Versions/7.2/Frameworks PYTHON_EXECUTABLE=/Library/Frameworks/EPD64.framework/Versions/Current/bin/python PYTHON_INCLUDE_DIR=/Library/Frameworks/EPD64.framework/Versions/7.2/include/python2.7 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON /Users/lelandtaylor/Downloads/OpenCV-2.4.0.tar/OpenCV-2.4.0/ <path to the OpenCV source directory>
 
#Run sudo make install
 
  
===[http://www.mathworks.com/products/imaq/ Matlab Imaging]===
+
===Image Processing===
 +
====[http://www.mathworks.com/products/imaq/ Matlab Imaging]====
 
*[http://www.mathworks.com/products/imaq/ Image Acquisition Toolbox] - I think this costs money
 
*[http://www.mathworks.com/products/imaq/ Image Acquisition Toolbox] - I think this costs money
 
*[http://www2.cs.uh.edu/~somalley/camerabox.html Matlab toolbox to control cannon cameras]
 
*[http://www2.cs.uh.edu/~somalley/camerabox.html Matlab toolbox to control cannon cameras]
  
===[http://opencv.willowgarage.com/wiki/ OpenCV]===
+
====[http://opencv.willowgarage.com/wiki/ OpenCV]====
 
*Has some nice functions that could be used to detect opjects
 
*Has some nice functions that could be used to detect opjects
 
*OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision.
 
*OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision.
Line 69: Line 105:
 
**Camera used in FLAIL project: [http://www.logitech.com/webcam-communications/webcams/devices/6333 Logitech Webcam Pro 9000]
 
**Camera used in FLAIL project: [http://www.logitech.com/webcam-communications/webcams/devices/6333 Logitech Webcam Pro 9000]
 
***This camera will work with openCV and matlab camera control features (see [http://www.mathworks.com/matlabcentral/newsreader/view_thread/245473 here])
 
***This camera will work with openCV and matlab camera control features (see [http://www.mathworks.com/matlabcentral/newsreader/view_thread/245473 here])
 +
*If we go with openCV for grabbing the images from webcam and matlab for navigation and some processing, then we'll need a way for the two to talk. Here are some (potentially) helpful links. I haven't yet found anything specifically about MATLAB/terminal interaction.
 +
**[http://people.sc.fsu.edu/~jburkardt/m_src/matlab_os/matlab_os.html MATLAB_OS]
 +
**[http://www.mathworks.com/matlabcentral/newsreader/view_thread/251480 Calling OS commands]
  
 
Below is python code taken from [http://www.cs.duke.edu/~mac/flail.py FLAIL v2]
 
Below is python code taken from [http://www.cs.duke.edu/~mac/flail.py FLAIL v2]
Line 113: Line 152:
 
</pre>
 
</pre>
  
===Issues===
+
==Navigation==
*How do we connect to the camera wirelessly?
+
Here's the potential navigation plan, as discussed by Cyrus, Jack, and Corey on 5/6. Our plan was to break up this general plan, itemize it, edit it, and for each person to claim some of it to work on. Email everyone with comments, suggestions, or new ideas.
**http://www.youtube.com/watch?v=LG8zX68lxI0
 
**http://www.jbprojects.net/projects/wifirobot/
 
 
 
*New leads:
 
**http://bitshift.bi.funpic.de/en/dslr-remote/manual/bluetooth.php
 
**http://www.informationweek.com/news/cloud-computing/software/228800042
 
**Pros: we can use almost any dslr camera.
 
**Cons: A lot of (potentially very difficult) coding. And we still need how to send the photo back to our laptop.
 
  
*MATLAB approach:
+
*Wall Finding Algorithm
**http://www.mathworks.com/matlabcentral/newsreader/view_thread/154601
+
**Assume start on the 3rd floor on the right wall by the math department side.  Use the wall finding algorithm developed by Cyrus to navigate along the right wall. In wall finding loop, use Door Recognition Algorithm to find classrooms.  
**Pros: it's been done before (though maybe not without the acquisition toolbox, but I think it's possible). It looks very straightforward.
+
*Door Recognition Algorithm
**Cons: Acquisition toolbox is a lot of money. Couldn't find anything about using newer versions of MATLAB to do this. Have to use low res webcam.
+
**Continuously take photos at regular intervals and analyze them for the doors.  Find doors by placing tape on door jamb so it is noticeable from where the robot will be coming from.  When a door is recognized, call the Door Navigation Algorithm.
 
+
*Door Navigation Algorithm
==Navigation==
+
**Navigate some distance to get in front of door opening (maybe wait for the door tape to become a certain size before stopping?), then turn 90 degrees into the door, and go forward until in position.  Then call Window Picture Algorithm (ask window team). After taking the picture and analyzing it, call Door Exit Algorithm.
 +
*Door Exit and Re-Wall-Finding
 +
**Robot goes back the same way it came (maybe follow same steps?). Once outside, turn right 90 degrees, ignoring tape seen on the door (because it's already seen it and navigated through that classroom) and navigate forward a predetermined distance, then start wall-finding again.
  
 +
pseudocode for the __main__ algo:
 +
<pre>
 +
robot = initialize()
 +
while notDone:
 +
    robot.findWall()
 +
    if doorRecognized():
 +
          robot.navigateDoor()
 +
          robot.analyzeWindows()
 +
          robot.exitAndReFindWall()
 +
</pre>
 
==Notes==
 
==Notes==
 
Jack and Duke met on 4/20 to discuss navigation. The consensus was that our first goal is to figure out how to design a virtual map of a space and write commands to get the robot to go to a target location in the space. Once we do that, we will work on mapping out chambers, hopefully using the robot to gather data of the shape of our chambers floor (which one are we going to do?) and turn that data into a map. We also discussed the possibility of using traveling salesman problem model to get the robot to our target locations as quickly as possible.
 
Jack and Duke met on 4/20 to discuss navigation. The consensus was that our first goal is to figure out how to design a virtual map of a space and write commands to get the robot to go to a target location in the space. Once we do that, we will work on mapping out chambers, hopefully using the robot to gather data of the shape of our chambers floor (which one are we going to do?) and turn that data into a map. We also discussed the possibility of using traveling salesman problem model to get the robot to our target locations as quickly as possible.

Latest revision as of 18:13, 8 May 2012

To Do

  • Connect to iRobot & Send Command with MatLab (with laptop) - Cyrus
  • Decide on Camera - Leland & Corey
  • Subgroup Make Outline

Abstract Draft

Imaging

Hardware Setup

Summary

  • Camera will be attached and set - to move the camera left or right we will move the robot
    • We will have to decide if we want to create a contraption to raise/lower the camera
  • We need to get a camera that we can also connect to via bluetooth... at first this could be a wired, but we need direct usb connection in final version
  • Good Link

Possible Cameras

SmartPhone Camera Vision

Feed Streaming

With VLC
  1. Make VLC alias
    alias vlc='/Applications/VLC.app/Contents/MacOS/VLC'
  2. Now connect, and up comes live feed!
    vlc -vvv "http://http://10.40.181.49/videostream.cgi?user=test&pwd=&rate=3"
With Python/OpenCV
With MatLab

We didn't want to have to pay money so we did a kinda joker work around.

  1. Get webcam.py and configure it how you want
  2. Put this line at the start of your matlab script. This will begin executing the python code. The python code will write an image to a file. I have "/opt/local/bin/python2.7" because the python interpreter that has Open CV installed (macports) resides there.
    system('/opt/local/bin/python2.7 /path/to/webcam.py')
  3. Put this line at the end of matlab script to kill the infinite loop our python code is running.
    system('pkill -9 -f webcam.py')

How to connect to IP camera

  1. Connect to davidson device using WPA personal with the passphrase
  2. Go to the address http://10.40.181.49/
  3. Log in using our id and password

Install Open CV on Mac

  1. Install with MacPorts here
    1. Use Command:
      sudo port -v install opencv +python27
    2. Now Check:
      port select python
    3. Again:
      port installed opencv
    4. Then, depending on mac ports settings:
      /opt/local/bin/python2.7
    5. If we want to set this as the default interpreter:
      sudo port select --set python python27
    6. To uninstall something:
      sudo port uninstall opencv @2.3.1a_3+python26
    7. While we are at is go ahead and install pil
      sudo port install py27-pil
    8. Also GStreamer python bindings
      sudo port install py27-gst-python
    9. And if you don't have iterm2, you should get that
      sudo port install iTerm2
    10. We need this for matlab stuff
      sudo port install proctools

(Below are random notes)

  1. Install with OpenCV
    1. Otherwise, download latest open cv release for mac... nevermind this wont work for enthought, just give up.
    2. Install ffmeg using this tutorial
    3. Install libdc1394
    4. PYTHON_PACKAGES_PATH=/Library/Frameworks/EPD64.framework/Versions/7.2/lib/python2.7/site-packages PYTHON_LIBRARIES=/Library/Frameworks/EPD64.framework/Versions/7.2/Frameworks PYTHON_EXECUTABLE=/Library/Frameworks/EPD64.framework/Versions/Current/bin/python PYTHON_INCLUDE_DIR=/Library/Frameworks/EPD64.framework/Versions/7.2/include/python2.7 cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON /Users/lelandtaylor/Downloads/OpenCV-2.4.0.tar/OpenCV-2.4.0/ <path to the OpenCV source directory>
    5. Run sudo make install

Issues

  • MATLAB approach:
    • http://www.mathworks.com/matlabcentral/newsreader/view_thread/154601
    • Pros: it's been done before (though maybe not without the acquisition toolbox, but I think it's possible). It looks very straightforward.
    • Cons: Acquisition toolbox is a lot of money. Couldn't find anything about using newer versions of MATLAB to do this. Have to use low res webcam.


Image Processing

Matlab Imaging

OpenCV

  • Has some nice functions that could be used to detect opjects
  • OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision.
    • "applications of the OpenCV library are Human-Computer Interaction (HCI); Object Identification, Segmentation and Recognition; Face Recognition; Gesture Recognition; Motion Tracking, Ego Motion, Motion Understanding; Structure From Motion (SFM); Stereo and Multi-Camera Calibration and Depth Computation; Mobile Robotics."
  • OpenCV Documentation
  • List of compatible cameras
  • If we go with openCV for grabbing the images from webcam and matlab for navigation and some processing, then we'll need a way for the two to talk. Here are some (potentially) helpful links. I haven't yet found anything specifically about MATLAB/terminal interaction.

Below is python code taken from FLAIL v2

##################
# Camera Control #
##################
class FlailCam:
  """
  Controls a USB webcam. Uses OpenCV to control the camera, and should
  therefore work with any V4L2-compatible camera (in linux) or just about
  anything (in Mac OS). Webcam support being what it is in Linux, though, it
  may not work at all.
 
  If you find yourself in the it-doesn't-even-begin-to-work boat, take a look
  at flailcam.py from FLAIL 1.0. It has a (terrible, kludgy, slow) workaround
  that sometimes worked better.
 
  The important method (get_image) returns a Python Imaging Library (or PIL)
  object; these are well-documented on the PIL website, at
  <http://www.pythonware.com/library/pil/handbook/image.htm>. You're probably
  most interested in the getpixel, putpixel, and save methods. 
 
  FLAIL 1.0 had a FlailImage class, which wrapped the same PIL image class
  used here; if you'd like an extremely simplified interface, take a look at
  that code.
   
  If you'd prefer an OpenCV object, just take a look at the get_image source
  code, and you'll see what to do.
  """
  def __init__(self, index = 0):
    """
    Connect to a camera. OpenCV (which we use for camera control) numbers
    these starting from 0; the index parameter tells which camera to use. In
    Linux, an index of X implies the device /dev/videoX.
    """
    self.cap = opencv.highgui.cvCreateCameraCapture(index)
 
  def get_image(self):
    """
    Take a picture. Return it as a PIL image. 
    """
    return opencv.adaptors.Ipl2PIL(opencv.highgui.cvQueryFrame(self.cap))

Navigation

Here's the potential navigation plan, as discussed by Cyrus, Jack, and Corey on 5/6. Our plan was to break up this general plan, itemize it, edit it, and for each person to claim some of it to work on. Email everyone with comments, suggestions, or new ideas.

  • Wall Finding Algorithm
    • Assume start on the 3rd floor on the right wall by the math department side. Use the wall finding algorithm developed by Cyrus to navigate along the right wall. In wall finding loop, use Door Recognition Algorithm to find classrooms.
  • Door Recognition Algorithm
    • Continuously take photos at regular intervals and analyze them for the doors. Find doors by placing tape on door jamb so it is noticeable from where the robot will be coming from. When a door is recognized, call the Door Navigation Algorithm.
  • Door Navigation Algorithm
    • Navigate some distance to get in front of door opening (maybe wait for the door tape to become a certain size before stopping?), then turn 90 degrees into the door, and go forward until in position. Then call Window Picture Algorithm (ask window team). After taking the picture and analyzing it, call Door Exit Algorithm.
  • Door Exit and Re-Wall-Finding
    • Robot goes back the same way it came (maybe follow same steps?). Once outside, turn right 90 degrees, ignoring tape seen on the door (because it's already seen it and navigated through that classroom) and navigate forward a predetermined distance, then start wall-finding again.

pseudocode for the __main__ algo:

robot = initialize()
while notDone:
     robot.findWall()
     if doorRecognized():
          robot.navigateDoor()
          robot.analyzeWindows()
          robot.exitAndReFindWall()

Notes

Jack and Duke met on 4/20 to discuss navigation. The consensus was that our first goal is to figure out how to design a virtual map of a space and write commands to get the robot to go to a target location in the space. Once we do that, we will work on mapping out chambers, hopefully using the robot to gather data of the shape of our chambers floor (which one are we going to do?) and turn that data into a map. We also discussed the possibility of using traveling salesman problem model to get the robot to our target locations as quickly as possible.

Uninstall Python

  1. Remove framework
    sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
  2. Remove Applications Dir
    sudo rm -rf "/Applications/Python 2.7"
  3. Remove symbolic links in /usr/local/bin
    ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | xargs rm
    or
    cd /usr/local/bin; ls -l . | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | xargs rm