Source Code Download

Here is the source code for both Loki and Turtle in a single zip file.

Note that Loki and Turtle are evolving robots.  The code is constantly changing, along with the hardware.  So, expect to see code commented out, or #defines that turn code on and off.  Also, there is some “dead” code, for example there are data structures to support sensors that are no longer used on one or both robots.  This code is my active project, just for fun.  It makes sense to me, but it might not make sense to you. :-)

ReadMeFirst

This code is posted as example code for how to do things like getting started with OpenCV, Kinect, talk to servos and motor controllers, voice recognition, etc.  You should cut and paste whatever helps you.  If you want to use the full code as is, this is an advanced project, which requires a good understanding of Visual Studio and C++, including the ability to modify project files so you can remove any dependencies on external functionality you don’t need.

Release Notes –  Please Read this!  Important info to get you started!

Downloads

1/15/2013:  NEW! External dependency problems Fixed, and Arduino Support!
By popular request, I have converted all my PIC code to Arduino! This also might make some good sample code for anyone wanting to use an Arduino as a sensor interface to a PC. Download it here: 2013-01-26-LokiRobot.zip.

9/25/2012:  This includes a single zip file that includes OpenCV 1.1.  Note that this is an update in progress.  If you want OpenCV examples, I suggest you use the prior update below.  If you just want a simple install, with core functionality, install this one.  This “Should” just work, but I don;t have a “clean” system to test it on. See “READ ME TO INSTALL.txt” for simplified instructions (you can ignore all the instruction in the prior updates!)  Download it here:  Loki 2012-09-25.zip

7/24/2012: New – moved to Microsoft Kinect 1.5 SDK, and moved Kinect Depth detection and speech recognition to a C# project, to take advantage of Kinect’s excellent microphone phased array.  Works really well.  Also added some new tricks.  Try “Loki, which way is north?” and “Loki, Follow me” . :-)  Here’s the updated source: LokiSource2.zip

I have also posted a copy of OpenCV 1.1, that is compatible with the current code (I am moving to 2.x, but not there yet).   Just unzip and copy to “C:\opencv”.  If you get any errors about “xxx.dll not found” when you run, you may have to edit your PATH environment variable and add “C:\OpenCV\bin”.

1/10/2012:  Loki and Turtle source code, all in C++, using the non-Microsoft Open Kinect SDK:  LokiSource.zip

 

