profmason.com

June 3, 2010

Updated Competition Robot Code:

Filed under: Daily — profmason @ 3:16 pm

The Bioloid Gait Software has been ported to the new CM-700.  The software has been tested with AX-12+, RX28, RX24, RX64 and DX117 servos and can run them all interchangeably.   Note, no accommodations have been made for the different servo speeds so the servo group speeds will need to be recalculated.  In addition the software has been massively cleaned and streamlined.  All compiler warnings in main.c have been eliminated and substantial commenting has been introduced.  For detailed information see my report on the bioloid real time control software.

How to get started with the CM700:

  1. Unzip the zip file (2June2010ProjectFiles)
  2. Open AVR-Studio.
  3. Open the Project file  (bioloid.aps)
  4. You may modify main.c to implement changes.
  5. Choose Build->Build and wait about 30 seconds
  6. On conclusion it should report “Build Succeeded”
  7. In your project directory you now have a file called “bioloid.hex”
  8. Open Robot Terminal
  9. Hold the # key.
  10. Power cycle the CM700
  11. The prompt “SYSTEM-O.K. CM700 BOOTLOADER 1.51) should appear
  12. Type LD
  13. Select Files->Transmit File and select your bioloid.hex file
  14. It will report “Transmitting Data” and should conclude after about 30 seconds with “Success”

Here is the main loop.  (Now should be readable!)

  1. //——————————————————————————
  2. // Main Function called each time Micro is restarted
  3. //——————————————————————————
  4. int main(void)
  5. {
  6. //——————————————————————————
  7. // Initialization (Done Once)
  8. //——————————————————————————
  9.         InitializeRobot();
  10.         int             Tick = 0;
  11.         RobotFlags = 0;
  12. //——————————————————————————
  13. // Main Loop (Never Terminates)
  14. //——————————————————————————
  15.         for(;;)
  16.         {
  17.                 if (RobotFlags & _BV(MSGRCV))       //Check to see if anything came in on the serial port
  18.                 {
  19.                         cli();   //Clear Interrupts
  20.                         RobotFlags=RobotFlags & ~_BV(MSGRCV);
  21.                         sei();  //Set Interupts
  22.                         if(CheckProtocol())
  23.                                 OnGoodPacket()//This function is in comms.c and is the main messaging function
  24.                 }
  25.                 if (RobotFlags & _BV(HBEAT))  //Check to see if a heartbeat happened, if it did, do the next Tick
  26.                 {
  27.                         cli(); //Clear Interrupts
  28.                         RobotFlags=RobotFlags & ~_BV(HBEAT);
  29.                         sei(); //Set Interupts
  30.                         Set_LED(LED_RXD, LED_OFF);
  31.                         ZigbeeHeartBeat();
  32.                         if(Tick==0)  //Ticks per pose is implemented so that the main motion only happens when Ticks is 0
  33.                         {
  34.                                 IMUReport(IMU_Report_Flag);   //Do IMU sensor reporting if set
  35.                                 ServoReport(Servo_Report_Flag); //Do Servo reporting if set
  36.                                 FootReport(Foot_Report_Flag);  //Do foot sensor reporting if set
  37.                                 if (UsingPoseSystem==2)  //If Usingposesystem = 2 then we are controlling servos directly
  38.                                 {
  39.                                         UpdateServosDirectly();
  40.                                 }
  41.                                 if (UsingPoseSystem==0)  //The UsingPoseSystem is used to turn on and off the dynamic gait.
  42.                                 {
  43.                                         DynamicGait();
  44.                                         PoseNum++;
  45.                                         if (PoseNum >= NumPoses) PoseNum = 0;
  46.                                 }
  47.                         }
  48.                         Tick++;
  49.                         if (Tick >= Ticks_Per_Pose) Tick = 0;  //Restart the Tick Counter
  50.                 }
  51.         }
  52. }

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress