Mostrando entradas con la etiqueta SourceCode. Mostrar todas las entradas
Mostrando entradas con la etiqueta SourceCode. Mostrar todas las entradas

domingo, 28 de abril de 2013

Code is uploaded to Sourceforge



Hi folks!

I just uploaded the library with comments and 2 examples to Sourceforge. You have the code here:

https://sourceforge.net/projects/omniplatform/files/

As you can see there, I put quite a lot of comments on the Lib file. It should be easy for you follow the code. 

I create 3 classes: 

B_Wheel: Virtual class to deal with any wheel / driver combination. 

Driver_Wheel: Class to deal with wheels commanded by a driver using 2 outputs to define direction and a PWM output.

Platform: Class able to control a 3 omni-wheel platform. This class uses an array of pointers to B_Wheel variables. This way, this class can control any kind of wheels.

I will extend this lib by providing an additional wheel-drive type: Full Rotation Servo like this one of Sparkfun. This way, 99% of wheel-drive combinations were covered.

The To-Do list is quite long: Full rotation Servo, 4 wheel platform, 2 wheel platform (not omni), incorporation of compass to control direction, LIDAR support...

If you have any question or doubt, please put an comment in this page and I will answer you.

Enjoy!




miércoles, 27 de febrero de 2013

App Inventor


I created the "Omnidrive" App using App Inventor

App Inventor is a programming environment that allows you to create simple Android Apps in an (quite) easy way. Again, it is ligth, (mostly web based) and it is for free. (So far, I didn't use any commercial Software to design my platform. I hope to reach my final target in this way too!)

App Inventor offers you 2 Shells: The Viewer and the Block Editor. The viewer is where you create the Screen of your App. Here you create and organize all the visual (and non visual) elements of your App.
The Block Editor allows you to code your app in a funny way: There is a "white piece of paper" where you put together a kind of puzzle pieces into blocks, each covering a different function linked with the elements you previously created.

But we aware of it: you cannot use this tool to create complex apps. It allows you to use all the nice hardware elements of your Android device (Accelerometer, Photo/Video Camara, Bluetooth, compass, your locations, the music player, etc...). As soon as you want to do something more than just start/stop something, things can go pretty messy. You reach a nice level quite fast, but then you get "glue on your shoes". Each incremental improvement costs you more and more...

In my opinion, a "block" where you could program directly in Java would be a plus.

A feature of App Inventor, and a real nice one, is the ability to use your own device for testing your App nearly in real time via Wi-Fi. You modify something in your computer and, after a few seconds, you can see / test your modified app directly in your device.

All in all, I recommend to use it as an start point to start programming Android Apps. You can even deliver them via the Google Play, as I did with mine!

Remember I publish the source code of this App here!

domingo, 10 de febrero de 2013

The Remote Controller App


These are the steps you should go through to use my App "Omnicontrol" to control your own system.


Elements:

- An Android device with the app loaded on it. You can download the compiled application from Google Play going here.
- A Bluetooth Modem. I use the RN-42.(  https://www.sparkfun.com/products/10269. )
- An Arduino Board. This example works only on the Mega or Leonardo Arduinos. I explain you later why.
- A USB cable.
- Some wiring materials.
- A computer with the Arduino Software.

This is what you must do:

1.- Wire the Modem in this way. 



The red cable is connected to the +5V, the black one to GND. Be informed that the Modem will be delivered to you without headers. So, a little bit of soldering will be needed.

2.- Connect the USB cable and load the test sketch. You can find it here: http://sourceforge.net/projects/omniplatform/files/Arduino%20Code/Bluetooth%20Test%20Sketch/?
It is a very short one!

3.- The modem will blink in red at this moment, because it is not linked to any other Bluetooth source. It's normal.

4.- Switch Bluetooth on in the Android device, search for new devices and pair it with the RN-42 modem.  This is the typical step you perform prior to use any Bluetooth device. Please refer to your Android documentation & the modem documentation if you need more information on this point. The modem shall appear as "Firefly ...........".

5.- Once you paired the devices in the Android device, start there the App "Omnicontrol". Press "Select device".  A list of all paired Bluetooth devices will be presented to you. Please press the name of the Bluetooth Modem you want to connect to (Again, "Firefly........."). You will go back then to the main screen.

6.- Press "Connect". If everything went Ok, after 1 or 2 seconds, the status bar will change from Red to Green and the text "Connected" will appear. The blinking red Led on the Modem switches off and the green one goes on (As in the picture above).

7.- If you press "Power On", the App starts sending telegrams. If you press it again, you stop the transmission. Have a look on this former entry of my blog to see a video with the whole process.

8.- While the communication is on, go to your computer and open the Serial Monitor in the Arduino IDE. (Tools -> Serial Monitor). You will see something like this:

The Structure is quite simple. There are letters, then associated values:
M -> Magnitude
A -> Angle
E -> Switch is On or Off. (E = Enable). When you switch off, you will receive a single time "E0", then communication stops.
T -> Turn

I programmed the Android App in such a way that when "Power On" is false, no communication takes place. If this is not OK for you, you can easily adapt the App to your own needs. F.ex. you may use this On/Off switch to control not the Move Enable but something else mounted on your robot.

The source Code is here: http://sourceforge.net/projects/omniplatform/files/Remote%20Controller/
This App is programmed with AppInventor. I will comment it in a next entry.

On the other side of the comm. channel, in you Arduino real sketch, you can read the values using a simple piece of code. Like this: (This works as it is on a Leonardo. The Serial1 must be changed to Serial2, 3 or 4 in the Arduino Mega)
-------------------------------------------------------------------------------------------
r = Serial1.read();
    switch (r)
    {
      case 'M' : vel = Serial1.parseInt();              // Magnitude
      case 'A' : ang = Serial1.parseInt();              // Angle
      case 'E' : moveEnable = Serial1.parseInt(); // Move Enable
      case 'T' : turning = Serial1.parseInt();         // Turning
    }
-------------------------------------------------------------------------------------------

I suggested you to use an Arduino Leonardo or Mega. Both boards have at least 2 Serial ports. This way you can upload & debug your Sketch through one port, while the Bluetooth communication is working on the other. This allows you to keep everything in place while modifying & debugging your sketchs.

The Arduino UNO has only 1 Serial port used for everything, included upload your sketchs.

This means: in an UNO, if you have the Bluetooth modem connected, you cannot connect your computer. Using this board is perfectly possible, but you will need to re-wire constantly from one configuration to the other each time you upload / test your sketch. Needles to say, the above mentioned test will not work on an UNO.

Bluetooth is tricky but the RN-42 do a nice job, making things much easier as I would expect. I ordered by mistake the HID version. It can be used too, but I recommend to use the normal one, the one I indicated before.

When using the Bluetooth modem, be sure to have adjusted the proper Baud Rate in your Arduino Serial Port (default value is 115200 Bauds) and that the Modem is working in SPP mode. If you are using the HID version, you must switch to this mode before using it. Again, refer to the modem documentation to see how to do it.

I didn't test this system with other Bluetooth modems, but if you are able to open a SPP channel with the correct Baud Rate on it, it must work too.

Enjoy!


miércoles, 6 de febrero de 2013

SourceForge


I just created a project in SourceForge to publish all the files of my project.

This is the link:
http://sourceforge.net/projects/omniplatform/files/

I look forward to your comments!