Shop OBEX P1 Docs P2 Docs Learn Events
MyActivityBot (Android App) - Motion-Control your bot — Parallax Forums

MyActivityBot (Android App) - Motion-Control your bot

MacTuxLinMacTuxLin Posts: 821
edited 2014-09-15 00:49 in Learn with BlocklyProp
Received my ActivityBot over a month back but just didn't had the time to do anything with it other than feeling happy about it. Anyway, managed to complete my last design & take a little time off to tinker with my new toy. When I first received it, I sort of have an idea what I'll do with it but just KIV till now. And, I had not been spending time on this forum so I'm not sure if anyone have already done this so pardon me if its a repeat project. I've spent about 3 days assembling, writing the C code in SimpleIDE and wrote the Android App to use motion control the bot.

Simple User Guide
Just done up a simple User Guide.

Android App
I've published the Android App in Google marketplace. Please look for MyActivityBot & download to your smartphone.

Bot Setup
I bought the Easy Bluetooth a few years ago but never really did anything with it so I mount it on my bot. You can use any Bluetooth module as long as you are able to communicate via UART to your board. And, I know, I've mounted the board in the reverse but I'm too lazy to do it right at the moment :lol:
2013-11-30 03.14.17.jpg


C Code
I'm attaching the simple code since most of the hard work were already done by the Parallax team. I had, however, encountered some weird problems. E.g.
int main(){
fdserial *portNumPt = fdserial_open(rxPort, txPort, modeValue, baudRate);
:
:

This works but if I placed this in a function like:
int main(){

   setComm();
:
}

void setComm(){
   fdserial *portNumPt = fdserial_open(rxPort, txPort, modeValue, baudRate);
}
This doesn't work. Not sure why as I have done such in AVR C/AS6 without issues. Also, the volatile uint variable doesn't seems consistent (I've commented in the code).

Anyway, hope you guys will enjoy this. If you want to have higher speed, then just add another multiplier to the drive_speed().

Cheers
«1

Comments

  • edited 2013-12-02 10:31
    Hi Kenichi,

    Wow, what a fantastic project!

    I will probably move this to the Projects forum because it is outside the scope of the Learn tutorials at this point. We might add a sticky post with links to interesting projects like this so that folks looking will have an easier time finding. For this project, we might also ask your permission to publish it in the Projects section of learn.parallax.com. Would that be okay?

    About the serial communication question, the answer is to declare your serial type globally (above any functions) so that code in any function in that file can work with it, like this:
    ...
    fdserial *portNumPt;
    
    int main()
    {
      portNumPt = fdserial_open(rxPort, txPort, modeValue, baudRate);
      ...
    


    With the code like that, you'll be able to move that initialization to another function (like your setComm) because the portNumPt pointer will be visible there as well as in any other function in that file.

    Andy
  • jazzedjazzed Posts: 11,803
    edited 2013-12-02 12:49
    Kenichi!

    Great work.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-12-02 18:18
    I will probably move this to the Projects forum because it is outside the scope of the Learn tutorials at this point. We might add a sticky post with links to interesting projects like this so that folks looking will have an easier time finding. For this project, we might also ask your permission to publish it in the Projects section of learn.parallax.com. Would that be okay?
    Thanks Andy. Yes & Yes, please do. I'd love to hear people having fun with their bot using this app. At least I am:lol:. BTW, sorry as I was so eager to publish this app that I've forgotten to ask Parallax permission in using the ActivityBot's pix. Please let me know if it is alright in continuing publishing the app using this pix, if not, I can change & update the app in Google Play.

    About the serial communication question, the answer is to declare your serial type globally (above any functions) so that code in any function in that file can work with it, like this:
    OK, got it. So I guess the function fdserial_open() must be in main().
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-12-02 18:19
    Thanks Steve. Take a break & have some fun too.:smile:
  • edited 2013-12-03 10:49
    Kenichi,

    Thank you very much for your permission to point to and potentially republish your material on our learn site. We greatly appreciate it, and many ActivityBot enthusiasts will too! I'm pretty sure using our picture is fine for this, but will forward your question to our editor in case she has any suggestions.

    About the serial communication, you do not have to place fdserial_open in main. The trick is to declare your fdserial type outside of main so that it's global. So, this should work:
    fdserial *uart;
    
    main
    {
      uartInit();
      ...
    
    void uartInit(void)
    {
      uart = fdserial_open(31, 30, 0, 115200), it should work fine
    


    In contrast, this will not work because you are declaring the fdserial type within a function. When the function is done, the uart pointer is gone:
    main
    {
      uartInit();
      ...
    
    void uartInit(void)
    {
      fdserial *uart = fdserial_open(31, 30, 0, 115200)
    


    Andy
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-12-03 21:07
    Oh, :tongue:. So I've got to class globally it instead of global int then parsing it. My mistake. Thanks Andy.
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2013-12-04 15:27
    MacTuxLin wrote: »
    BTW, sorry as I was so eager to publish this app that I've forgotten to ask Parallax permission in using the ActivityBot's pix. Please let me know if it is alright in continuing publishing the app using this pix, if not, I can change & update the app in Google Play.

    Yes, you hereby have our enthusiastic permission to use the ActivityBot photo with the Google Play app!! What a great project. I'd like to give this a try with my Samsung tablet to see what happens.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-12-04 20:40
    Yes, you hereby have our enthusiastic permission to use the ActivityBot photo with the Google Play app!! What a great project. I'd like to give this a try with my Samsung tablet to see what happens.

    Thanks Steph. Just uploaded v1.1.1 (solve a bug). :tongue:
  • NWCCTVNWCCTV Posts: 3,629
    edited 2013-12-04 22:51
    I am assuming this can be done with a Prop BOE also, correct? Any documentation as to how to set it all up?

    Edit: Very nice work indeed. I have been trying to get an EBT module to work with the Prop and this will make life much easier.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-12-04 23:48
    Yeap, it should be able to control any 2-wheel bot as long as it complies with this requirement.
    drive_speed(cmdStream[0] * cmdStream[2], cmdStream[1] * cmdStream[2]);
    

    cmdStream[0] => Left Signal.
    cmdStream[1] => Right Signal.
    cmdStream[2] => Acceleration multiplier

    Have fun!

    Oops, sorry, I'll try to write up the documentation soon as I'm juggling with a few things at the moment.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-12-05 02:37
    Just did a simple user guide & added to post# 1.
  • twm47099twm47099 Posts: 867
    edited 2013-12-13 21:47
    I've read through this thread with great interest and would like to try this with my Activitybot. However, I read that Easybluetooth is no longer available, and I see that Parallax no longer carries any bluetooth boards.
    Are there any available bluetooth boards that work with the Activity board that could be recommended (with source)?

    Thanks
    Tom
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-12-13 23:36
    Yeah, thought Parallax was carrying the RN-42 Bluetooth module but just saw that the "product not available" tag.

    Sparkfun has a number of them but I found one fairly reasonable in terms of cost. https://www.sparkfun.com/products/10269. I have not tried this module myself but looking at the schematics, it seems quite straightforward. The only drawback I see is that they include a regulator onboard so it operates at 5v instead of the module's 3v3. Most likely they made it for Arduino. You might need a voltage translator for your Rx & Tx pins connecting to your prop. Other than that, I see they have some code examples.
  • twm47099twm47099 Posts: 867
    edited 2013-12-15 14:52
    MacTuxLin wrote: »
    Yeah, thought Parallax was carrying the RN-42 Bluetooth module but just saw that the "product not available" tag.

    Sparkfun has a number of them but I found one fairly reasonable in terms of cost. https://www.sparkfun.com/products/10269. I have not tried this module myself but looking at the schematics, it seems quite straightforward. The only drawback I see is that they include a regulator onboard so it operates at 5v instead of the module's 3v3. Most likely they made it for Arduino. You might need a voltage translator for your Rx & Tx pins connecting to your prop. Other than that, I see they have some code examples.

    Thanks for the response. That product is also out of stock with no intention of restocking. Do you think that this product might work ?
    https://www.sparkfun.com/products/11601

    It uses the RN-42 in an Xbee form, and would plug into the XBee socket on the Activity Board. It appears that the necessary pins would be available to connect to. It also is a 3.3v board, and very reasonably priced.

    Thanks
    Tom
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-12-16 01:44
    Hey, this looks like a very good catch :thumb:. Its datasheet says it supports UART & SPP so it should work with this app. You'll just need to connect the ActivityBot's Xbee DO & DI pins from its header over to the prop's pin direct since this Bluetooth module's Tx pin is driving at only 8mA but no harm in placing current-limiting resistors, though.
  • jazzedjazzed Posts: 11,803
    edited 2013-12-16 03:05
    MacTuxLin wrote: »
    Hey, this looks like a very good catch :thumb:. Its datasheet says it supports UART & SPP so it should work with this app. You'll just need to connect the ActivityBot's Xbee DO & DI pins from its header over to the prop's pin direct since this Bluetooth module's Tx pin is driving at only 8mA but no harm in placing current-limiting resistors, though.
    Have you tried the BluetoothBee with an HC05 (or other HC module)?

    I have some HC05 modules, and ordered some BluetoothBee PCBs. I could probably give some away at my cost depending on yield ($20+postage US only). Here's a link for the same module: http://www.robotshop.com/en/seeedstudio-bluetooth-bee.html
  • MacTuxLinMacTuxLin Posts: 821
    edited 2013-12-16 03:17
    jazzed wrote: »
    Have you tried the BluetoothBee with an HC05 (or other HC module)?

    I have some HC05 modules, and ordered some BluetoothBee PCBs. I could probably give some away at my cost depending on yield ($20+postage US only). Here's a link for the same module: http://www.robotshop.com/en/seeedstudio-bluetooth-bee.html

    Yeap, I've tested HC-05 & HC-06 modules & they worked without any problems too. Didn't recommend to Tom as the pitch were so narrow & there weren't any breakout boards the last time I searched but since Steve pointed it out, its probably worth taking a look too.
  • jazzedjazzed Posts: 11,803
    edited 2014-01-03 19:32
    Hi Kenichi.

    I found that the simpletext serial port has some trouble receiving from the HC05. I'll be updating simpletext to fix that and add some functionality soon.

    Still have some other things to do before trying your app.

    Happy New Year.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2014-01-05 23:20
    Happy New Year Steve.

    Yea, I just tried my HC-06 on my ActivityBot & couldn't receive anything too. Previously I tested HC-0x with PropTools without problem so I assume it should be fine.

    2014-01-06 15.15.37-small.jpg
    327 x 184 - 43K
  • jazzedjazzed Posts: 11,803
    edited 2014-01-06 09:00
    Hi Kenichi,

    The problem exists only with the default simpletext serial IO (the RX sample delay is wrong for some devices).

    Here is an example terminal using fdserial.
    /**
     * This is the main xbee-terminal program file.
     */
    #include "simpletext.h"
    #include "fdserial.h"
    
    int main(void)
    {
      extern text_t *dport_ptr; // default debug port pointer gets reassigned to fdserial.
      char ch;
      fdserial *xbee = fdserial_open(13,12,0,9600); // P13 connected to DO, P12 connected to DI
      simpleterm_close();
      dport_ptr = (fdserial_open(31,30,0,115200));
    
      putLine("Starting terminal");
    
      while(1) {
        if(fdserial_rxReady(xbee)) {
          ch = readChar(xbee);
          writeChar(xbee,ch);
          putChar(ch);
        }
        if(fdserial_rxReady(dport_ptr)) {
          ch = getChar();
          putChar(ch);
          writeChar(xbee, ch);
        }
      }
      return 0;
    }
    
  • MacTuxLinMacTuxLin Posts: 821
    edited 2014-01-06 18:54
    :blush: Sorry Steve! I've forgotten to reset the baudrate when I changed to HC-06 in the header file so that's why no comm. Its good.
  • MacTuxLinMacTuxLin Posts: 821
    edited 2014-02-05 06:36
    Had a bit of time so I cleaned up my code a bit & push to my google respository.

    http://code.google.com/p/myactivitybot/
  • jazzedjazzed Posts: 11,803
    edited 2014-02-05 20:07
    MacTuxLin wrote: »
    Had a bit of time so I cleaned up my code a bit & push to my google respository.

    http://code.google.com/p/myactivitybot/

    Thanks for sharing!
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-12 23:18
    Is the code in Post# 1 the final code with all the edits included?
  • ValeTValeT Posts: 308
    edited 2014-09-13 06:02
    Can you post the code for the android app?

    Once I get past my first month of school, I am going to try to write an Android app for one of my Parallax projects, and would like to get my hands on some sample code first.

    Thanks
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-13 20:01
    Does anyone know where the user guide from post number 1 went?

    https://www.dropbox.com/s/ep1hursll8f6oim/MyActivityBot%20(v1)-%20User%20Guide.pdf
  • twm47099twm47099 Posts: 867
    edited 2014-09-13 20:20
    NWCCTV wrote: »
    Does anyone know where the user guide from post number 1 went?


    Here's a copy

    Tom
  • MacTuxLinMacTuxLin Posts: 821
    edited 2014-09-13 23:35
    Thanks Tom.

    Sorry, I've recently dropped Dropbox as my 25GB is no longer free. I've moved over to ownCloud but have forgotten to relink the public files.
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-14 09:45
    I thank you very much!!!
  • NWCCTVNWCCTV Posts: 3,629
    edited 2014-09-14 11:02
    I have placed the downloaded program in to my Learn directory such as this: C:\Users\Andyn.NWUPGRADESPLUS\Documents\SimpleIDE\Learn\Examples\Devices\Sensor\KenichiActivityBot

    However, I am receiving the attached errors upon compiling: Please help.
    propeller-elf-gcc.exe -v GCC 4.6.1 (propellergcc_v1_0_0_2408)
    propeller-elf-gcc.exe -I . -L . -I ./library/libabdrive -I ./library/libfdserial -I ./library/libsimplei2c -I ./library/libsimpletext -I ./library/libsimpletools -L ./library/libabdrive/cmm/ -L ./library/libfdserial/cmm/ -L ./library/libsimplei2c/cmm/ -L ./library/libsimpletext/cmm/ -L ./library/libsimpletools/cmm/ -Os -mcmm -m32bit-doubles -fno-exceptions -std=c99 -c OARD -o cmm/OARD
    propeller-elf-gcc.exe: error: OARD: No such file or directory
    propeller-elf-gcc.exe: fatal error: no input files
    compilation terminated.
    Done. Build Failed!
    
Sign In or Register to comment.