Author Topic: My small walking robot project ...  (Read 3481 times)

0 Members and 1 Guest are viewing this topic.

Offline MarcoPajotter

  • Newbie
  • Posts: 6
    • View Profile
My small walking robot project ...
« on: April 20, 2021, 08:45:47 am »
Hello everyone,

I love building small robots,
now I'm playing with the idea to build a walking robot.
I want to use a LATTE PANDA DELTA 432 - Win 10 pro x64 with a FHD display and QB64 for the GUI Human Machine Interface.
And an Arduino DUE for all the hardware connections, like GPS, 9 DOF sensor (compass, accelerator, )
So I need a USB serial connection between the LATTE PANDA and the ARDUINO DUE.

Q1) Is here someone who have some experiences with this communication ?
Q2) Is it possible to read and use the touch screen (mouse) data in QB64 ?

Greetings,
thanks,

Marco

PS: How can I show some images here on the forum ?
- every professional was once an amateur - greetings from Pajottenland - Belgium -
I love building small robots
PS: sorry for my english I speak flemish ...

Offline Cobalt

  • QB64 Developer
  • Forum Resident
  • Posts: 878
  • At 60 I become highly radioactive!
    • View Profile
Re: My small walking robot project ...
« Reply #1 on: April 21, 2021, 12:20:54 am »
Q1) Is here someone who have some experiences with this communication ?
Q2) Is it possible to read and use the touch screen (mouse) data in QB64 ?


PS: How can I show some images here on the forum ?

A1) Yes and No,  I have interfaced with older style Fischertechnik interfaces but nothing newer.  (there is a post somewhere around here)
A2) Not sure, imagine it depends on how the OS handles input from a touch screen, I unfortunately have never had enough $$$ to purchase a computer with touch screen capabilities to play with
      that possibility. If the OS treats the screen like a mouse then I guess you could probably use it with QB64.

PS. A) Right below the text box says Attachments and other options with a little plus in front. click on that and select a file to attach.
Granted after becoming radioactive I only have a half-life!

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: My small walking robot project ...
« Reply #2 on: April 21, 2021, 07:49:31 am »
Hi

Very interesting project.

Few years ago I worked on communication between ardunio and android basic via Bluetooth. From what I remember the USB connection gets converted to a serial comm port on the pc so the communication is serial and qb64 already has serial communication via print and input. I will see if I still have an ardunio and try hooking it up to qb64.
Pretty sure windows converts touch screen movements and taps to mouse so qb64's mouse command's would work fine.
Brian ...

FellippeHeitor

  • Guest
Re: My small walking robot project ...
« Reply #3 on: April 21, 2021, 09:44:33 am »
Pretty sure windows converts touch screen movements and taps to mouse so qb64's mouse command's would work fine.

It does. Here's my TTTRings clone being played on a touch enabled device:


Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: My small walking robot project ...
« Reply #4 on: April 21, 2021, 02:06:26 pm »
There are supposedly GPS receivers sensitive enough to work indoors, but I bet
they're expensive.  Maybe your robot will stay outdoors, squashing squirrels.

For ideas re indoors:
https://en.wikipedia.org/wiki/Indoor_positioning_system

It's fun to track purple arrows (my attached ancient tracking system), which used
CDPD (Cellular Digital Packet Data).
It works better if you plug it in.

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: My small walking robot project ...
« Reply #5 on: April 21, 2021, 02:40:42 pm »
Hi

Found an Arduino in my shed, put a primitive sketch on it that listens for commands "fast", "med" and "slow" on the serial port then flashes its on board LED accordingly, then wrote a little QB64 program to send commands via serial port.
As proof of concept it works.



Arduino sketch.
String inputString ="";
int fspeed = 500;
char code = "x";

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  Serial.begin(9600);

}

void loop() {
  // put your main code here, to run repeatedly:
  //Serial.println(code);
  digitalWrite(LED_BUILTIN, HIGH);
  delay(fspeed);
  digitalWrite(LED_BUILTIN,LOW);
  delay(fspeed);
}

void serialEvent()
{
  while(Serial.available())
  {
    char ch = (char)Serial.read();
    Serial.write(ch);
    inputString += ch;
    if(ch == '\n')
    {
      if(inputString == "fast\r\n"){
        fspeed = 50;
        code = "s";
      }
      if(inputString == "slow\r\n"){
        fspeed = 1000;
        code ="f";
      }
      if(inputString == "med\r\n"){
        fspeed = 500;
        code ="f";
      }
      inputString ="";
     
    }
  }
}

