Questions on Phoenix code with RC individual leg control

When mode 3 is on in the RC code it really seems like I would need to change these variables for individual leg control
LRGaitPosX
LRaitPosY
LRGaitPosZ

For the Right Front leg.

Although when I put this line of code in

     LRGaitPosX = (pwmInput01 -1500)/4   
     LRGaitPosZ = (pwmInput02 -1500)/4
     LRGaitPosY = (pwmInput03 -1500)/2

It completely breaks the entire program and the phoenix does nothing.

now it seems like if these variables are modified via the rc read and are constantly changing is the IK function trying to change these values?

When In mode 3 do i need to put some sorta statement in my code to disable IK and simply do “If mode 3 = true then gosub — some other part of the program?”

I’m guessing on the right track slightly but still missing something.

Innerbreed — Try changing one of those numbers to 90 degrees in fact change the 2 outer femur and tibia to 90 degrees and leave the coxic bone to 0 and see if its perpendicular to the body… that way you can tell if the numbers are angles or not…

I’m guessing that they probably are I don’t think the programmer guys would use something that isn’t an angle in this situation it just wouldn’t make much sense if it wasn’t an angle or something easily referenced…

hi thanks for replying… makes sence actually, i guess they are angles. looking at them now i can see that.
**
im working on this code blind. (not being able to test it)
I dont actually have the phoenix… nor do i have my electronics setup, or even a complete robot built!!**

im converting the code to Quadruped from Hexapod. lets just say i have a theory that this will work!! :wink:
bet ill be hit by a crap load of Compiler errors!!!

im sorry but i cannot seen to give you input on the above post as im still learning too. many of the questions you are asking are ones i wish to know the answers to too!!

good luck.

You know I had a feeling something like that was the issue, order that stuff! its hard to learn blind without anything to test with…

I wish I had a way of powering my phoenix from a computer power supply as I have tapped every known voltage off it and put it in a Plexiglas glass case with wire taps on them and I don’t have a 6 volt out which would be perfect!

Either way I’ll do some more tests hopefully one of the smarties will reply and show me the way, I have the code that works with the modified transmitter although I cant seem to reverse engineer it back to how zenta did his.

Either way good luck!

–Aaron

sniffle sniffle … possibly aid some help to individual leg control?

I’m kinda looking for some code I can put into that mode 3 section of my code block with hardset 1 leg to control via 3 channels of RC…

I’m not sure how to bypass your IK subroutine.

–Aaron

I was wondering If I could get some assistance trying to get individual leg control working what variables I would have to change.

Currently it would be nice to see a sample of code for a hard leg to be hard coded to be RC controllable via 3 channels, it seems like no matter how I try and implement the idea zenta did with individual leg control …it bricks the entire loop so the phoenix just sits there doing nothing when I run the program…

I can’t use the code he modified as I don’t have a modified transmitter, but I am trying to remove a piece of the code he created for individual leg control and put it in another program for the non modified version of the T7C remote…

I feel like I’m between a rock and a hard place! I know it can’t be that complicated.

–Aaron

With this information you should be able to add the functionality by yourself. Don’t get we wrong but I think you’re new at programming and are trying to much at once. Start by building small programs and work your way up. Give yourself a small goal which you can reach in a few hours.

Try to read just one input of your remote and led something like a led blink when the joystick is in the outer position. If you got this done, I’m sure you know how to read the joystick signals.

If you’re ready for it, try to put the 3 variables from the joystick into the IK of the leg. Be careful. The IK input requires positions in mm. So don’t just drop in the raw joystick value.

Currently I’ve got my priority on another project so I’m short in time. I’m willing to add this functionality to V2.0 but this will take some time.

Xan

Yeah xan your right, I really don’t know much about this basic programming, mostly my knowledge is in vb i can usually grasp concepts pretty fast and learn them. but this code is pretty complicated, granted its layed out very well for people like myself to understand it.

I understand from previous pieces of code that I need to take the pulsin read of a channel and subtract 1500 and make that an absolute value so i only get positive numbers, then take that number and divide it by "some other number 2/4/8/16 whatever to make the output a number per say between 0 and 40 or so which would be MM movements. depending on which number i divde by will allow me to make my control movements either very precise or very large. … so reading a channel and doing something with the numbers isn’t difficult…

I guess its trying to understand the code I’m pretty sure that I have to disable a piece of the code so that i can feed the rest of the code the modified variables for individual leg control… I’m not looking for someone to flat out just post the program all done, but it seems like whatever i do the entire program breaks and no feature works.

