Source Code Download

NEWS:

05/18/2016:  Final snapshot of Loki code, which is end of life so I can focus on ROS.  See latest Loki drop below.

12/3/2013:  New update with Kobuki Base for Turtlebot, and Android Phone Robot Control for Loki.  

7/5/2013:  NEW! Android Phone Robot Control Sample for Arduino
I have made a sample program for controlling an Arduino robot (stand-alone or connected to a PC) from an Android phone.  This also might make some good sample code for anyone wanting control Arduino from an Android phone (and get data from Arduino).  Download it here: Android BotControl-rev1.zip.

Loki and Turtle Code

Below 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

5/18/2016:  Final snapshot of Loki code.
Download it here: 2016_05_17_LokiRobot.zip.

12/3/2013:  LOKI CODE: Loki with Arduino, Android Phone interface, and Kobuki Base control for Turtle robot.
Not much change from the code below, but added Kobuki base control (Google “turtlebot”), and more vision recognition code.  Download it here: 2013-12-3-LokiRobot.zip.

1/15/2013:  LOKI CODE: Moved Loki to Arduino!
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

 

41 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 🙂

    • laith says:

      hello Dave
      I really like your robots and I was wondering what materials did you use to do Loki can u tell me.

  15. Laura Lemmons says:

    Will you help me with the code for Loki? His sister(which is going to be my robot) will be sorda like him but will have the ability to communicate with other computers and will also have the ability to use the internet through my laptop and internet to chat on her facebook, twitter, etc.

    • dshinsel says:

      Hi Laura,
      What is your programming background?
      Loki’s programming is an advanced project, so if you don’t have extensive C++ programming experience, you should start a little smaller and work your way up.

      I am in the process of learning ROS (Robot Operating System) on a Turtlebot 2 (google Turtlebot), and may move Loki code to ROS, so starting with a Turtlebot would be a good way for you to start, after you have built something smaller like an arduino robot. Take a look at PI Robot for an example how someone is growing a TurtleBot to a more advanced robot like Loki.

  16. fred miller says:

    HI laura DAVE is right c++ is very hard to learn,i would look at starting with a cpu that has a easy to learn GUI script l,check out EZ-ROBOT board very easy to learn and program and great for young programmers 6 and up
    do a search for ez-robot,many very young builders using it and has so many functions and interfaces to add to it

    then after you learn it for awhile then try higher programming

  17. Rick says:

    Dave,

    Will the Loki build recognize the iRobot Create (Turtlebot) as its motor source if the COM port is correct? I’ve wiped Win7 off my system so I can play with ROS for a bit or I would test it myself. I’m wanting to play with your code again and was hoping I could use the Loki build with my Create as the motor source. I’m looking through the different files and see (RobotType Header). It looks like this is the source that sets the robot that is connected. Is this correct?

    My current robot parts:

    Motor= iRobot Create
    Vision= xBox Kinect + Two Webcams
    PIC= Arduino MEGA (Not yet connected)
    Laptop= ASUS G60J

    I’m wanting to use my Create for the motor for now but also use the Kinect and Stereo Vision/webcams as well as your speech software. I’m hoping that your code is forgiving enough to allow the use of its features as I can afford the part/sensors that are programmed into it.

    P.S. Have you ever thought of adding a forum to your site so others can help you help others with their Loki projects?

    Thanks,
    Rick

    • dshinsel says:

      Yes, iRobot Create and Kobuki base both work,and you are in the right file to set the base type. I have been spending all my time lately with Kobuki, so I might be broken Create configuration, but if so it would be a compile time error, so pretty easy to find.

      Regarding forum, that’s a great idea!

  18. brandon says:

    hi Dave.
    im trying to build a robot based on seeker. im good with the hardware. but was wondering about the software. I have the files from 2006 servo mag articlea. but was wondering how you get the camera feed to show up. also was wondering if you could email mee the codes and source so I can modd it for my setup.
    thanks.

    • dshinsel says:

      It’s been a long time since I worked on Seeker 🙂
      The most current code on my webpage *should* mostly work, but probably needs updates.
      For vision, I use OpenCV: http://www.opencv.org but the 2006 code is on version 1 and most newer code is based on OpenCV version 2.
      I’ll dig through my backups to see if I have something newer for you… might take a few days…

      • Brandon says:

        thanks. i really appreciate it

        • dshinsel says:

          Hi Brandon,
          I looked through my backups, and I have the Seeker code, but it no longer compiles. I’d need to install old copies of OpenCV and such.
          I can provide that if you are comfortable with getting it working, or you can use the latest code for Loki and Turtle that *should* support a car robot, but I have not tested for a while. Either way, there is probably work to get it all working again. If you are not in a hurry, I will try to get current code base working for a carbot, but not sure when I can get to it. Let me know.

          • brandon says:

            thanks, im not in a hurry.
            if you could get the code working that would be great.
            also im planning on using my old Dell latitude c600 as the “computer” its running at 850mhz with xp pro. was wondering if the old code could work on that? if not then i will use a newer laptop.
            thanks

  19. Mohamed says:

    To build a robot you need to design it I wa a wondering of you could tell me which app you used for the designing for your robots waiting for your reply

    • dshinsel says:

      I assume you mean “CAD Software” for doing the hardware design? No, I just design the hardware in my head and on paper 🙂
      For software, I use Microsoft Visual Studio. Requires learning C++ and/or C#. To get started in robotics, I suggest Arduino (see other comment). 🙂

  20. Mohamed says:

    hi dave i was wondering which website do you go on to program your voice reginition module

  21. brandon devogel says:

    could i get the code for seeker?
    and the dll for joystick control thanks

  22. Brandon Devogel says:

    Hi dave i was compilling your newest loki source code on my copy of visual studio 2010 pro, but it could not find the file: winsfx.h or something like that ( my programming pc is not on right now so im going off mem.) so i was poking around in the code and i concluded that it is not in the zip file at all. was wondering if you forgot it or if im just missing something. and if i am, how could i fix it. thanks

  23. Alek says:

    I’m gonna try to make a ROS version of the code……..Im gonna use openkinect so that i am still using that

    I dont understand what ROS is but im going to use linux for gcc and make

    ill make a git repo for anyone who wants to follow me or help me ill reply the link

    Any tips david?

  24. Lue Martin says:

    Hi Dave.
    I wanted to let you know that I love your robots. I feel that Loki is about the closest thing to what most people visualize when they hear the word robot. Now, I have a question. Of Loki’s abilities shown in the videos, how many are as shown. I.E.: does Loki actually visually recognise items, like the ball and the CD case or were his responses… prompted? If he actually recognises various items, how many items can he visually recognise at present? I’ve tried looking at the source code, but it’s actually well above my pay grade. But, I am still undaunted in the attempt to understand most of it. You and Loki are inspirations for those of us who are just starting on the path of robotics.

  25. vicky says:

    Can u upload a program code for voice recognisation robot car for c++ language

  26. fred miller says:

    HI Dave
    working on the seeker and like you idea of using only one web cam

    where you able to get the full seeker code working,if so can i get a copy of it

Leave a Reply

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