Code: QB64: [Select]
  1.  
  2. Type button
  3.     x As Integer
  4.     y As Integer
  5.     w As Integer
  6.     h As Integer
  7.     code As String
  8.     imageH As Long
  9.  
  10. Type vector2
  11.     x As Integer
  12.     y As Integer
  13.  
  14.  
  15. Dim Shared speedBtn(3) As button
  16. Dim Shared mousePos As vector2
  17. Dim Shared currMode As String
  18.  
  19. Dim comP As Long
  20. Dim comPno As String
  21. Dim comPmode As String
  22.  
  23. currMode = ""
  24. comP = FreeFile
  25. comPno = "COM3:"
  26. comPmode = "9600,N,8,1,ASC"
  27.  
  28. CreateButtons
  29.  
  30. Open comPno + comPmode For Output As comP
  31.  
  32. _Delay 0.5
  33.  
  34. Screen _NewImage(320, 140, 32)
  35.  
  36.     Cls
  37.     _Limit 30
  38.     DisplayButtons
  39.     _Display
  40.     mousePos.x = _MouseX
  41.     mousePos.y = _MouseY
  42.     ' If the mouse was clicked check if it was selecting a tile, clicking a button or putting a tile on the map
  43.         currMode = CheckButtons
  44.     End If
  45.     If currMode <> "" Then
  46.         Print #comP, currMode
  47.     End If
  48.  
  49.  
  50.  
  51. Close #comP
  52.  
  53.  
  54. Sub CreateButtons
  55.     Dim si As Integer
  56.     Dim currDest As Long
  57.  
  58.     currDest = _Dest
  59.  
  60.     si = 0
  61.     speedBtn(si).imageH = _NewImage(64, 32, 32)
  62.     _Dest speedBtn(si).imageH
  63.     Line (0, 0)-(63, 31), _RGB32(255), B
  64.     _PrintString (10, 2), "Slow"
  65.     speedBtn(si).x = 10
  66.     speedBtn(si).y = 10
  67.     speedBtn(si).w = 64
  68.     speedBtn(si).h = 32
  69.     speedBtn(si).code = "slow"
  70.  
  71.     si = 1
  72.     speedBtn(si).imageH = _NewImage(64, 32, 32)
  73.     _Dest speedBtn(si).imageH
  74.     Line (0, 0)-(63, 31), _RGB32(255), B
  75.     _PrintString (10, 2), "Medium"
  76.     speedBtn(si).x = 110
  77.     speedBtn(si).y = 10
  78.     speedBtn(si).w = 64
  79.     speedBtn(si).h = 32
  80.     speedBtn(si).code = "med"
  81.  
  82.     si = 2
  83.     speedBtn(si).imageH = _NewImage(64, 32, 32)
  84.     _Dest speedBtn(si).imageH
  85.     _PrintString (10, 2), "Fast"
  86.     Line (0, 0)-(63, 31), _RGB32(255), B
  87.     speedBtn(si).x = 210
  88.     speedBtn(si).y = 10
  89.     speedBtn(si).w = 64
  90.     speedBtn(si).h = 32
  91.     speedBtn(si).code = "fast"
  92.  
  93.     _Dest currDest
  94.  
  95.  
  96.  
  97.  
  98. Sub DisplayButtons
  99.  
  100.     Dim si
  101.  
  102.     For si = 0 To 2
  103.         _PutImage (speedBtn(si).x, speedBtn(si).y), speedBtn(si).imageH
  104.     Next si
  105.     _PrintString (120, 90), "Mode " + currMode
  106.  
  107.  
  108. Function CheckButtons$
  109.     Dim si As Integer
  110.  
  111.     CheckButtons = ""
  112.  
  113.     For si = 0 To UBound(speedbtn)
  114.         If RectCollide(mousePos.x, mousePos.y, 1, 1, speedBtn(si).x, speedBtn(si).y, speedBtn(si).w, speedBtn(si).h) Then
  115.             CheckButtons = speedBtn(si).code
  116.             Exit For
  117.         End If
  118.     Next si
  119.  
  120.  
  121. FUNCTION RectCollide (rect1X as integer,rect1Y as integer,rect1Width as integer,rect1Height as integer,_
  122.                       rect2X as integer,rect2Y as integer,rect2Width as integer,rect2Height as integer)
  123.  
  124.     Dim rect1X2 As Integer
  125.     Dim rect1Y2 As Integer
  126.     Dim rect2X2 As Integer
  127.     Dim rect2Y2 As Integer
  128.  
  129.     rect1X2 = rect1X + rect1Width - 1
  130.     rect1Y2 = rect1Y + rect1Height - 1
  131.     rect2X2 = rect2X + rect2Width - 1
  132.     rect2Y2 = rect2Y + rect2Height - 1
  133.  
  134.     RectCollide = 0
  135.     If rect1X2 >= rect2X Then
  136.         If rect1X <= rect2X2 Then
  137.             If rect1Y2 >= rect2Y Then
  138.                 If rect1Y <= rect2Y2 Then
  139.                     RectCollide = -1
  140.                 End If
  141.             End If
  142.         End If
  143.     End If
  144.  
  145.  
  146.  
Brian ...

Offline MarcoPajotter

  • Newbie
  • Posts: 6
    • View Profile
Re: My small walking robot project ...
« Reply #6 on: April 21, 2021, 04:12:54 pm »
Hi everyone,

first at all, thanks for your help.
it is nice to see some working solutions.
so I can start right away ...

it is a big project, so I will be a lot on this forum ;-)

greetings
Marco,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
I love building small robots
PS: sorry for my english I speak flemish ...

Offline 191Brian

  • Newbie
  • Posts: 91
    • View Profile
    • My Itch page
Re: My small walking robot project ...
« Reply #7 on: April 21, 2021, 04:57:26 pm »
Hi Marco

Look forward to seeing the project develop would be happy to help where I can.
Brian ...