Posts Tagged ‘Sanguino’

Friday Night Robotics – Visualizing Data w/Matlab

Posted by Erin, the RobotGrrl on Friday, September 4th, 2009

I recently purchased Matlab since it seems to be pretty popular on this campus, and I’m taking a part of a class on it. You didn’t really have to purchase Matlab though, since you could obtain it through different ways, or use a lab computer. My reasoning was that I wouldn’t want to be stealing from an industry that is computer science related, that’s kind of FAIL, LOL! =) Plus, I wouldn’t want people to steal my software! :P

This software is really cool! You can graph data extremely easily!!!

I did a quick search for Arduino and Matlab, and saw that there were some working results!

I used my Sanguino with the IR sensor to send data to Matlab.

I found some very useful starting code from here . I actually didn’t modify it too much as I was eager to see it run!

  1. /*
  2. *
  3. * Take IR sensor data from Sanguino and put it into Matlab!
  4. *
  5. * Original code comments:
  6. *   Accelerometer Sensor
  7. *   ——————–
  8. *
  9. *   Reads an 3-D accelerometer
  10. *   attached to three digital inputs and
  11. *   sends their values over the serial port;
  12. *   There exists an opposite code to read
  13. *   the values from MATLAB.
  14. *
  15. *   Modified by CARLOS AGELL
  16. *   (www.carlosagell.tk)
  17. *
  18. *   Original code by
  19. *   http://www.0j0.org
  20. *   copyleft 2005 K3 – Malmo University – Sweden
  21. *   @author: Marcos Yarza
  22. *   @hardware: Marcos Yarza
  23. *   @project: SMEE – Experiential Vehicles
  24. *   @sponsor: Experiments in Art and Technology Sweden, 1:1 Scale
  25. */
  26.  
  27. #include <Wire.h>
  28. #include "WProgram.h"
  29. void readAcceleration(int axe);
  30.  
  31. int ledPin = 13;
  32. int xaccPin = 0;
  33. int yaccPin = 1;
  34. int zaccPin = 2;
  35. int value = 0;
  36.  
  37.  
  38. void setup() {
  39. Serial.begin(9600); // Sets the baud rate to 9600
  40. pinMode(ledPin, OUTPUT);
  41. pinMode(xaccPin, INPUT);
  42. pinMode(yaccPin, INPUT);
  43. }
  44.  
  45.  
  46. /* (void) readAccelerometer
  47. * procedure to read the sensor, calculate
  48. * acceleration and represent the value
  49. */
  50. void readAcceleration(int axe){
  51. value = analogRead(axe);
  52.  
  53.  
  54. if (axe == xaccPin){
  55. Serial.print(‘X’, BYTE);
  56. }
  57. if (axe == yaccPin){
  58. Serial.print(‘Y’, BYTE);
  59. }
  60. if (axe == zaccPin){
  61. Serial.print(‘Z’, BYTE);
  62. }
  63.  
  64. Serial.print(value, DEC);
  65. Serial.print(‘ ‘, BYTE);
  66.  
  67. }
  68.  
  69. void loop() {
  70. readAcceleration(xaccPin); //reads and represents acceleration X
  71. digitalWrite(ledPin, HIGH);
  72. delay(1200);
  73. digitalWrite(ledPin, LOW);
  74. }