…Ive been trying to compile for the last 4 hours and can’t seem to get it :\

::: Update

I’ve looked in the previous 2 pages of this post referencing the code posted and I’m missing something …

Ignore most of the crap above, I really have no idea why it works now, but this is all i did… and some history before this, when I did this before it did not compile at all and gave me weird errors although this works

[code] elseif LegMode

RFPosX = -(RCInput(1)-1500)/8
RFPosY = -(RCInput(3)-1500)/20
RFPosZ = (RCInput(0)-1500)/20

ENDIF

return [/code]

I’ll fiddle with this some now that its doing 'THINGS" other then just giving me the finger.

:slight_smile: whoohoo

heh another update :::

Not quite what i was expecting although when i enter leg mode the leg is messed up even when I switch out of leg mode wacky! … and I know this because those individual variables I am messing with are defined at the beginning of the program out of the main loop.

I could enable a serial out to figure out what i need to divide the pulsin results with to get a max and min decimal output, and then figure out some way of returning the variables to the hard set values at the top of the program… come to think of it…

Could I just take this code

[code]'Feet Positions
RFPosX = 53 ;Start positions of the Right Front leg
RFPosY = 25
RFPosZ = -91

RMPosX = 105 ;Start positions of the Right Middle leg
RMPosY = 25
RMPosZ = 0

RRPosX = 53 ;Start positions of the Right Rear leg
RRPosY = 25
RRPosZ = 91

LFPosX = 53 ;Start positions of the Left Front leg
LFPosY = 25
LFPosZ = -91

LMPosX = 105 ;Start positions of the Left Middle leg
LMPosY = 25
LMPosZ = 0

LRPosX = 53 ;Start positions of the Left Rear leg
LRPosY = 25
LRPosZ = 91[/code]
and put it in a subroutine so I can call it again?

Put something like

legPositions: and at the bottom put Return

I think this will work to quickly reset the leg’s after you exit mode3: legcontrol mode… HRMS…

the gears are turning…

LOL, I’ve told you this before. First time in history I’m gonna quote myself. LOL

Hahaha xan your such a goober :stuck_out_tongue:

you said this 2 pages ago!

Hahaha your a funny guy… you got other variables i can change?’

I’ll have to try the other variables again zenta posted, but last time I tried it nothing worked when i uploaded the code. which looked exactly like the code i flashed but with the pwm inputs changing the values of the RF leg in 3 positions.

quote yourself… heh…

anyway! if no other variables work or others have issues, I have ideas to work around the problem to modify the “RF x,y,z” initialization position and simply put that in a subroutine which I’m not sure is a proper way to do it … you know? I don’t want to get into the habit of learning bad habits with this code and each time i exit individual leg control mode i can simply call that subroutine and have it fix the variables… ehh ehh it will work but as to how proper that is, you’d be able to tell me that I’m just happy the phoenix doesn’t eat it self at this point…

Bananna robot…“EEEEK”

Cool cool, so ive been experimenting with this leg control and I think ive figured some stuff out that I can use later…

((RCInput(1)-1500)/10)

using this I’ll get a +40 -40 sweep with my stick positions out in decimal if i need a larger sweep i’ll take that 10 and make it a 9 yada nothing difficult…

so using RFPosX as a number when i load on this line of code

RFPosY = RFPosY + (RCInput(3)-1500) this works initially but that Y variable is constantly being increased the longer I hold the stick away from 1500 centered… so it made me think about it abit and realized I don’t need to really use that variable why don’t I try and put another variable inside your IK which in my code would look something like this
in my mode 3 section

RCModify = ((RCInput(1)-1500)/10)

so this RCModify variable would be -40 to 40 so then I changed this line of code

GOSUB BodyIK -RFPosX+BodyPosX+RFGaitPosX, RFPosZ+BodyPosZ+RFGaitPosZ,RFPosY+BodyPosY+RFGaitPosY, RFOffsetX, RFOffsetZ, RFGaitRotY]

to

GOSUB BodyIK -RFPosX+BodyPosX+RFGaitPosX+RCModify, RFPosZ+BodyPosZ+RFGaitPosZ,RFPosY+BodyPosY+RFGaitPosY, RFOffsetX, RFOffsetZ, RFGaitRotY]

Although that did not work although it didn’t break anything either which is good! so that wasn’t it so I put it back the way it was and changed this line of code

gosub BalCalcOneLeg -RFPosX+BodyPosX+RFGaitPosX, RFPosZ+BodyPosZ+RFGaitPosZ,RFGaitPosY, RFOffsetX, RFOffsetZ]

