Kids Rocket Lamp

Hi! Today I am coming back with a small cool project that I designed recently. Let's build a super cool rocket lamp for kids (and kid-souled adults!)

SUMMARY MATERIALS:

  • Transparent/translucid PLA
  • Cables for wiring up everything
  • Soldering tool
  • Tweezers
  • Hot glue gun
  • 4 Li-ion batteries (similar to ICR18650 samsung 28a)
  • 4 Blue leds (or the color you want)
  • 4 resistors to limit the voltage that drops on the leds
  • 1 TP4056 Micro USB 5V 1A battery charger
  • 1 small toggle switch


I uploaded all the required files to my dashboard in Thingiverse, you can download everything directly here https://www.thingiverse.com/thing:3166389


I used a transparent PLA filament (which I bought from a Spanish supplier ), but you can use the filament that you want. Anyway, I recommend some kind of translucid material so the lamp can actually throw some light.

Let's start by 3D printing the chassis of the rocket. Here you can see how it looks like:

Once you have the rocket, let's dig into the electronic side. I am using 4 "icr18650 Samsung 28a" batteries to supply the lights. To charge them I found a small circuit called "TP4056" which is a simple Li-Ion 1s charger with a USB connector and has an internal safe method for the batteries. This circuit allows us to charge the batteries and prevent them to discharge too much if we forgot to switch off the lamp. Additionally, I bought a switch and a battery level display. The battery level display is optional but it is always cool to know how much remaining battery do we have. Finally, we cannot forget the LEDs, it is important to know which color are we using because each led has a working voltage and overloading them will lead us to burn them.  Here you have a picture of the components.

Next step is to assemble everything. But first, we need to print the core of the rocket. The model is also on thingiverse and it should look like this


Once it is installed, let's start by integrating the battery charger circuit. At first, solder 4 cables to the connector and insert them through the hole in the base. Start with the cables and use some tweezers to help you catch the cables on the center. Fit the circuit with some hot glue to the base.
Then, put your batteries in the stack. You can arrange them as you what, but I recommend placing the negatives in the extremes and the positives in the center. Solder cables to all the extremes to join all the negatives and all the positives.

Solder all the negatives to the negative for the battery in the circuit (B-) and all the positives to the positive for the battery in the circuit (B+). You will have then two more cables, the out+- of the circuit. Leave the negative by now, and pass the positive through the other hole in the basement for the switch, solder the cable to the switch and solder another which returns through the hole too. Then safe the switch using too small screws.


And God said, let there be the light! Let's put some LEDs on the lamp. There are two cornices to place two LEDs at the height of the windows. Then there are two holes in the centers to place the other two. You can place as much as you want on the pillar but 4 should be enough, it is supposed to be a nightlamp, not an actual lighting lamp. Use hot glue to fix them.
Then, I recommend you to put a resistor at each led, in my case I don't need them because these are high voltage blue led. So make sure that your LEDs can resist the voltage or you will break them. And voila!



Finally, If you have filaflex, there is a model for a gasket in thingivesrse. It fits to the bottom of the core and seal the chassis with the basement. But don't worry if you don't have filaflex, you can fix the base with hot glue too. 



So let's assemble the chassis!



And don't forget to charger it from time to time!


Self-controlled ARdrone (Part II) - Configuring the on-board computer and some useful tools.

<< Previous (Adding extra hardware)

On previous tutorial we see how to add easily a small computer to our ARdrone. Now we need to configure the odroid to use with ARdrone.

Connecting to network
To start working with the odroid, we need first to connect it to a screen, mouse and key board.


Afterwards we will be unconnected from internet. So firstly, connect to your home network and download every package or repo you will need.

For this tutorial install x11vnc and ssh

      sudo apt-get install x11vnc openssh-server

Now, look for the ARdrone Access Point (AP), and connect the odroid to it. This "network" will allow us not only to control directly the drone by odroid, but to have a network to work through.
Finally, disconnect the screen and the peripherals.