The matlab code was also from this site, but I commented out a few lines so that there was only one graph line.

  1. %Graph Accelerometer Data
  2.  
  3. s = serial(‘/dev/tty.usbserial-FTE4Z66C’);
  4. set(s,‘BaudRate’,9600);
  5. set(s,‘DataBits’,8);
  6. set(s,‘StopBits’,1);
  7. fopen(s);
  8.  
  9. out =‘a’
  10. figure
  11. hold on    % on keeps all the current plot data, off resets the axes before drawing
  12. xacc =[];
  13. yacc =[];
  14. zacc =[];
  15. for i = 1 : 5000
  16.     out = fscanf(s);
  17.     if(sum(size(out))>0)
  18.         out2 = reshape(out(1:(round(size(out,2)/5)-1)*5),[5 (round(size(out,2)/5)-1)]);
  19.         out2 = out2‘;
  20.        out2 = str2double(out2(1:end,2:end));
  21.        if out(1) == sprintf(‘X‘)
  22.            xacc = [xacc out2(1:3:end)'];
  23.             plot(xacc);
  24.             %yacc = [yacc out2(2:3:end)'];
  25.            %plot(yacc,’r‘);
  26.            %zacc = [zacc out2(3:3:end)’];
  27.             %plot(zacc,‘g’);
  28.         end
  29.         drawnow
  30.     end
  31. end
  32.  
  33.  
  34. fclose(s)
  35. delete(s)
  36. clear s

It works okay, but it’s really slow. Even though the data is being sent every 1.2 seconds, it takes Matlab 10 seconds to plot it! Also, it kept saying this in the command window:


Friday Night Robotics - Data in Matlab

The graph looked like this in the end:


Friday Night Robotics - Data in Matlab

It was pretty exciting to see it being plotted!!

I think what is making it slow is that the data is being stored in an array/matrix, and then the lines are calculated, and then they are plotted.

What I want to do is just have a 3D graph of the IR sensor data over time. It doesn’t have to be a complete history, maybe just the past 10 values. I would also want the delay to be minimal, 100ms at most!

I have no idea how to do this yet, but I’m guessing playing around with that weird out2 variable would be a start. Rewriting the code the way I want it would also be a good place to start, because then I can understand everything that’s going on :D

Oh yeah, and the day I received Matlab was the day the newer version came out that supports 64 bit for Macs. :( but at least I have the second-latest version of the software. :)

There are also these ‘add-ons’ for Matlab called toolboxes. There are gajillions out there for HMMs, Bayes logic, AI, Robotics (Kinematics), Probability, Neural Nets, and sooo much more. I wonder if there is a toolbox for determining the proper ratio of icing to a cupcake though? That would be extremely useful, I should probably make that :P :D

The benefit this has over using Processing to visualize data is that it’s very more robust and mathematical. However, if one wanted to make an art display, Processing would win hands down.

Posted in: Programming, Projects.

Friday Night Robotics – Hula Hooping Motion?

Posted by Erin, the RobotGrrl on Monday, August 24th, 2009

Building on last week’s RGB LEDs, it was time to add some motions to MANOI that would suit the carnival-ish theme.

Friday Night Robotics - MANOI Hula-hooping

A significant amount of time was spent on brainstorming ideas on how to make MANOI walk. The key will be the first step, as it has to get the rhythm started. The following steps will maintain the rhythm. Another point to look at would be shoes for MANOI. For walking, MANOI uses these ‘flip flops’ :

Friday Night Robotics - MANOI Hula-hooping

For skating, MANOI has roller skates that are made out of lego. These shoes are attached by velcro. It would be interesting to see if I could use some ShapeLock to make new shoes. (Shoes, Omg shoes. Shoes. Let’s buy some shoes!) By using ShapeLock, I may be able to eliminate some of the tilting that the velcro introduces, and thus eliminating another reason why the robot may fall.

In any case, I want to build on MANOI’s hip and leg motions like I did with the arm motions. I started with a simple swaying function, but Boom from the Robotics themed floor suggested an awesome suggestion- tilting the body to make it go forward and backward. In the right sequence, this would make a hula hoop motion!

It was interesting the way we did it. Instead of just telling the hip motors to tilt forward, we also told the shin motors to tilt backward. This maintained the center of balance. :D

Friday Night Robotics - MANOI Hula-hooping

We added onto this with arm motions. When MANOI tilts backwards, the arms go up. We tried keeping the arms up for tilting forward, but it shifted the center of balance too much.

Friday Night Robotics - MANOI Hula-hooping

Here are two videos of the motion:

There are more photos on Flickr!

I’m going to blog more about the Robotics themed floor later, as well as the Autonomous Robotics Club! =) I also adopted an iRobot Create recently, and I’m controlling it with an Arduino. It’s fun! :)

