KurtE / Phantom_Phoenix

Lynxmotion Phoenix code ported to Trossen PhantomX
94 stars 34 forks source link

Phantom_Phoenix MX28T Setting #4

Open GMDFr opened 5 years ago

GMDFr commented 5 years ago

Hi KurtE, My name is Guillaume, and I am doing a PhD on Robotics and AI. I am ok with IK and I have already all the measure of the hexapod for settings. I am working on a Hexapod which runs MX28T instead of AX18. I saw that Zenta used this range for his MX-Phoenix. I tried some things, but I am still stick on the MX28.

1) Did you have a MX28 version of Phoenix code please ? If not, do you have a list of variables or the .h files I need to modify to implement it please?

I saw on the code the MinMax values are noted as 650 , -700 i.e. Is it using a neutral pose as reference ? Do I need to modify it using an arbitrary mx28 setting ?

Thank's you so much for any tips and helps you can provide.

Best regards,

Guillaume,

GMDFr commented 5 years ago

Hi, Here are the values I changed to fit the hexapod configuration.

Phoenix_Code.h

Phoenix_Driver_AX12.h l.21-l.27 //#define cPwmMult 128 // modif //#define cPwmDiv 375 // modif //#define cPFConst 512 // half of our 1024 range //modif

define cPwmMult 512 // modif

define cPwmDiv 1500 // modif

define cPFConst 2048 // half of our 4096 range //modif

/!\ cPinTable w= Get Pose AX_PRESENT_POSITION

Phoenix_Input_Commander.h

Phoenix.h

BioloidEX.cpp l.31-l.37 // initialize for(i=0;i<AX12_MAXSERVOS;i++){ id[i] = i+1; pose[i] = 2048; nextpose[i] = 2048; //pose[i] = 512; //nextpose[i] = 512; // l.57-l.61 // initialize poseSize = servocnt; for(i=0;i<poseSize;i++){ id[i] = i+1; //pose[i] = 512; //nextpose[i] = 512; pose[i] = 2048; nextpose[i] = 2048; }

BioloidEX.h

Hex_Cfg.h // Define other optional compnents to be included or not... //#define PHANTOMX_V2 // Some code may depend on it being a V2 PhantomX

define cFemurHornOffset1 -35 // décalage moteur géométrie ?

define cTibiaHornOffset1 463 // décalage moteur géométrie ?

//-------------------------------------------------------------------- //[MIN/MAX ANGLES] - Start off assume same as Phoenix...

define cRRCoxaMin1 -750

define cRRCoxaMax1 750

define cRRFemurMin1 -1000

define cRRFemurMax1 1000

define cRRTibiaMin1 -1020

define cRRTibiaMax1 670

define cRMCoxaMin1 -750 //Mechanical limits of the Right Middle Leg, decimals = 1

define cRMCoxaMax1 750

define cRMFemurMin1 -1000

define cRMFemurMax1 1000

define cRMTibiaMin1 -1020

define cRMTibiaMax1 670

define cRFCoxaMin1 -750 //Mechanical limits of the Right Front Leg, decimals = 1

define cRFCoxaMax1 750

define cRFFemurMin1 -1000

define cRFFemurMax1 1000

define cRFTibiaMin1 -1020

define cRFTibiaMax1 670

define cLRCoxaMin1 -750 //Mechanical limits of the Left Rear Leg, decimals = 1

define cLRCoxaMax1 750

define cLRFemurMin1 -1000

define cLRFemurMax1 1000

define cLRTibiaMin1 -1020

define cLRTibiaMax1 670

define cLMCoxaMin1 -1000 //Mechanical limits of the Left Middle Leg, decimals = 1

define cLMCoxaMax1 1000

define cLMFemurMin1 -1000

define cLMFemurMax1 1000

define cLMTibiaMin1 -1020

define cLMTibiaMax1 670

define cLFCoxaMin1 -750 //Mechanical limits of the Left Front Leg, decimals = 1

define cLFCoxaMax1 750

define cLFFemurMin1 -1000

define cLFFemurMax1 1000

define cLFTibiaMin1 -1020

define cLFTibiaMax1 670

define cTurretRotMin1 -1500

define cTurretRotMax1 1500

define cTurretTiltMin1 -125

define cTurretTiltMax1 1100

//-------------------------------------------------------------------- //[BODY DIMENSIONS] // A Modifier selon la pose d'origine.

define cRRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1

define cRMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1

define cRFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1

define cLRCoxaAngle1 -450 //Default Coxa setup angle, decimals = 1

define cLMCoxaAngle1 0 //Default Coxa setup angle, decimals = 1

define cLFCoxaAngle1 450 //Default Coxa setup angle, decimals = 1

define X_COXA 60 // MM between front and back legs /2

define Y_COXA 66 // MM between front/back legs /2

define M_COXA 108 // MM between two middle legs /2

//#define X_COXA 60 // MM between front and back legs /2 //#define Y_COXA 60 // MM between front/back legs /2 //#define M_COXA 100 // MM between two middle legs /2

define cRROffsetX -60 //Distance X from center of the body to the Right Rear coxa

define cRROffsetZ 120 //Distance Z from center of the body to the Right Rear coxa

define cRMOffsetX -100 //Distance X from center of the body to the Right Middle coxa

define cRMOffsetZ 0 //Distance Z from center of the body to the Right Middle coxa

define cRFOffsetX -60 //Distance X from center of the body to the Right Front coxa

