Questions on Phoenix code with RC individual leg control

Hi Xan to avoid starting a new thread, Had a question about your RC code you did…

My goal is to take your 1.3 ps2 code and adapt it for RC remote, and one feature I would like to attempt to eliminate would be the R2 button to double travel length, after looking at the code a while I broke this part of it

IF (DualShock(2).bit1 = 0) THEN ;R2 Button test
		TravelLengthX = -(Dualshock(5) - 128)
		TravelLengthZ = (Dualshock(6) - 128)
	  ELSE
		TravelLengthX = -(Dualshock(5) - 128)
		TravelLengthZ = (Dualshock(6) - 128)	
	  ENDIF

As you can see I broke it so that when R2 is pressed or not pressed the outcome is the same… anyway semantics I’ll clean it up later… infact I could probably delete it all… anyway besides the point…

What other variables change when R2 is pressed ???

I would sort of like to modify it in this way “Ill try and explain this best I can”

the Pheonix goes from 0-100% speed with r2 not pressed
with R2 pressed it goes from 100% - 200% speed and some other variables change"

so I want to make it so that the stick moves to forward halfway position and the phoenix is walking forward 100% speed, when you move the stick forward the full position the phoenix is moving forward 200% so you eliminate the need for R2 as my futaba transmitter doesn’t have extra buttons to use.

as for gait type, have you made many additions to modifying your gaits? It seems like tripod 4 step gait is the fastest

One other question for you xan, Is it possible for the phoenix to go faster then the 4 step tripod gate at full forward while pressing R2? if so what variable would I modify to test faster gait speeds or step length…

Have you shared your code you put on your spider all said and done in that video you had created where you did individual leg control with the sticks of your remote?

–Aaron

Hi Xan,

What were you using in your code to read the inputs of the receiver ?

Kurts assembly function or pulsin commands or something of your own creation?

I remember the video you had shown a while back about individual leg control via rc remote and phoenix control via rc remote … any updates to this?

do you have the link for this, i must have missed it?

I believe Zenta was the one who posted RC stuff. His earlier code was using pulsein and now is using multiple atom pros…

… Yeah my mistake I honestly keep getting xan and zenta confused its like the borg they are joined at the hip or something, I can’t remember who does what anymore… anyway SORRY.

:blush:

Innerbreed youtube.com/watch?v=72MY5GuHSpA

This is what I was talking about.

–Aaron
It was located here lynxmotion.net/viewtopic.php?t=2743&postdays=0&postorder=asc&start=330

Hi LikWidChz,

I’m using the black phoenix, Zenta got the red one. :wink: But I agree, we do work together on a lot of things.

I used my own creation using pulsin. As far as I know Zenta also used the pulsin command. But I believe that Kurt’s version is much better and faster.

Zenta did that indeed. It’s easy to do by changing the values of the Tars.

RFPosX RFPosY RFPosZ

Xan

Hi,

For control of one single leg I used the following code in the RC part (there are more code, but this is the essential):

'Balance left front leg TestLeg = LFGaitLegNr TravelLengthX = (pwmInput01 -1500)/4 TravelLengthZ = (pwmInput02 -1500)/4 TravelHeightY = (pwmInput03 -1500)/2'for balance testing

And I added this code in the start of the Gait sub:

[code] IF BalanceOneLeg then
IF TestLeg = GaitLegNr then
GaitPosX = TravelLengthX
GaitPosY = -TravelHeightY
GaitPosZ = TravelLengthZ
GaitRotY = 0
ENDIF

ELSE;...... remember the ENDIF at the end og Gait sub[/code]

That’s also a smart way to do it 8)

Cool thanks guys I’ll try and grasp it shortly…

Whats the deal with everyone?? I think there robots are attacking them, Kurte did something with his arm or something zenta has a something else wrong with him some flu or something…

YEEESH I think its the robot flu or something.

–Aaron

[code]channel_1 var word
channel_2 var word
channel_3 var word
channel_4 var word
counted var word
counted = 0

top

counted = counted+1
pulsin p0,0,channel_1
Pulsin p1,0,channel_2
pulsin p2,0,channel_3
pulsin p3,0,channel_4

serout s_out,i57600,[dec channel_1," “,dec channel_2,” “,dec channel_3,” “,dec channel_4,” " ,dec counted,13]
;pause 100

gosub top

[/code]

So could someone tell me why it seems like my atom pro resets after the counter variable gets to around 500ish? I’m pretty sure who ever reads this understands what it does… but it’s just a test application i made to watch inputs anyway, seems like this resets after watching the values for a while any ideas why it might do this?

I think you’ll get a stack overflow. Try changing this

gosub top 

in this

goto top 

Xan

heh, I bet if you listened you could hear the whirlwind noise as it augered itself into the stack. :laughing:

Yeah I did hear it, and I think I’m deaf now…

ehh so exactly why would someone use gosub vs goto? I’ll go ahead and post this and then look in my manual shortly after.

