Shop OBEX P1 Docs P2 Docs Learn Events
Normal polygons and Circles with ActivityBot — Parallax Forums

Normal polygons and Circles with ActivityBot

NikosGNikosG Posts: 705
edited 2014-02-16 13:05 in Learn with BlocklyProp
Helo everybody,

In this thread I will try to explain how we can make polygonal and circular orbits with a deferential robot. I will give you some examples of regular polygons and circles, first using mathematics, and then giving the algorithms which can be implemented in ActivityBot of Parallax and various other robots (like the S2). But first it is necessary to have studied and analyzed the problem of the rotation of every particular robot. We should be able to program the robot to do the right rotations (clockwise or counterclockwise) according the various angles 0 ° < ω < 360 ° that we want to turn.

[size=+2] Rotation of ActivityBot ω degrees [/size]

Studying the examples of ActivityBot Navigation you can see that the drive_goto(26, -25) command makes the ActivityBot to execute a 90-degree right turn. Let’s see this example closer and try to create a formula in order to calculates the appropriate “ticks for” this command for a random angle ω.

attachment.php?attachmentid=104934&d=1384294949


As the ActivityBot makes a rotation it moves its wheels on the red circle which has radius 52.9mm. If the robot makes a turn equal to 1 rad, each wheel will make a distance equal to the radius r of the red circle. Thus 1 rad rotation of the ActivityBot is equivalent to movement of the wheels at a distance r=52,9mm= 52,91/3,25 ticks= 16,2769 ticks . Changing rad to degrees we take the formula: Ticks for Angle= ω * 0,284. So if we want to program the ActivityBot in order to rotate ω degrees we can multiply by 0,284 in order to find the appropriate wheel ticks.
To verify the above formula we can see that a rotation 90 degrees=90*0.284 ticks=25,56ticks=26 ticks

In the image above, you can also see a useful table with some angles that we will use in the next steps.

[size=+2] Making Polygonal paths using robots[/size]

Polygon is a closed shape that has N vertices and N sides (N ≥ 3). Specifically regular polygon is the polygon that has all sides equal.
So some categories of normal polygons for example are:
The equilateral triangle (N = 3 ) , the square (N = 4 ) , the regular pentagon (N = 5), the regular hexagon (N = 6 ) etc.
Normal polygons with (N ≥ 36) have a special interest, because they are practically close to the circle. Although there are not real cycles, in practice these polygons can represent a circle with very good precision.

We will try now to do orbits of regular polygons with the ActivityBot.

In order to achieve these goals it is essential to know the external angle of the normal polygon in order to give the robot the appropriate command to turn properly. The external angle ω , of a normal polygon (n>=3) is given by the formula: ω=360/N

attachment.php?attachmentid=104942&d=1384294966


So in order to make (clockwise) an equilateral triangle with side S, using the ActivityBot we must give the following commands:

attachment.php?attachmentid=104935&d=1384294953

The SimpleID code is:

attachment.php?attachmentid=104936&d=1384294955

If we want the robot to do a square path of side S (clockwise) we need to give the following commands:

attachment.php?attachmentid=104937&d=1384294957

The SimpleID code is:

attachment.php?attachmentid=104938&d=1384294959

If we want the robot to do a normal pentagon path of side S (clockwise) we need to give the following commands:

attachment.php?attachmentid=104939&d=1384294962

The SimpleID code is:

attachment.php?attachmentid=104940&d=1384294962

We can give a general algorithm for every normal polygon with N vertices (Ν≥3) and side S (clockwise):

attachment.php?attachmentid=104941&d=1384294965


Nikos Giannakopoulos
1024 x 883 - 113K
997 x 697 - 109K
513 x 313 - 40K
1024 x 681 - 56K
504 x 327 - 38K
954 x 689 - 137K
512 x 320 - 34K
1024 x 647 - 54K
876 x 818 - 77K