to

gosub BalCalcOneLeg -RFPosX+BodyPosX+RFGaitPosX+RCModify, RFPosZ+BodyPosZ+RFGaitPosZ,RFGaitPosY, RFOffsetX, RFOffsetZ]

and that didn’t work although it did not break anything either.

So… I’m kinda curious where I can add a variable or simply modify an existing one to accomplish what I’m trying to do here,

I’m missing a tiny bit, and I know I’m close because I’m not breaking the code anymore “come on it sounds positive doesn’t it”

I love it how I just get skipped :frowning:

Hi,

I’m just wondering, what are you expecting us to do for you? Write the whole code?

I remember getting 14 PM’s about the code from you and I answered 6 of them. I gave you a working example of the code doing individual leg control using a modified T7C. I also gave a hint earlier in this thread of how I solved the individual leg control. But if you want to solve it another way thats fine, but you can’t expect us to solve it for you.

No no that’s not what im asking for, but I’m trying to learn how the IK works so I can add variables to it as the example I provided a page back or so and was curious why that wasn’t working? seems like it would since all you really do is add some numbers to the IK formula.

When I had tried your example the compile failed and I wasn’t sure why, I’ll have to stare at it again. You know I might have a different learning curve from the rest of the folks out there so don’t take it the wrong way, I just like asking a lot of questions… It’s nothing against you or anyone, but I like to learn a lot quick… it’s interesting stuff to me… Maybe you guys are kinda tired about helping new people like myself but I like to teach others stuff I learn… but hey that might be me you know?

I think everyone here on this forum is fantastic bunch of folks, I mean this hobby doesn’t seem to wide spread although, this is the first time I have ever seen yourself and Xan so into it where your robots walk like none other I have ever seen previously!

I’m used to VB where it highlights the actual error and with this new software it tells you somewhat different of an error message then I’m used to, where as you guys would spot the problem in half a second. It’s just little things that set me back learning this all , the nested loops and the amount of code i can see at once… would be nice for a 2500x1600 display or some nonsense to really get stupid into it!

anyway zenta, xan anyone else… I’m not trying to be a difficult person at all I just enjoy learning this stuff… slowly but surly…

Anyway keep up the good work I can’t wait to see what you fellas have brewing for other ideas in the future… care to give any hints? It would be interesting to see what your CoBap is able to give you for other features.

–Aaron

*Edit for some reason version 8.0.1.7 version was giving me issues with trying to take your advice and modify that code you gave me zenta… well I upgraded to 8.0.1.8 even though it said beta and it does what you say it does I get leg control on that single leg you posted the code for, previously it would not compile… so I’m not sure what the .7 to .8 changelog has in it but something was fixed.

… wow I feel so stupid, all along I had individual leg control working with simply modifying the variables you told me, but when I did it I had no idea it was the same way you had yours working zenta because when you hold the sticks to the right for too long those values get way too large and the legs start going all wonky like… the RFPosX variable for instance.

I guess I assumed you had to hold the sticks in a position you wanted the leg to be propped up on your boxes while you switched modes… all along the program is looping its just adding some number to increment or decrement that variable but your sticks are always in the centered position …

I could never see your fingers on the controller when you made that video so I assumed the opposite!..

WOW… See I realize now why you guys thought I just was loosing it or something, i feel like a goober now…

I guess I can moving onto bigger and better things now that I know how to tweak those variables and return them to the default state when I exit… :\

:blush:

by the way guys,

RFPosX = 53 – Was this in millimeters?

and

RFCoxa_MIN con -58 ;Mechanical limits of the Right Front Leg RFCoxa_MAX con 74 RFFemur_MIN con -101 RFFemur_MAX con 95 RFTibia_MIN con -106 RFTibia_MAX con 77

these were Millimeters? or are these angles?

… wow -1000 points for me… yeeesh…

I guess what I’m trying to ask is the values I need to do is how would I manage to get the femur and tibia pointed straight up and straight down… obviously this isn’t possible on a real spider let alone the phoenix could stand up with the femur and tibia perpendicular to the bottom
… wow anyway

Well done. :blush:

Good to hear you’ve figured it out. :wink:

Yes, its mm.

Hi troublemaker here. thought id probe for some more info.

So since Ive gotten individual leg control working Ive been comparing it to your video you did with the leg on the 3 servo boxes and for some reason I can’t get a leg to be cooperating with my movements compared to your video