Oh yeah, and MANOI fell about 3 feet from a desk when its battery ran out. It survived just fine, and nothing was broken!

Posted in: MANOI, Projects, Robot.

Friday Night Robotics – Fading Multiple RGB LEDs

Posted by Erin, the RobotGrrl on Tuesday, August 18th, 2009

I mentioned a while ago last week that I wanted to have MANOI’s RGB LEDs fade in and out at different rates from different starting points to different ending points. Luckily, it was a pretty easy task to accomplish, so now I can share the code with everyone! :)

The setup I have for MANOI’s RGB LEDs are using a Sanguino for a microcontroller. It has 6 PWM pins, so I use 3 pins for two LEDs. (The RGB LEDs have 3 leads for red green and blue). On MANOI, this ends up looking like this:

Friday Night Robotics - RGB LEDs + IR Sensor

I define left to be the LED #1 and #3, and right to be LED #2 and #4.

You need 1K ohm resistors, otherwise the red LED will use all of the power, and not save any for green and blue. :(

Friday Night Robotics - RGB LEDs + IR Sensor

I kept the wiring constant, since non-constant would be too confusing. Just a personal preference when dealing with RGB LEDs.

Friday Night Robotics - RGB LEDs + IR Sensor

Friday Night Robotics - RGB LEDs + IR Sensor

That is all for the RGB LEDs. Next part is the Fade function!

  1. void fade ( int startL_R, int startL_G, int startL_B,
  2.             int finishL_R, int finishL_G, int finishL_B,
  3.             int startR_R, int startR_G, int startR_B,
  4.             int finishR_R, int finishR_G, int finishR_B,
  5.             int stepTime ) {
  6.    
  7.   // Defining the ‘skip everys’ for different rates        
  8.   int skipEveryL_R = 256/abs(startL_R-finishL_R);
  9.   int skipEveryL_G = 256/abs(startL_G-finishL_G);
  10.   int skipEveryL_B = 256/abs(startL_B-finishL_B);
  11.   int skipEveryR_R = 256/abs(startR_R-finishR_R);
  12.   int skipEveryR_G = 256/abs(startR_G-finishR_G);
  13.   int skipEveryR_B = 256/abs(startR_B-finishR_B);
  14.  
  15.   // Count up to 255
  16.   for(int i=0; i<256; i++) {
  17.  
  18.     // If it’s fading down…
  19.     if(startL_R<finishL_R) {
  20.       // If we haven’t reached the final point yet…
  21.       if(i<=finishL_R) {
  22.         // If it’s a skip every…
  23.         if(i%skipEveryL_R == 0) {
  24.           // Colour the LED!
  25.           analogWrite(redL, i);
  26.         }
  27.       }
  28.     // If it’s fading up…
  29.     } else if(startL_R>finishL_R) {
  30.       // If we haven’t reached the final point yet…
  31.       if(i>=(256-startL_R)) {
  32.         // If it’s a skip every…
  33.         if(i%skipEveryL_R == 0) {
  34.           // Colour the LED!
  35.           analogWrite(redL, 256-i);
  36.         }
  37.       }
  38.     }
  39.    
  40.     if(startL_G<finishL_G) {
  41.       if(i<=finishL_G) {
  42.         if(i%skipEveryL_G == 0) {
  43.           analogWrite(greenL, i);
  44.         }
  45.       }
  46.     } else if(startL_G>finishL_G) {
  47.       if(i>=(256-startL_G)) {
  48.         if(i%skipEveryL_G == 0) {
  49.           analogWrite(greenL, 256-i);
  50.         }
  51.       }
  52.     }
  53.          
  54.     if(startL_B<finishL_B) {
  55.       if(i<=finishL_B) {
  56.         if(i%skipEveryL_B == 0) {
  57.           analogWrite(blueL, i);
  58.         }
  59.       }
  60.     } else if(startL_B>finishL_B) {
  61.       if(i>=(256-startL_B)) {
  62.         if(i%skipEveryL_B == 0) {
  63.           analogWrite(blueL, 256-i);
  64.         }
  65.       }
  66.     }
  67.    
  68.     if(startR_R<finishR_R) {
  69.       if(i<=finishR_R) {
  70.         if(i%skipEveryR_R == 0) {
  71.           analogWrite(redR, i);
  72.         }
  73.       }
  74.     } else if(startR_R>finishR_R) {
  75.       if(i>=(256-startR_R)) {
  76.         if(i%skipEveryR_R == 0) {
  77.           analogWrite(redR, 256-i);
  78.         }
  79.       }
  80.     }
  81.    
  82.     if(startR_G<finishR_G) {
  83.       if(i<=finishR_G) {
  84.         if(i%skipEveryR_G == 0) {
  85.           analogWrite(greenR, i);
  86.         }
  87.       }
  88.     } else if(startR_G>finishR_G) {
  89.       if(i>=(256-startR_G)) {
  90.         if(i%skipEveryR_G == 0) {
  91.           analogWrite(greenR, 256-i);
  92.         }
  93.       }
  94.     }
  95.          
  96.     if(startR_B<finishR_B) {
  97.       if(i<=finishR_B) {
  98.         if(i%skipEveryR_B == 0) {
  99.           analogWrite(blueR, i);
  100.         }
  101.       }
  102.     } else if(startR_B>finishR_B) {
  103.       if(i>=(256-startR_B)) {
  104.         if(i%skipEveryR_B == 0) {
  105.           analogWrite(blueR, 256-i);
  106.         }
  107.       }
  108.     }
  109.  
  110.     // Delay an amount of time between steps of colouring the LED
  111.     delay(stepTime);
  112.      
  113.   }
  114.  
  115. }

I added in some comments to make it clear what is going on. The if statement ‘block’ is repeated for RGB on left and right. You could use an array if you wanted to make it more complicated and more condensed.

That code by itself is pretty fun. But, it’s even more fun if you get to interact with it!

I created a headband with an IR sensor for MANOI last week (but neglected to blog it :( ).

Friday Night Robotics - RGB LEDs + IR Sensor

It’s very handy. The IR sensor is from Adafruit! It is really simple, and works ‘out of the box’ without any pull up or pull down resistor needed.

Friday Night Robotics - RGB LEDs + IR Sensor

Friday Night Robotics - RGB LEDs + IR Sensor

It goes straight into Analog 0.

Now I just need a simple function to map the analog reading back to an appropriate time :D

  1. int theTime() {
  2.   int result = map(analogRead(0), 0, 1023, 500, 10);
  3.   /*Serial.print(analogRead(0));
  4.   Serial.print(", ");
  5.   Serial.println(result);*/
  6.   return result;
  7. }

The reason why the Serial.print’s are all commented out is because if you leave the Sanguino running with the Serial.print’s, it will eventually run out of memory and just stop. However, for debugging, the Serial.print’s are very handy.

Here is the loop function that I use to give MANOI its magic:

  1. void loop() {
  2.  
  3.   LR = int(random(50, 255));
  4.   LG = int(random(50, 255));
  5.   LB = int(random(50, 255));
  6.   RR = int(random(50, 255));
  7.   RG = int(random(50, 255));
  8.   RB = int(random(50, 255));
  9.  
  10.   fade( preLR,      preLG,      preLB, // L Start
  11.                 LR,           LG,            LB, // L Finish
  12.            preRR,     preRG,       preRB, // R Start
  13.                  RR,          RG,            RB, // R Finish
  14.         1);
  15.        
  16.   delay(theTime());
  17.  
  18.   preLR = LR;
  19.   preLG = LG;
  20.   preLB = LB;
  21.   preRR = RR;
  22.   preRG = RG;
  23.   preRB = RB;
  24.  
  25. }

This code means that the LEDs fade from the previous value to the current value, over and over again. At the beginning of the program, the previous values are said to be 0.

I had to use 50 as a lower bound on the random as everything below it looks off :( Of course, you could add some features where you check to see if all three are below 50, if they are you would re-reandomize the values and check again. If not, you would send them to the fade function.

So all of this results in a really cool effect where if something gets close to MANOI, then its ‘antennai’ will start changing colours rapidly. Here are some videos:

The next thing now is to have MANOI dance and communicate to the Sanguino, Arduino + Motor shield (for MANOI’s ears), and the Arduino + WaveShield (for music). That would mean that MANOI would have FOUR cores!! :D ^_^ =)

You can see more photos on flickr.

Posted in: Art, MANOI, Programming, Projects, Robot.

Friday Night Robotics – RGB LEDs

Posted by Erin, the RobotGrrl on Saturday, August 8th, 2009

A few weeks ago, I added four RGB LEDs inside of ping-pong balls to MANOI’s head. The goal of this is to let MANOI express some colour. From colour, we gain meaning. The meaning we usually tie to colour is emotions! (and food, haha)

FNR - RGB LEDs &amp; Gyro!

I also plan to give MANOI ears, so when they move in a certain way, we can tie emotions to their meaning.

In any case, controlling RGB LEDs is fun. In one LED you have four leads for red, green, blue and ground. This means a whopping 16 leads in my scenario! :O

What I did to organize this was I used 5 24″ servo extension cable, and 1 12″ cable. The 12″ and one of the 24″ are for ground, and the 4 others are for the RGB leads. Eventually I’ll combine all of the grounds together.

Since the Sanguino only has 6 PWM ports, two of the RGB LEDs have to be combined together. Later on, when I get shift out PWM chips, this will be a different story ;)


FNR - RGB LEDs &amp; Gyro!

FNR - RGB LEDs &amp; Gyro!


So I coded in lots of funky functions, there is just one last function that I have to make… I want to be able to fade LEDs at the same time from different starting points to different ending points. I’m sure if I take the brightness value (which is 255), and map it to 100, I can come up with a math function that will let me do that. It will probably have something to do with jumping numbers and mod. I’m going to be thinking about that tomorrow :) It is a pretty easy problem to solve :D

