Shop Learn
Next large robot - Page 30 — Parallax Forums

Next large robot

1242526272830»

Comments

  • I’ve been spending a lot of time on the P2 forum and learning C programming using FlexSpin. That’s a great tool and works well. To learn C I am spending time on the Parallax Tutorials which has a very nice C tutorial written for the P1. It’s been fairly easy to translate the lessons over to the P2 so far. The P2 C setup has a lot of add-ons for math so last night was spent writing some simple programs to enter an angle and output the sin value. I was getting lots of errors before I realized the sin() function used rads instead of angles for input. After that it got much easier. Today I want to start converting my Inverse Kinematics formulas from the P1 program over and see if I can get them running also.
    C hasn’t been too bad to learn so far but I’m still in the very basic stages of it, I’m sure it will get more interesting soon! As it is I tend to make a lot of stupid mistakes that keep things from compiling...
    Still looking for a serial communications object that can handle several separate input/outputs. I’ll have to look at the P1 versions of these objects to see if I can convert one over to the P2 if one doesn’t show up by the time I need it. The other thing that needs setting up is the XBee radio, will need to get a interface board since none of the P2 boards have that incorporated and create a P2 object to interface. Lots of stuff to do still but it’s all fun.

    Bob

    PS. I sold my big metal lathe which required dismantling the hexapod as it was in the way for getting the lathe out of the basement. Finally got the robot back together again (lots more space for testing the legs now!) so hopefully I’ll be able to start testing with the P2 board before too long.
  • Fun times learning new P2 language, specifically C for the P2.
    My first adventure was converting the existing Inverse Kinematics (IK) formulas into something that would compile under FlexSpin. First off I had to remind myself about how I went about coming up with the original equations. That required some digging and finding the PDF (see attached) with my calculations.
    Next step was entering the equations and lots of work getting the syntax right!
    /* Test code for IK entries - fixed inputs for testing purposes */
    #include <stdio.h>
    #include <math.h>
    #include <propeller.h>
    #include <simpletools.h>
    
    double coxaLength = 2.5;
    double femurLength = 6.0;
    double tibiaLength = 25.0;
    
    #define LEDdata  54
    #define LEDclock 52
    
    void main()
    {
      float degreeValue;  
      degreeValue = 45.0;
      /*  getsine(degreeValue); */
      /*  legIK(0.0, 28.0, 11.0); */
    }
    
    double to_degrees(double rad)
    {
      	return rad * 180.0 / PI;
    }
    double to_radians(double deg)
    {
      	return deg * PI / 180.0;
    }
    
    void legIK (double IKx, double IKy, double IKz)
    {
      	double L1, L, C, IKb, IKb1, IKb2;
      	double IKfemurAngle, IKtibiaAngle, IKcoxaAngle;
      
      	L1 = sqrt((IKz*IKz) + (IKx*IKx));
      
    	L = L1 - coxaLength;  
      
      	C = sqrt((IKy*IKy) + (L*L));
      
      /* IKb = acos(((femurLenth^2 + C^2) - tibiaLength^2) / (2 * femurLength * C))  */
      	IKb = acos(((femurLength*femurLength) + (C*C) - (tibiaLength*tibiaLength)) / (2.0 * femurLength * C));
      
    	IKb2 = atan(L / IKy);  
      
      /* IKb1 = acos((tibiaLength^2 + C^2 - FemurLength^2) / (2 * tibiaLength * C))  */
      	IKb1 = acos(((tibiaLength*tibiaLength) + (C*C) - (tibiaLength*tibiaLength)) / (2.0 * tibiaLength * C));
      
      	IKfemurAngle = (IKb + IKb2) * (180.0 / PI);
     	IKtibiaAngle = (IKb2 - IKb1) * (180.0 / PI);  
     	IKcoxaAngle = atan(IKz + IKx) * (180.0 / PI); 
    
      	printf("L1 = %lf\n", L1);
      	printf("L = %lf\n", L);
      	printf("C = %lf\n", C);
      	printf("IKb = %lf\n", IKb);
      	printf("IKb2= %lf\n", IKb2);
      	printf("IKb1 = %lf\n", IKb1);
      	printf("IKfemurAngle = %lf\n", IKfemurAngle);
      	printf("IKtibiaAngle = %lf\n", IKfemurAngle);
      	printf("IKcoxaAngle = %lf\n", IKcoxaAngle);
    }
    
    
    I got everything up and running faster than I expected, the C math library was much easier to use than floating point on the P1! The test code outputs to a windows terminal window with the calculation results. I'd like to output to the Propeller Serial Terminal (PST) window if I can figure out how to get FlexSpin to change its default output.
    Now I'm working on getting the robot RGB troubleshooting LEDs to work under P2. The P1 object for the LPD8806 is a combination of Spin and pasm and I'm pretty rusty on assembly. I've been trying out a Spin only bit-banged approach but it isn't working quite right yet. The LPD8806 LED Driver chip appears to be unique and there isn't much out there, even the datasheet doesn't show the timing requirements for the chip. The only other driver I found on-line was written in C for an Arduino so not much help there. I'm about ready to give it up and switch over to the WS2812B RGB modules that Parallax sells. There are several P2 drivers already developed for it.
    Bob
  • I think if you leave off the '-t' parameter in the command line P2load will not start the build in terminal and you can use the Propeller Terminal as you did with the P1.

    Mike
  • I got a lot of help from the folks on the P2 forum and especially JonnyMac in coming up with a driver for the LPD8806 RGB controller. The driver works great so it's time to move on to the next item on the list.
    Next is getting a multi-port serial device set up. The P1 master code uses 2, 4 port serial objects. There are 8 serial lines being used; 1 for master to leg controllers (one way comms only), 6 receive lines from each leg controller to the master (one way comms also), and 2 way comms via the PropPlug (mainly for troubleshooting).
    I started fiddling with a simple serial driver, jm_serial.spin2, unfortunately I managed to break it and now it isn't responding. JonnyMac recommended that I look into his FullDuplexSerial code as he set it up better for handling multiple ports. So its off to reviewing more code and seeing what it might take to allow it to handle more lines. I have seen that the P2 Smart Pins capabilities are pretty nice and can greatly reduce the amount of setup code needed for tasks like this. Study time again!
    Nothing else to update on, still haven't quit on this project!
  • Bob:
    Back on page 19, you shared that you had to rewrite the encoder code for the HH12 encoders. Are you willing to share that P1 code? I am about to start putting together my bot arm and I would like to use that for positioning. btw do you happen to know if the HH12 is still available?
    Jim
  • RS_Jim wrote: »
    Bob:
    Back on page 19, you shared that you had to rewrite the encoder code for the HH12 encoders. Are you willing to share that P1 code? I am about to start putting together my bot arm and I would like to use that for positioning. btw do you happen to know if the HH12 is still available?
    Jim
    Not a problem, I’ll dig that code out and will post it here, haven’t looked at that code since I got it working. I don’t know if the guy I bought the encoders from still makes them, I’ll look up the contact info (he is in Germany) and pass that on to you.
  • Bob,
    Thanks much, I am looking forward to it.
    Jim
  • Finally got to a computer so I could dig out the code!
    ' encoder mask
    con
        CDataIn     := 18    ' input
        CEncoderClk := 16    ' output
        CEncoderCS  := 17    ' output active low
      AngleMask = %111111111111000000
      StatusMask = %000000000000111111
    
    PUB CoxaEncoder | x, rawin, packdata, angledata, statusdata
    '' AS4045 magnetic encoder bit-banging routine
      'setup encoder pins
      dira[CDataIn]~
      dira[CEncoderClk]~~
      dira[CEncoderCS]~~
      outa[CEncoderCS]~~ 'take CS pin high
      outa[CEncoderClk]~~ 'take Clk pin high
    '  PauseMSec(1)
      outa[CEncoderCS]~ 'CS pin low to start transfer
    '  PauseMSec(1) 'for chip response time
      outa[CEncoderClk]~ 'start clocking
    '  PauseMSec(1) 'pause 10 msec
      repeat x from 0 to 17
        outa[CEncoderClk]~~
    '    PauseMSec(1)   '10ms
        RawIn := ina[CDataIn]        'read raw data from encoder in
        packdata := (packdata << 1) + RawIn
        outa[CEncoderClk]~
    '    PauseMSec(1)
      'get angle and status values via masking raw packdata
      result := (packdata & anglemask) >> 6            'AND mask and shift 6 bits
    '  statusdata := packdata & statusmask
    '  encoderangle := angledata
      'calculate actual angle
    '  Encoderangle := (angledata * (8789))/10000
      packdata := 0
    
    
    The commented out delays may not be required. The statusdata and encoderangle were there for troubleshooting

    Contact Georg Hylinski about the HH-12 via his website: www.DF1SR.de.
    DF1SR@Arcor.de

    Hope this helps you.
  • Bob,
    Thanks for digging that out. As soon as I get on my computer, I will try it out.
    Thanks again.
    Jim
  • Just a update on robot status. I'm working towards creating a multi-port serial object for the P2 created based on the JonnyMac jm_fullduplexserial.spin2 object. Jon writes some very well documented code which helps a lot for figuring things out. Since no one has written a serial object with multiple ports, I'm teaching myself P2pasm so I can try my own hand at making one. I haven't done assembly for any processor in many years so its been a slow undertaking given the scarcity of documentation at this point (Parallax has lots of stuff is in the pipeline but I want to get a jump on it now). I have read the available documents several times and reviewed a lot of other folks assembly in P2 (Whew, lots of words to figure out and finding examples of the new P2 specific assembly commands takes a lot of searching). With the help of people on the P2 forum, its finally starting to make sense to me. Now whether or not it makes enough sense that I can write my own serial driver is another matter altogether! The hope is that I can write a 8 port buffered serial driver that uses one cog.
    Anyway I have been attending the weekly Parallax Zoom meetings covering the various aspects of the P2. These sessions have been a lot of fun. I've learned a lot just from attending these sessions and have been having some fun playing with P2 spin coding. I really like the P2 Edge board and I got the mini breakout board for it along with the Jon McPhalen Edge Module Breadboard from Parallax. I think the P2 Edge will be make for a nice robot master computer and I want to mount the mini breakout board on the robot computer deck. It should make wiring to the 6 P1 boards fairly easy to do using jumpers.
  • Bob,
    Here are some dance moves for your hexapod!
    [url] [/url]
    Dennis
  • The Boston Dynamics Atlas robot, I would only guess that you put sensors on a real dancer record the moves, then program the robot with the dance moves.
  • I wish I could afford the motor/servo and sensors that they have available to create these robots!
  • It’s been a while since my last update here but I have been active on the Parallax P2 forum instead.
    I’m continuing work on a version of a multi-port serial object, lots of studying P2 pasm and other’s code. After several fits and starts I finished up my first version of the code, unfortunately it doesn’t work properly so now I’m using Pnut and debugging to figure out where I’m going wrong.
    In the meantime Cluso99 created his own multi-port serial object that seems to work pretty well. I’m still continuing on working on my version as a good excuse to get better at P2 pasm and I’ve designed the interface to the code to be similar to the P1 multi-port serial object I have been using on the master computer. That will make converting my existing master P1 code over to the P2 somewhat easier.
    Once I get the serial object running I am going to re-visit coding the inverse kinematics engine using some of the built-in P2 functions instead of running the code in C under FlexProp. I think long term that will make the code easier to maintain instead of having Spin, C, and Pasm all mixed together.
    No additional changes to the mechanical features on the robot at this point. After selling my big metal lathe I had to re-assemble the robot and now I have a larger testing area in the basement.

Sign In or Register to comment.