I have duplicated the things you have mentioned to me in the code and I just cant get the leg to go where I want and then at the very end of the range of movements the leg slams into the ground quickly “I’m guessing one of the variables is mad at me or something, or possibly got too large” is it the max/min constants above for leg angles that permits the phoenix leg from folding in on itself when the code is running? and same with individual leg control I would like some more … how should i say this… reach upwards and forwards with the leg almost where the tibia and femur are both perpendicular to the ground then I would like to be able to point them both directly upwards also would I have to modify the constants to allow me this control?

The thing I noticed in your video when you had 1 leg in the air I notice that the body tilts back to compensate I can’t seem to locate that code in the "modified t7C remote version’ you sent me – that is unless the code from your video is different. "EDIT I think that’s because I forgot this BalanceMode = 1 inside mode 3… Yes scratch that It does work now. That’s exactly what I was missing.

what was the idea of setting 9 step quad ripple as the gait method when doing individual leg control?

Also could I get a hint as to where to add a modifier to the leg so that when I switch to that mode the position of the sticks when center’d are zero then the more I move the sticks the larger that number is and changes the position of each leg rather then modify RFPosX the initialization variables at the beginning of the program… I have some examples of things Ive tried to add in the previous page maybe that will give you an idea of what I have tried so far to modify positions of legs with other idea’s I had put the Initialization values into a sub routine to call it if I have messed the values up somewhere while doing leg control.

I’m glad It’s doing something! although I nearly added all the individual leg control functionality back into the “un modified remove version” using the “modified remote version” and just have a single leg to control inside the mode 3.

Also I thought of something to effectively double the number of modes you have on your 'modified remote version" hold switch H down while you switch modes … I’m going to work this into mine so I have 6 modes vs 3 … although I’m digging the GP player you have zenta I’m wondering if you can just have it loop though a list of RFPosX positions with pauses in between to effectively create the same outcome… you think?

Let me know if something doesn’t make sense to you and I’ll try and re word it…

–Aaron

I guess one thing that I have been scratching my head over is, what needs to happen for a leg to hold it’s position when switching from leg mode “mode3” to walkmode “mode2” the rotation and tilting mode from left to right and front to back like in the video zenta shows him demonstrating his individual leg control, does not seem to be staying in 3d space, when switching from LegMode"mode3" to WalkMode"mode1" the phoenix just keeps walking! "this is only when you try and position the leg in 3dspace from the normal standing position.

here is a link to the code I’m using.
pastebin.com/f6a5bf11d

Leg Mode starting at line 646, with a lot of commented out lines of code i was testing with, and I know why leg mode only works on the 9 step quadripple gate.

when going from LegMode to MoveMode the leg does not hold position “not sure why”

When going from LegMode to walk mode… wow the Pheonix goes crazy, I have to quickly switch it back to LegMode then WalkMode or the phoenix is likely to tie itself into a Knot.

What variables would I possibly need to change the values of to allow the leg to have a bit more travel while in mode 3? I’m speculating that I need to only change them in LegMode so that it does not affect the walking when switched back to WalkMode.

I have a theory that the max upwards position of the femur will not like being past 90 degrees as the value of sin(91) vs sin(90) is 2 huge differences in results for value’s so since LegMode variables being adjusted by the 3 rcinput reads being divided by

–Aaron

TravelLengthX = (RCInput(1)-1500)/4 TravelLengthZ = (RCInput(0)-1500)/4 TravelHeightY = (RCInput(3)-1500)/2

for example 4, 4, and 2, The only way I can prevent this from my knowledge “which isn’t that great at this point” is to change the value’s of them to higher then 4, 4 and 2 to prevent the inputs to be larger then +90 degrees for the femur “pointing straight up” or -90 degrees for the femur pointing straight down.

as when those values get out of wack the leg changes direction very quickly when I position the femur up in the air it slams down towards the floor and smashes into it when I try and move the femur back further “towards the phoenix body”

so comments, a hard time, jokes, all welcome!

–Aaron

… I just thought of something, this really only applies to zenta’s transmitter…

Zenta what do you have your Endpoint’s set at on all 7 of your channels on your T7C transmitter… I believe this is the reason why I see problems with me doing leg control and you not having any issues as my values would be slightly larger then yours based on Most of my Endpoints being slightly larger then 100%…

–Aaron

Its so long time ago I did something with my T7C, but I can’t remember doing anything with the endpoints. I’ve to check it one time. But it shouldn’t matter so much. A little tip is to check if some sbyte variables exceeded their range (ex XXGaitPosY, XX = RR,RM, and so on) when doing single leg control (it can be solved by using sword). Also the MAX MIN commands can be used to limit the pwm range.