Mounting the gyro was fun. I actually started this around the beginning of the week, but I got delayed a few days because I ran out of velcro… so I bought more velcro, and I added it to a stable DOF attached to the torso of MANOI.

FNR - RGB LEDs &amp; Gyro!

The point of the gyro is that it measures movement. It doesn’t measure where you are relative to where it was. I actually got stumbled up with that at the beginning.

Though, in order to use the gyro effectively, MANOI has to be able to WALK! I spent sooooo much time this week trying to make MANOI walk, again. I’m no closer to the goal than I was ages ago. :( I think it will involve lots of patience and trial & error…

I’m still trying to think of the best way to make MANOI walk. Until I figure it out, I’ll be working on the extras :D I want to add in some sensors for the RGB LEDs, specifically an IR and an accelerometer. If MANOI is moving with nothing in front, the LEDs will behave differently than if MANOI is not moving with/without someone in front. ^_^

Posted in: MANOI, Programming, Projects, Robot.

Update on MANOI’s code

Posted by Erin, the RobotGrrl on Monday, May 18th, 2009

I updated MANOI’s code a little bit. I think it will work better, it’s more organized for sure!

This program “lifts” MANOI’s broken leg.

  1. #include <stdio.h>
  2.  
  3. int HOME0 = 1800;
  4. int HOME1 = 1500;
  5. int HOME2 = 1000;
  6. int HOME3 = 1300;
  7. int HOME4 = 1300;
  8. int HOME5 = 1600;
  9. int HOME6 = 1900;
  10. int HOME16 = 1550;
  11. int HOME17 = 1200;
  12. int HOME18 = 900;
  13. int HOME19 = 1600;
  14. int HOME20 = 1600;
  15. int HOME21 = 1500;
  16. int HOME22 = 1200;
  17. int HOME23 = 1000;
  18. int HOME24 = 1580;
  19. int HOME25 = 1600;
  20.  
  21. void setup() {
  22.   Serial.begin(9600);
  23.  
  24.   int homeFrame[18] = {
  25.       HOME0,
  26.       HOME1,
  27.       HOME2,
  28.       HOME3,
  29.       HOME4,
  30.       HOME5,
  31.       HOME6,
  32.       HOME16,
  33.       HOME17,
  34.       HOME18,
  35.       HOME19,
  36.       HOME20,
  37.       HOME21,
  38.       HOME22,
  39.       HOME23,
  40.       HOME24,
  41.       HOME25
  42.     };
  43.  
  44.   setFrame(homeFrame, 100, 500);
  45.  
  46.   Serial.println("Hello world!");
  47. }
  48.  
  49. void loop() {
  50.   for(int i=0; i<500; i+=50) {
  51.   int liftLeftLeg[17] = {
  52.       HOME0,
  53.       HOME1,
  54.       HOME2,
  55.       HOME3,
  56.       HOME4,
  57.       HOME5,
  58.       HOME6,
  59.       HOME16,
  60.       HOME17+i,
  61.       HOME18,
  62.       HOME19,
  63.       HOME20,
  64.       HOME21,
  65.       HOME22,
  66.       HOME23,
  67.       HOME24,
  68.       HOME25
  69.     };
  70.     setFrame(liftLeftLeg, 500, 5000);
  71.   }
  72. }
  73.  
  74. void setFrame(int theFrame[], int moveTime, int delayTime) {
  75.   char str[250]; // I will count the actual number, some day
  76.   sprintf(str, "#0 P%d #1 P%d #2 P%d #3 P%d #4 P%d #5 P%d #6 P%d #16 P%d #17 P%d #18 P%d #19 P%d #20 P%d #21 P%d #22 P%d #23 P%d #24 P%d #25 P%d T%d", theFrame[0], theFrame[1], theFrame[2], theFrame[3], theFrame[4], theFrame[5], theFrame[6], theFrame[7], theFrame[8], theFrame[9], theFrame[10], theFrame[11], theFrame[12], theFrame[13], theFrame[14], theFrame[15], theFrame[16], moveTime);
  77.   Serial.println(str);
  78.   delay(moveTime + delayTime);
  79. }

I am more happier with this :) Pretty easy to program with one hand, and MANOI in the other.
Thanks to all who left a comment on the previous post! =)