18 Responses to Source Code Download

  1. Grant Imahara says:

    I have yet to look at your source, I’m downloading as I type in my phone but I’m hoping to port some of it to debian Linux, if I do, and your intrested I’ll post my portages… let me know. ;-)

  2. dshinsel says:

    Yes, I’d be interested if you port to Linux.
    You might also consider using ROS (Robot OS). If I was on Linux, that’s what I would use. I’d love to have someone take my code and integrate it with ROS!

  3. Adam Walker says:

    YEA!! An update! I never gave up hope that you would post one sooner or later. I emailed you back in Nov 2010 thanking you for sharing your code which was the only resource I found that was useful for learning OpenCV SURF, and I would like to thank you again now. I have not even unzipped the code yet, but I know there is loads for me to play with. As I said back in 2010, “Hopefully I will be able to create my own mechanical mischief soon……..” As soon as finances (and the wife) allow that is.
    Thanks again!

  4. Adam Walker says:

    Forgot to mention, I have used the code I got from you back in 2010 to make my laptop learn and recognize various objects via its built in webcam. I am most impressed with its ability to differentiate a one dollar bill from a twenty and so on. Also, the speech engine on my laptop has been written to give random responses to commands via grxml and blink its lights (it’s an alienware) on the “vowely” sounds.
    Can also tell the laptop to turn lights in the house on and off, change the channel, etc. via an arduino board I built. All of this spawned from perusing your code and I am very grateful once again. Just thought you may like to know how much it helps us “little folk” when people like you are gracious enough to share. :)

  5. dshinsel says:

    I have posted a new update!
    Changes include: Moved to Microsoft Kinect 1.5 SDK, and moved Kinect Depth detection and speech recognition to a C# project, to take advantage of Kinect’s excellent microphone phased array. Works really well.

  6. William August says:

    Hey Dave -Excellent job with Loki. I wonder if you have ever thought about making a complete tutorial regarding Loki’s mechanical,electrical,code. Something where the average Joe could follow along from page to page and eventually end up with a Loki of there own to experiment with. I for one would be willing to pay whatever for a tutorial that included blueprints of the mechanical parts + parts lists etc. To my knowledge there is nothing like this out there that deals with a robot of this caliber. I hope you will think on this. Thanks Bill

  7. Rob Lear says:

    Dave – Love the Seeker robot concept. I am working on a similar robot using the EMAXX platform, controlled with an Arduino. Would you be willing to share the GUI code? I have a copy of your Seeker Demo package, but would like to work with the GUI more. Thank you

  8. fred miller says:

    Dave you LOKI project it great
    i made your seeker design only added a second webcam like your LOKI robot
    only having problems with the code,how can i convert seeker one webcam design to a 2 webcam like on LOKI

  9. dshinsel says:

    Hi Fred,

    Help me understand the goals of using 2 cameras on a car robot? I originally used 2 for stereo vision to get depth perception for Loki (because he has arms). I was never happy with the results, and once Kinect came out, the need is gone, at least for an indoor robot.

    If you are building an outdoor robot, what are your plans for it? for a later version of Seeker, I put 6 ultrasonic sensors in a half circle to help it navigate / avoid obstacles, and use the camera to identify objects of interest.

    If you want stereo 3d, I would grab later version of code that uses OpenCV 2, and add the stereo there. I have not played with Seeker for a long time, so the new code will need some work to get it working with seeker’s design again.

    If it helps, I am in the process of moving my code over to OpenCV2… let me know if you intend to use this, and I’ll let you know when the port is done.

  10. fred miller says:

    not much using as a outside robot,mostly inside for little better face recognition and navigation,kinect not too happy with using mostly very big and draws over 1 am ,plus about 400 ma at 5 volts,i seem to like NEATO xv-11 LIDAR for navigation
    and i sell them,havent made a code for it yet,but does work on a robot with linux ROS really well

  11. Robert H. Zeiler says:

    Dave,
    In the LOKI mechanicals for the arm, specifically shoulder joint, you use a dc geared motor with encoder. This drives a chain and effects eventual rotation of the shoulder joint. I have built an arm similar to yours (still under contruction) except using a stepper motor and chain drive. Since the dc motor is not a servo, I was wondering how you command the dc motor to start/stop and go to the correct position? Of course I understand the feedback loop from the encoder, but doesnt this mean turning on/off the motor for a specific duration? Then, how do you calculate that duration?

  12. Pete Skeggs says:

    Hey Dave, I thought I’d check our your Arduino code. Looks good. I think your zip file (http://www.dshinsel.com/download/2013-01-15-LokiRobot.zip) is missing a library, as FreqPeriodCounter.h is not present. Is this something you wrote, or a third-party library?

  13. Antonio says:

    Hi Dave,

    Your robots are simply amazing! Meanwhile I’m trying to run the Loki project from your Loki 2012-09-25.zip. I followed your instructions carefully and I’m running the code on Visual Studio 2010. Everything compiles great and I have set the turtle as the starting project. My hardware setup is an iRobot Create adapted with a kinect on top (similar to the turtle bot). Thereby I’m trying to run your code on my robot. However I have a few questions:

    1. As I start the software it seems that I’m always stuck in the simulation mode. Here’s my steps:
    a. I have selected the Motor COM port 22 (my particular case) on the setup menu.
    b. I switch to command mode and try to move the robot with scroll up/left/right however it doesn’t move. Maybe I’m not configuring it well on the setup menu. In the command mode the motor square keeps saying Waiting. Something is not right and I might need to configure my serial port on other menu to successfully setup my physical robot.

    2. I managed to start the Kinect mode but not in a common fashion. I have compiled both the debug and release versions. I was expecting that VC++ Robots.sln would launch the RobotKinectViewer itself. As it didn’t happened I launched the RobotKinectViewer manually. The VC++ app. has detected it as the green square says ready.
    However as the kinect is ready I don’t know what to perform next in order for to build a map of my room and navigate with the robot.

    PS: I have sent two GUI screenshots.

    Regards,
    Antonio

    • dshinsel says:

      Hi Antonio,
      Sorry for the delay.

      1. “Simulation Mode” is determined by if an Arduino or PIC is found (depending upon which version of software you have). If neither is found, it will drop into simulation mode. You can edit the code to prevent this, or attach an Arduino loaded with the provided Arduino code. The Robot expects Odometer values from the motors to come from the Arduino. If you use a different method, you need to edit the code, or the robot won’t know how far it has traveled.
      1b. Try to use keys W(forward), A(Left), S(Right), X(Back), like video games use. Also, first try the slider bars for forward/reverse and Left/Right

      2. To auto-launch the Kinect app, look at the top of Globals.cpp, and make sure “AUTO_LAUNCH_KINECT_APP” is set to 1 as follows:
      #define AUTO_LAUNCH_KINECT_APP 1 // set value to 1 to auto launch

      Also, search for the function “LaunchKinectApp()”, and notice this line:
      if( !CreateProcess(
      //”C:\\Dev\\_Robot\\RobotKinectViewer\\bin\\Debug\\RobotKinectViewer.exe”, // __in_opt LPCTSTR lpApplicationName,
      “C:\\Dev\\_Robot\\RobotKinectViewer\\bin\\Release\\RobotKinectViewer.exe”, // __in_opt LPCTSTR lpApplicationName,
      Enable either the debug or release version (and the path to your binary if different) here.

      To build a map of your house is a little more difficult. See next post.

  14. dshinsel says:

    How to add a Map:
    - Make a map of your house on paper, using a compass and measuring tape. The Compass directions are very important, so be precise.
    - Once the robot code is running, select File –>New–>Map
    - A blank map will be displayed, with a circle in the center of the map, representing the robot (and red lines indicating simulated or real sensor readings)
    - Select Add Page and add pages to North,South, East, or West get approximate size of your house
    - Select Draw Mode –> Wall to draw a wall. Leave gaps for Doors, and select “Door” to draw them in.
    - If you want, you can export to Common Separated Value format, using Text Import/Export, and edit values that way.
    the file is always saved in c:/temp/map.txt
    - If the map is off a little, you can rotate it with Rotate

    Most Important: Save Frequently! there is no “Undo”. This is a VERY primitive map drawing program that I just threw together. It may have a few bugs :-)

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>