Remote desktop
To work easily with our system, download on your personal computer some vnc client (For example, for windows: VNCviewer) and ssh client . Connect to ARdrone network with your personal computer and create and ssh connection with the odroid. ARdrone's dhcp provides ips with the following pattern "192.168.1.X" with X = 2, 3, 4 or 5.

Type:    ssh odroid@192.168.1.X

It will ask you for the password. Type:    odroid.

Now we are connected to our odroid remotely, but a terminal is not always comfordable. That's why we installed x11vnc.

Type:     x11vnc

This will launch a program that allows us to connect to a remote desktop and use the odroid as using a screen and a mouse/keyboard.


If everything was fine, it will tell you in which IP and port you should connect, Now, on your personal computer, launch your VNC client and connec to that IP and port; for example 192.168.1.X:5900 (on port 5900). We would be able to see the odroid remotelly.


And that's it, we can configure, code or whatever remotelly, without wires and sharing mouse and keyboard. Unfortunatelly, we do not have internet, so in order to download new applications, packages or our own code, we have three option:

  1. If possible, copy into an usb.
  2. Connect again the odroid to a normal screen and a mouse, etc... And reconnect to your "home" network.
  3. This is the most versatile one: Connect another USB wifi module into the odroid and configure it to have 2 connections, one to the drone and the other to your house network, so it's possible to download directly in remote network.

Hope you liked this tutorial! If you have any doubt or suggestion tell me!

libsvmpp - The c++ wrapper of libsvm



For those of you who wanted to have some machine learning in your code, but felt frustrated using old fashionable c-style libsvm, I bring libsvmpp to you!.


libsvm is a well know library from the Department of Computer Science of the National Taiwan University. This library is world-wide tested, fast and throw good results in most of cases. However... It's in C, and although it's not too difficult to be used, sometimes it's not clear and made us to write crappy lines of codes.

I designed a new face for it. A beautiful and very easy to use interface that will allow you to use it using all the power of C++ stl libraries.


Having fun with arduino and robotic arm.

Some weeks ago someone dropped a small 3d-printed arm in my University. Finally this Friday I took it and brought it to home to play with it.

I prepared a small library for controlling it easily (Matrix classes, trajectory calculus, command parser from raw strings and a small Arm class). Code is here.

This is a small demo video. It has only forward kinematics with some predefined positions (home, extended, etc...). But now everything is prepared for inverse kinematics.





I'm currently working on it's equations and control in (X,Y,Z) coordinates. I will upload a new video soon.

Computer Vision

Tutorials

Useful libraries

  • PCL (Point Cloud Library): is an open-source library of algorithms for point cloud processing tasks and 3D geometry processing, such as occur in three-dimensional computer vision.
  • OpenCV (Open Computer Vision): is a library of programming functions mainly aimed at real-time computer vision. This library cover many areas and nowadays is one of the most used libraries for computer vision as it provides all possible basic functionalities to speed-up development.

External Courses

  • Machine Learning:

PCL on Windows. Compiling from sources