Posted in: MANOI, Programming, Projects, Robot.

Friday Night Robotics – Code > All theory

Posted by Erin, the RobotGrrl on Friday, May 15th, 2009

Sometimes theory isn’t worth blogging about. This is definitely the case for this FNR.

Instead, I will blog about the code that I use for MANOI! It’s super simple… this allows me to concentrate on harder things!

This is MANOI, in its simplest form:
MANOI <-- 17 servos <-- SSC-32 <-- Sanguino

The SSC-32 is the serial servo controller. It listens for commands at 9600bps, and sends the PWM to the servos accordingly. The Sanguino (an alternative Arduino with an ATmega644) sends these commands to the SSC-32.

Here is what I have at the top of all of my Arduino sketches for MANOI programs:

  1. int HOME0 = 1800;
  2. int HOME1 = 1500;
  3. int HOME2 = 1000;
  4. int HOME3 = 1300;
  5. int HOME4 = 1300;
  6. int HOME5 = 1600;
  7. int HOME6 = 1900;
  8. int HOME16 = 1550;
  9. int HOME17 = 1200;
  10. int HOME18 = 900;
  11. int HOME19 = 1600;
  12. int HOME20 = 1600;
  13. int HOME21 = 1500;
  14. int HOME22 = 1200;
  15. int HOME23 = 1000;
  16. int HOME24 = 1580;
  17. int HOME25 = 1600;