xan – that fixed it. Thanks!

–Aaron

GOTO jumps to another part of a program… one way trip.

GOSUB is a call to a subroutine or function that does some task and returns to the instruction following the GOSUB command. frequently if you had a clip of code that was repeated a lot you could write it as a subroutine and then everywhere you needed the code you would GOSUB to that code.

the reason GOSUB was crashing your program is GOSUB leaves a return address on the stack so it knows how to get back to the section of code that called it. If you don’t ever return the address stays on the stack. in your case you were using it to jump back to the top of your program and eventually you filled the stack and the program reset itself.

EddieB

I think I understand

for instance when you write a function to read some inputs and store them as variables you label this at the top with some “Readinputs” or something and at the bottom of that code you put a return

so later when you want to call that you write gosub readinputs “it reads the inputs” then returns to the line right after the gosub command correct?

Apparently you can only have it gosub like 500 times before that memory address gets full since I never used the return statement to clear it…

That about right?

–Aaron

pretty much how it works.

Ive been having the most interesting time trying to get individual leg control so far the only thing ive gotten is it to beep when I put it into mode 3 and anything else I do I get compile errors

So if someone could help me figure out how to get 1 individual leg under rc control minus all the IK as from the looks of it this code does not use IK when the servos are under direct RC control

I have been looking at the code zenta has changed for his modified T7C remote ‘I just gotta say this remote is really swoopy’ has many features that now I wish I had a helicopter! to use them all… anyway…

so zenta provided me with this snippit of code

'Balance left front leg TestLeg = LFGaitLegNr TravelLengthX = (pwmInput01 -1500)/4 TravelLengthZ = (pwmInput02 -1500)/4 TravelHeightY = (pwmInput03 -1500)/2'for balance testing
this was posted one page back

So far this line of code makes perfect sense to me. although I would want to hard set a leg to control and then once I grasp that I’m pretty confident I can add the rest of the legs and have a bunch of if statements inside that selecting which leg to control next.

Zenta had told me and after me looking at the t7c phoenix code he had shown me and 1 page back the Right Front leg 3 servos were controlled by

RFPosX RFPosY RFPosZ

that so I put 2 and 2 together and came up with this

'Balance left front leg RFPosX = (pwmInput01 -1500)/4 RFPosZ = (pwmInput02 -1500)/4 RFPosY = (pwmInput03 -1500)/2'for balance testing

Although that did not work for me, I think im missing something crucial here and pretty much diving head first into this code trying to grasp it… so some clarification would help immensely!

I have taken this code zenta had sent me in a PM that he had sent to someone else who wanted to use a un modified version of the T7C remote, I would totally hack up my remote for that but i sense an RC helicopter coming in the near future that is unless my phoenix doesn’t attack me like it did the banana robot earlier… I’m still cleaning him off the walls :\

One thing that I did notice that I don’t know how it works is when you do individual leg movement and you used your robot to plop its leg on top of a box and you switched back to the mode where it is able to be rotated while keeping that box in 3d space without shifting around the plastic boxes… what keeps that leg there?

I have been curious what the Zenta Xan combo have up their sleeves for other features they are working on…

I know kurte is trying to make a pure assembly version of the pheonix 1.3 code… “Or one could hope” Id imagine that would be an utter nightmare to take on as a task… actually come to think of it, you think the actual IK subroutines would be sped up considerably if coded in assembly?

How’s that terrain adaption coming Xan?

im guessing it will be the End Leg calculations.
something like this:

IKFeetPosX var sword ;Input position of the Feet X IKFeetPosY var sword ;Input position of the Feet Y IKFeetPosZ var sword ;Input Position of the Feet Z IKFeetPosXZ var sword ;Length between the coxa and feet


i take it pwminput# corresponds to the servo pin numbers? are they correct! always best to check!

Yeah the pin’s are correct as My phoenix is RC control only, Ive been walking around the last couple days scaring the cats and my buddies are like wow was that like $200 dollars and I’m like yes but take that number and multiply it by 5!

Humm, I’ll try those variables you posted and get back to you.

–Aaron

also i would have a look over this. iv been trying to see if i can get this section to work with it:

;-----------------------------[BalCalcOneLeg] BalCalcOneLeg [PosX, PosZ, PosY, BodyOffsetX, BodyOffsetZ] ;Calculating totals from center of the body to the feet TotalZ = BodyOffsetZ+PosZ TotalX = BodyOffsetX+PosX TotalY = 150 + PosY' using the value 150 to lower the centerpoint of rotation 'BodyPosY + TotalTransY = TotalTransY + PosY TotalTransZ = TotalTransZ + TotalZ TotalTransX = TotalTransX + TotalX

Humm not sure what that really does… but it does not look complicated… Since I didn’t make that code for me to quickly grasp what each variable does is a bit beyond me at this point :frowning:

slowly but surely! one compile error at a time.