Comments

  • Steph LindsaySteph Lindsay Posts: 767
    edited 2013-11-12 15:25
    Nikos, this is beautiful!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-11-12 16:40
    What Steph said! Your presentations are always top notch!

    BTW, Nikos, have you seen the latest S2 GUI (beta) build with the Greek language translation? If not, give me your email address, and I'll send it to you.

    -Phil
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2013-11-12 17:18
    BTW, Nikos, have you seen the latest S2 GUI (beta) build with the Greek language translation? If not, give me your email address, and I'll send it to you.

    -Phil

    Phil, Nikos, I posted it here: http://www.parallax.com/downloads/s2-gui-software
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-11-12 19:35
    Thank you. Steph!

    -Phil
  • NikosGNikosG Posts: 705
    edited 2013-11-13 05:52
    Stephany and Phil,

    I have already installed the GUI-v1.4 Beta on School's new lab in order to use it in my class.
    This Lab has Ubuntu as operating system but the server has also windows. I succesfuly installed the new GUI on server under windows and I can also share the application on the other terminal computers. However I haven't test the software using the robot. In the past I had some problems because many times I couldn't upload programs on my S2.(I suppose it was a driver issue)
    I'll test it again now and I'll send you a feedback.

    @Phil,
    I'm trying to find a way to turn the S2 in a specific angle using the motion tile icon on GUI, in order to make normal polygons using my S2.
    I think that GUI doesn't help very much in this point. I think that the only way to approach a speciffic angle in this way is to calculate the time for this speciffic angle. Have I right? Is any other way to achieve this goal using the GUI?


    Nikos.
  • Steph LindsaySteph Lindsay Posts: 767
    edited 2013-11-13 09:57
    NikosG wrote: »
    Stephany and Phil,

    I have already installed the GUI-v1.4 Beta on School's new lab in order to use it in my class.
    This Lab has Ubuntu as operating system but the server has also windows. I succesfuly installed the new GUI on server under windows and I can also share the application on the other terminal computers. However I haven't test the software using the robot. In the past I had some problems because many times I couldn't upload programs on my S2.(I suppose it was a driver issue)
    I'll test it again now and I'll send you a feedback.
    Nikos.

    Hi Nikos,

    I am not sure that you can program the S2 from a Linux terminal and Windows server with the Propeller Tool (which is utilized by the GUI). I know that we usually recommend local installation. I will check into that.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-11-13 10:08
    NikosG wrote:
    I think that the only way to approach a speciffic angle in this way is to calculate the time for this speciffic angle. Have I right?
    Yes, that's right. Getting the correct angle will require juggling individual wheel speeds and the time they spend at those speeds. This is a consequence of trying to maintain backwards compatibility with the original Scribbler, which did not have wheel encoders. However, with the S2, the turning will be precise and repeatable, because the speed*time for each wheel is converted directly into an encoder pulse count, with a forced time-out only after twice the programmed time.

    -Phil
  • Jeff MartinJeff Martin Posts: 757
    edited 2013-11-13 10:11
    Hi Nikos,

    I am not sure that you can program the S2 from a Linux terminal and Windows server with the Propeller Tool (which is utilized by the GUI). I know that we usually recommend local installation. I will check into that.

    The Propeller Tool should be able to work from a networked installation, but I wouldn't be able to guarantee that it works for Propeller programming (downloading) via a connected terminal where the Propeller is physically connected.

    How is the terminal connection made? Some kind of Windows emulation? If so, have you tried locally installing the Windows USB drivers? http://www.parallax.com/downloads/parallax-usb-driver-installer
  • PublisonPublison Posts: 12,366
    edited 2013-11-13 10:13
    Nikos,

    That is an awesome post! Thanks so much for the information. This is great for students all around the world..

    Jim
  • NikosGNikosG Posts: 705
    edited 2013-11-13 15:00
    [size=+2]Approaching the circle as a normal polygon[/size]

    As we said before, circle has a special interest because we can approach it with a normal polygon with 36 vertices.

    attachment.php?attachmentid=104980&d=1384383016

    So, if we want the robot to do a circle (clockwise) we need to give the following commands:

    attachment.php?attachmentid=104981&d=1384383019

    Have in mind that the S mustn’t be a big number because circle will be huge!
    At this point choose for S small numbers. For instance in the next example the S= 8 ticks.
    The following SimpleID code programs the ActivityBot in order to make a circle with radius 15cm approximately:

    attachment.php?attachmentid=104982&d=1384383020

    The question that arises is: how much should be the S in order to take a circle with a specific R? In other words can I calculate the S as a function of R?
    Math theory gives the answer again with the “Cosines Law”. Looking at the triangle OA1A2 we can see that:

    attachment.php?attachmentid=104983&d=1384383022

    At this point we are almost ready for the final algorithm that will be able to create any circles with a given radious r and ofcourse any other normal polygon isnide this circle.


    Nikos Giannakopoulos
    613 x 541 - 39K
    1024 x 704 - 74K
    512 x 309 - 40K
    1024 x 528 - 47K
  • NikosGNikosG Posts: 705
    edited 2013-11-13 15:14
    The Propeller Tool should be able to work from a networked installation, but I wouldn't be able to guarantee that it works for Propeller programming (downloading) via a connected terminal where the Propeller is physically connected.

    How is the terminal connection made? Some kind of Windows emulation? If so, have you tried locally installing the Windows USB drivers? http://www.parallax.com/downloads/parallax-usb-driver-installer

    Jeff,
    The terminal connection now in my Lab is a kind of Windows emulation. In the past (before the Ubuntu instalation ) I had only Windows. However I had many problems with the drivers. (I had installed them many times from the link you said before but always I had problem and I used my notebook in order to load the programs into S2)
  • jazzedjazzed Posts: 11,803
    edited 2013-11-13 15:16
    Such wonderful posts!

    Thanks for sharing.
  • NikosGNikosG Posts: 705
    edited 2013-11-13 15:20
    However, with the S2, the turning will be precise and repeatable, because the speed*time for each wheel is converted directly into an encoder pulse count, with a forced time-out only after twice the programmed time.

    -Phil
    Phil,

    How we can I do this in practice using the GUI ? Must I write a subroutine?
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-11-13 21:30
    NikosG wrote:
    How we can I do this in practice using the GUI ? Must I write a subroutine?
    To make a turn in the GUI, the left and right wheel "speeds" should be equal, but opposite in sign. Let's call that speed Spd. The relationship of that speed, times the time in milliseconds MoveTime, is
    Spd * MoveTime = TurnDegrees * 1111.1111

    For example, to turn 90 degrees, Spd * MoveTime = 90 * 1111.1111 = 100_000

    Setting Spd to 100 and MoveTime to 1 sec (1000 ms) should do the trick. Of course, not all angles will work out so nicely, given the 50 ms granularity of the times.

    -Phil
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-11-13 23:31
    NikosG wrote:
    I have already installed the GUI-v1.4 Beta on School's new lab in order to use it in my class.
    Nikos,

    Can you confirm for me, please, whether the newly-added Unicode capability and consequent Greek translation are working properly for you? IIRC, there might be a couple holes in the file greek.dic that still need to be filled with correct translations.

    Thanks,
    -Phil
  • NikosGNikosG Posts: 705
    edited 2013-11-15 11:31
    Can you confirm for me, please, whether the newly-added Unicode capability and consequent Greek translation are working properly for you? IIRC, there might be a couple holes in the file greek.dic that still need to be filled with correct translations.


    Phil

    The Greek Translation of the GUI is very good !
    I can assure you that everyone Greek user can understand the meaning . In addition the icon of each command is perfect and explains the meaning without words.
    However If you want to do a more "Greek" translation here is a screenshot with some small changes:

    Phil ,
    if I could make a suggestion for the GUI, This would be about the motion tile icon. I think that will be very helpful if users could have the choise to turn the wheels specific number of rotations 1,2,3...etct or specific degrees (360 degrees=1 rotation). (something like the Lego NXT motor command)
    1024 x 880 - 116K
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2013-11-15 12:21
    Nikos,

    Thanks for the feedback on the Greek translation. There's a file that comes with the GUI, greek.dic (in the same folder as s2.exe). Would you be willing to take a look at that file, edit it with the better translations, and email it to me?

    Also, I like your suggestion about the motion tile. I will have to figure out a way to do it that doesn't break existing GUI programs.

    Thanks,
    -Phil
  • NikosGNikosG Posts: 705
    edited 2013-11-19 12:32
    Approaching the circle as a normal polygon (prt2)

    The flowchart that describes the final algorithm in order to do a circle with given R is the following:

    attachment.php?attachmentid=105092&d=1384892840


    This algorithm works also well and for all the other normal polygons

    attachment.php?attachmentid=105093&d=1384892845

    As you can see the program can also make your ActivityBot to do any normal polygon inside a circle with a radius r.
    Here are some polygons and circle that you can make with your AcrivityBot changing the values of variables n, r on the above code.

    attachment.php?attachmentid=105091&d=1384892836

    As a small improvement of the above code we can change it in order to make the circles and the polygons, clockwise or counterclockwise according to our needs.

    Nikos Giannakopoulos
  • NikosGNikosG Posts: 705
    edited 2014-01-15 12:12
    Following Phil’s suggestion from post #15 , we can calculate the crucial angles for normal polygons in order to program and the S2 robot.
    We can make calculation easier using the Excel.

    attachment.php?attachmentid=106198&d=1389816296

    At the end of the post I provide a spreadsheet that can help. So here is a table with some of the angles we use in order to draw normal polygons and circles using the S2

    Following the algorithms that I mentioned on Post #1 we can make:

    A triangle:

    attachment.php?attachmentid=106193&d=1389816278

    A square:

    attachment.php?attachmentid=106194&d=1389816282

    A normal pentagon:

    attachment.php?attachmentid=106195&d=1389816286

    A normal hexagon:

    attachment.php?attachmentid=106196&d=1389816288

    A circle:

    attachment.php?attachmentid=106197&d=1389816291

    The attached file "S2_polygons_code" has also the code for your S2.

    Nikos Giannakopoulos
    1024 x 423 - 61K
    1024 x 391 - 59K
    1024 x 397 - 59K
    1024 x 397 - 55K
    1024 x 370 - 53K
    1024 x 720 - 145K
  • NikosGNikosG Posts: 705
    edited 2014-02-16 13:05
    You can see "Normal polygons using the S2 robot" in Greek language on my personal blog here:
    http://gianakop.blogspot.gr/2014/02/blog-post.html

    Greek students and teachers, will also have the opportunity to admire the s2 robot drawing normal polygons and many other drawings, in our presentation (me and with my students) on 4th Students Festival in Patras that will take place on 1rts General Lyceum of Patras on 3-4 of April 2014.

    Nikos Giannakopoulos
Sign In or Register to comment.