It’s useful to have as a reference. The way I organized the SSC-32 was to have all of the servos for above the waste from 0-15. Below would be 16-29. There’s a lot more leg motors than there are arm motors :P

Here is an example of a motion (forward ‘skating’):

  1. void forward(int repeat, int theTime) {
  2.  for(int i=0; i<repeat; i++) {
  3.    // Frame 1
  4.    Serial.print("#0 P");
  5.    Serial.print(HOME0);
  6.    Serial.print(" #17 P");
  7.    Serial.print(HOME17);
  8.    Serial.print(" #19 P");
  9.    Serial.print(HOME19);
  10.    Serial.print(" #22 P");
  11.    Serial.print(HOME22);
  12.    Serial.print(" #24 P");
  13.    Serial.print(HOME24);
  14.    Serial.print(" #3 P");
  15.    Serial.print(HOME3);
  16.    Serial.print(" #6 P");
  17.    Serial.print(HOME6);
  18.    Serial.print(" #2 P");
  19.    Serial.print(HOME2);
  20.    Serial.print(" #5 P");
  21.    Serial.print(HOME5);
  22.    Serial.print(" T");
  23.    Serial.println(theTime);
  24.    
  25.    delay(theTime+10);
  26.    
  27.    // Frame 2
  28.    Serial.print(" #17 P");
  29.    Serial.print(HOME17-55);
  30.    Serial.print(" #19 P");
  31.    Serial.print(HOME19-50);
  32.    Serial.print(" #22 P");
  33.    Serial.print(HOME22+45);
  34.    Serial.print(" #24 P");
  35.    Serial.print(HOME24+50);
  36.    Serial.print("#0 P");
  37.    Serial.print(HOME0 + 150);
  38.    Serial.print(" #3 P");
  39.    Serial.print(HOME3 - 300);
  40.    Serial.print(" #6 P");
  41.    Serial.print(HOME6 - 300);
  42.    Serial.print(" #2 P");
  43.    Serial.print(HOME2 + 100);
  44.    Serial.print(" #5 P");
  45.    Serial.print(HOME5 + 100);
  46.    Serial.print(" T");
  47.    Serial.println(theTime);
  48.  
  49.    delay(theTime);
  50.  
  51.    // Frame 3
  52.    Serial.print("#0 P");
  53.    Serial.print(HOME0);
  54.    Serial.print(" #17 P");
  55.    Serial.print(HOME17);
  56.    Serial.print(" #19 P");
  57.    Serial.print(HOME19);
  58.    Serial.print(" #22 P");  
  59.    Serial.print(HOME22);
  60.    Serial.print(" #24 P");
  61.    Serial.print(HOME24);
  62.    Serial.print(" #3 P");
  63.    Serial.print(HOME3);
  64.    Serial.print(" #6 P");
  65.    Serial.print(HOME6);
  66.    Serial.print(" #2 P");
  67.    Serial.print(HOME2);
  68.    Serial.print(" #5 P");
  69.    Serial.print(HOME5);
  70.    Serial.print(" T");
  71.    Serial.println(theTime);
  72.    
  73.    delay(theTime+10);
  74.    
  75.    // Frame 4
  76.    Serial.print(" #17 P");
  77.    Serial.print(HOME17+55);
  78.    Serial.print(" #19 P");
  79.    Serial.print(HOME19+50);
  80.    Serial.print(" #22 P");
  81.    Serial.print(HOME22-45);
  82.    Serial.print(" #24 P");
  83.    Serial.print(HOME24-50);
  84.    Serial.print("#0 P");
  85.    Serial.print(HOME0 - 150);
  86.    Serial.print(" #3 P");
  87.    Serial.print(HOME3 + 300);
  88.    Serial.print(" #6 P");
  89.    Serial.print(HOME6 + 300);
  90.    Serial.print(" #2 P");
  91.    Serial.print(HOME2 + 100);
  92.    Serial.print(" #5 P");
  93.    Serial.print(HOME5 + 100);
  94.    Serial.print(" T");
  95.    Serial.println(theTime);
  96.  
  97.    delay(theTime);
  98.  
  99.   }
  100.   lastMove = 3;
  101. }