define cRFOffsetZ -120 //Distance Z from center of the body to the Right Front coxa

define cLROffsetX 60 //Distance X from center of the body to the Left Rear coxa

define cLROffsetZ 120 //Distance Z from center of the body to the Left Rear coxa

define cLMOffsetX 100 //Distance X from center of the body to the Left Middle coxa

define cLMOffsetZ 0 //Distance Z from center of the body to the Left Middle coxa

define cLFOffsetX 60 //Distance X from center of the body to the Left Front coxa

define cLFOffsetZ -120 //Distance Z from center of the body to the Left Front coxa

Thank's you !

GMDFr commented 5 years ago

I modify properly values but have motor blinking on red... Guessing if there is a bit frame issue between AX18/ MX28 values

KurtE commented 5 years ago

Sorry currently busy with other stuff, so don't have time/energy to help much. As for Angle limits, they are in 10ths of a degree so don't really matter which servos...

One main difference as you already know is the conversion of Angles to servo units, as used in the values:

l.21-l.27
//#define cPwmMult 128 // modif
//#define cPwmDiv 375 // modif
//#define cPFConst 512 // half of our 1024 range //modif

#define cPwmMult 512 // modif
#define cPwmDiv 1500 // modif
#define cPFConst 2048 // half of our 4096 range //modif

One of the difficulties with some of these conversions is that the code could maybe overflow integer math: That is if you have: wCoxaSDV = (((long)(sCoxaAngle1)) * cPwmMult) / cPwmDiv + cPFConst;

Depending on which board you are using on size of long... 1500*512... Will probably fit...

Conversion update is probably wrong.. i.e. you did not actually change the resolution. You multiplied both Mult and Div by 4 and when you divide these two numbers it simply cancels out... You probably only needed to change Mult to 512...

For what it is worth: I have been playing with a version of the PhantomX that runs on OpenCM boards and either uses AX like servos or XL430 like servos: Which is part of the project: https://github.com/KurtE/Open_CM_CR_Arduino_Sketches The conversion factors I have are:

#define cPwmMultXL      225
#define cPwmDivXL       256
#define cPFConstXL      2048    // half of our 1024 range

The reason that it is not simply a multiply of 4 1024->4096, there is also a change in the ranges of degrees (0-300) -> (0-360).

I believe it is the same for the MX servos.

Note: I do not own any MX servos (except one MX12W that is floating around here somewhere...)

Other issues with MX might include:

a) Are you using Protocol 1 or Protocol 2? If Protocol 1, then same packet formats... If Protocol 2, then packets are different. Bioloid code in this project is Protocol 1 only... The other project I listed here has code for both Protocol 1 and 2... But uses different library...

b) Other control table differences? like different default baud rate for servos...

Sorry got to run.

KurtE commented 5 years ago

Forgot to mention, about blinking lights...

The Phoenix code - does blink the leds on the servos, when it is NOT receiving any valid packets from the XBee (Commander). That code was added as I killed a couple of batteries, when I turned off the commander, which caused the robot to sit down and turn off the torque to the servos, but then I forget to actually turn off the power to the robot...

GuillaumeMorinDuponchelle commented 5 years ago

Hi KurtE, And Thank's you so much for your quick answer ! I figure out that's : MX28 uses (very probably) protocol 1 (and now Robotis made an update for protocol 2) and the baudrate is 8000 bps. About Protocol, Robotis talkes about MX-28T / MX-28AT (Half duplex Asynchronous Serial Communication (8bit,1stop, No Parity)) and for AX18 (Half Duplex Asynchronous Serial Communication (8bit, 1stop, No Parity). It seems to be the same. Maybe, as you said, I should use your Phantom Phoenix OpenCMR. I use Arbotix for MX28 but I have also a Opencm700 for specific setup for servos. I will check all of this and see if the magic operates ^^ Again, thank's you so much to help me for that, I will probably open a topic about on trossen to avoid to monopolize your time. ^^ Best Regards, TY

GuillaumeMorinDuponchelle commented 5 years ago

Hi KurtE ^^ I tested the opencmr version of phoenix code but it blinks my servo. So, I am looking for change the protocol to see if the magic operates. Just to confirm with you that MX28 employs protocol 2 for firmware >= 39. I got the 40 version with a 1000000 baudrate. I tried to recover the firmware but it kept the 40 version and change my baudrate to 57142. If I can recover the protocol 1 on the servo, I will probably able to run the phoenix code properly. ^^

KurtE commented 5 years ago

Again, if you do not have an XBee hooked up to the board... I have an adapter that I plug into Serial2 and that XBee is not receiving properly formatted messages from Arbotix Commander (or something generating similar messages), the code will put the Robot into sort of an idle mode, and with the code will blink the different servos as a reminder to me, that I have not yet turned the power off...

As for servo firmware versions, again I don't have any of these servos... But have seen some reports on Robotis forum. That is the first firmware version that Protocol 2 was started from is 40, but that does not necessarily imply a servo with Protocol 1, will have a firmware version < 40... If I looked at stuff I think the current version is something like 40 for protocol 1 and 43 for protocol 2

GMDFr commented 5 years ago

Hi Kurt, Sorry for the reply delay (I did my 1st year PhD presentation^^). I put all the MX_Servo on protocol 1 and we get some result through the pypose + NUKE code from Trossen. I remember Zenta successes to implement MX servos with Phoenix code but I don't know how he did it ^^.