These days I wanted to work with pcl but the guides about using it on Windows were out-of-date or not precise at all, oblying me to work on linux.
([UPDATE:2015-12-19. Now, there is a nice official guide, http://www.pointclouds.org/documentation/tutorials/compiling_pcl_windows.php)

Finally when I got it I decided to share the whole proccess that I follow in order to help people with the same trouble like me. These are the steps:


  • Build zlib
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open zlib.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build". (Note: in order to call INSTALL from Visual Studio (VS), it's needed to open it as administrator)
  • Build libpng
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open libpng.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Build eigen
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open eigen.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Build boost
    • Extract zip into pcl_build folder, go inside the folder. Make sure u are in the same root as "CMakeLists.txt" file
    • Open cmd terminal. Type: ".\bootstrap.bat" this will generate a file for building everything.
    • Type ".\b2 variant=release install" to build and install boost. If want to compile PCL in debug, compile boost in debug too. (It's possible to have both versions)
    • Now is necessary to add to system variables "BOOST_ROOT" with value "C:\Boost\include\boost-1_60" (or similar, depending on the version and the place you installed it)
  • Build flann
    • Extract zip into pcl_build folder (or clone repository), go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open flann.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
      • Troubleshooting: If compiler throw this (or similar error) error: "flann windows serializer has already been defined". Open file "C:\programming\pcl_build\flann\src\cpp\flann\util\serialization.h" and change lines 96-115 to:
BASIC_TYPE_SERIALIZER(char);
BASIC_TYPE_SERIALIZER(unsigned char);
BASIC_TYPE_SERIALIZER(short);
BASIC_TYPE_SERIALIZER(unsigned short);
BASIC_TYPE_SERIALIZER(int);
BASIC_TYPE_SERIALIZER(unsigned int);
 BASIC_TYPE_SERIALIZER(long);
BASIC_TYPE_SERIALIZER(unsigned long);
//BASIC_TYPE_SERIALIZER(unsigned long long);
BASIC_TYPE_SERIALIZER(float);
BASIC_TYPE_SERIALIZER(double);
BASIC_TYPE_SERIALIZER(bool);
#ifdef _MSC_VER
// unsigned __int64 ~= unsigned long long // Will throw error on VS2013&
//#if _MSC_VER != 1800&
BASIC_TYPE_SERIALIZER(unsigned __int64);
#else
BASIC_TYPE_SERIALIZER(unsigned long long);
#endif

    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
    • If you see an error in a package related with matlab (see output and there should be a link to mathworks) dont worry about it, that package is not needed for PCL. It's possible to avoid compiling it disabling that module using cmake-gui.
  • Build qhull
    • Extract zip into pcl_build folder, go into the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.

    • Go to build folder, open qhull.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Build Gtest. This library is only needed if want to compile tests. If you dont really care tests, disable option "BUILD_global_tests" in cmake.
    • Clone repository and go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.

    • Go to build folder, open googletest-distribution.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Build vtk
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open vtk.sln.
    • Choose build type (preferable "Release").
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right clic "INSTALL" project and press "Build"
    • In order to let PCL find VTK, add "VTK_DIR" variable to system containing path to VTK folder (4 ex, "C:\Program Files (x86)\VTK").
  • Build PCL
    • Extract zip into pcl_build folder, go inside the folder. Create "build" folder (Make sure u are in the same root as "CMakeLists.txt" file)
    • Configure build files with cmake: (Two options, only one of this)
      • Open cmd window. Go to build folder and type "cmake .."
      • Right click CMakeLists.txt and open with cmake-gui. Press configure and then generate.
    • Go to build folder, open pcl.sln.
    • Choose build type. (Take care, before compiling pcl in any form, make sure that also has boost with that type of compilation).
    • In project explorer, right click "ALL_BUILD" project and press "Build"
    • Wait until build finished.
    • In project explorer, right click "INSTALL" project and press "Build"
  • Finally in order to allow new projects to find dinamyc libraries add following path to "System path variable"
    • libpng bin directory. 4 ex: "C:\Program Files (x86)\libpng\bin"
    • zlib bin directory. 4 ex: "C:\Program Files (x86)\zlib\bin"
    • flann bin directory. 4 ex: "C:\Program Files (x86)\flann\bin"
    • qhull bin directory. 4 ex: "C:\Program Files (x86)\qhull\bin"
    • vtk bin directory. 4 ex: "C:\Program Files (x86)\VTK\bin"
    • pl bin directory. 4 ex: "C:\Program Files (x86)\PCL\bin"


  • To use PCL in own project using cmake, add following:
find_package(PCL 1.2) // Or other version. 
include_directories(${PCL_INCLUDE_DIRS}) 
link_directories(${PCL_LIBRARY_DIRS}) 
add_definitions(${PCL_DEFINITIONS}) 
add_executable(testExe ${SOURCE_FILES}) 
target_link_libraries(testExe LINK_PUBLIC ${PCL_LIBRARIES})

  • Troubleshooting. Other possible errors.
    • "correspondence.h(75): warning C4003: not enough actual parameters for macro 'max'" or similar. This error means that "max" macro (And also "min" macro) of std collide with other definition of it (For example, with Eigen one). This error can be avoided adding following lines in the beginning of the headers that throw that errors:
#ifdef max 
#undef max 
#endif 
#ifdef min 
#undef min 
#endif

    • Cant find Boost: This error can arise from many reasons
      • Depend on cmake version, it's possible that your boost version is listed internally. Go to file "C:\Program Files (x86)\CMake\share\cmake-3.4\Modules\FindBoost.cmake" (check cmake instalation folder). Go to lines 514-522. Check if your version is in that list. If not, add it.
      • If previous point do not solve your trouble add this two variables to your Environment Variable System:
        • BOOST_DIR = C:\Boost
        • BOOST_INCLUDE_DIR = C:\Boost\include
    • "Cannot open include file: 'vtkgl.h': No such file or directory": This means that VTK has not generated properly that file. The vtkgl.h include file contains all the constants and function namespace safe way.  vtkgl.h is built from parsed glext.h, glxext.h, and You can also grep vtkgl.h (which will be in the binary build directory  (which will be in the binary build directory if VTK is not installed) for appropriate names.  There are also special extensions GL_VERSION_X_X (where X_X is replaced with a major and minor version, respectively) which contain all the constants and functions for OpenGL versions for which the gl.h header file is of an older version than the driver.
      • It is suppose to be generated, so firstly, try to remove all vtk  files, and call cmake again. Before recompiling VTK check that the file exists.
      • If problem persist, put a comment I'll try to help you.
PLEASE, don't doubt to put a comment if need some help, some step is missing or you think that something has changed!

Self-Controlled ARdrone (Part I) - Adding extra hardware.

On the previous entry, I showed my new Library ARdrone++. Now I want to show you in a few entries how to auto-control your ARdrone from a computer attached to it.

The computer
In my case, I use an Odroid U3, a small ARM-based computer with good relation weight-ComputerCapability.

Odroid U3 has a Cortex-A9 Quad Core 1.7Ghz CPU 2GB of RAM and a Mali-400 GPU. It weight ~28g without heatsink and 48g with it. Let me insist again on weight, this is very important because ARdrone is not designed to lift anything but itself.
Adding a new computer  carry a new trouble, it's power supply. There are two options here depending on the consumption of the computer. The first one is to use the USB of the ARdrone to steal to it energy. And the second one is add another battery to the drone. Let me show you pros and cons of both solutions:
  • Use the on-board USB: This solution has one key advantage: No extra battery-No additional weight. The main disadvantage is that consumes ARdrone battery and has current limitations. So if you plan to use many USB peripherals you should pass to next solution. 

  • Add a new battery: In this case I decided to use a one-cell Li-ion battery. this kind of batteries have high energy density. The only fact yo consider is that usually provide 3.7 output voltage, and the most of computers need 5V a power supply. To solve this trouble I take a Boost SMPS from a portable mobile charger (These has 2 pros, increase the voltage and can be use to recharge the battery):

Finally, to allow odroid.u3 to connect to ARDrone, we need a USB wifi module:
Assembly
Now we've everything!. The battery I chose was flat enough to be placed on the drone battery, if you have someone similar place there.


The best place for the computer is on the bottom due to space. The only issue is not to cover the ground sensors (Camera and US-sensor). Use some kind of double stick tape to attach it and for security, grab it with a pair of rubber bands (These will push it to the tape and prevent it to loose if tape lose stickiness due to vibrations).


And that's it! In future tutorials, I will show you how to connect the computer to the ARdrone and control it from inside!