It looks long, but it actually isn’t. I have numerous Serial.print()s. The main reason behind this is because I still haven’t found a way to do this:

  1. System.out.println("#0 P" + HOME0 + " #1 P" + HOME1 + " #2 P" + HOME2 + " T" + theTime);

in C.

The forward motion has 4 ‘frames’ in it. Frame 2 and 4 differ in the way that frame 2 is to bring the leg forward, and frame 4 is to bring the leg back. These two frames are joined together by the home position of those servos, frame 1 and 3. It can definitely be said that the motions need to be worked on ;)

The backwards motion looks the same as the forward motion.

It all culminates into the two main Arduino functions:

  1. void setup() {
  2.   Serial.begin(9600);
  3.   moveServosIndependent(300);
  4.   delay(1000);
  5. }
  6.  
  7. void loop() {
  8.   forward(10, 200);
  9.   //shoot(0);
  10.   //forward(5, 500);
  11.   //shoot(0);
  12.   //shoot(1);
  13.   //left(10);
  14.   //delay(1000);
  15. }

moveServosIndependent is a motion that sets all the servos to their home position :)

All in all, that is what MANOI’s code looks like. Highly unimpressive and super simple! :D

Posted in: MANOI, Programming, Projects, Robot.

Super Sanguino!

Posted by Erin, the RobotGrrl on Wednesday, December 17th, 2008

I got my Sanguino yesterday night, so it was time to finally delve in and make one of these awesomeness things! PLUS, I get to do a nice blog post about it. :D

I’m happy that I got super shipping… I don’t think I would have received it in time otherwise!

See:


It even comes with bubble wrap! ^_^


Let’s get started :D


The board is really shiny, but it is more of an orangey-red than a red-red. However, it is really catchy. Too bad in the end it is covered by all the components though!


See, look how giant the chip is! Sweet!


It’s time to solder. This is the cleanest the soldering iron has been in a few weeks :D


The SANGUINO silkscreen is easily covered by the DIP…


These capacitors remind me of balloons hehe :D


It doesn’t have a chip on its shoulder… yet (get it? the 648P isn’t in yet hahaha)


This part was sooo confusing. The instructions said… “Insert the LED on the flat side of the board” or something like that. Flat side? I never knew that there was a non-flat side… BAHA!


If the red LED is not entered correctly, nothing will work…


The proper way to insert the LEDs is… negative, positive and negative, positive. It clearly didn’t say that on my silkscreen >_> At least I only got one of them wrong :D


Sooo, after cleaning that LED up… it works! YAY! :D


The software was aggravating to get working, but I did manage to get it to work in the end. I’ll post up my version of the Arduino 12 IDE for Sanguino tomorrow, or something. :)

The number of outputs and inputs is so astonishing! It even has two TX/RX ports. I’ll probably finish off MANOI and Snowplow robot tomorrow, and think of a way to use the Sanguino in MANOI!

It would be cool to have an IR sensor right now for MANOI, so I could mount it on its stick, but instead I may try two LDRs with LEDs. I have the supplies for that, so I can easily implement a Bayes Filter algorithm to determine if the ball is there or not.

The Bayes Filter algorithm is a form of AI. I’ve been working on a tutorial about the BFA for uCHobby.com for a very long time. (TeX takes a long time to type).

Swweeeet!!!!

Posted in: Projects, Robot.