Write a algorithm for Chris and be Loved

Walter_1.3_Joystick_001.jpg (2743064Bytes)

Well folks,

I have been working on this problem for 4 days now and don't seem to be making any headway. There has got to be a math or programming geek out there that can figure this one out. The video should be self-expanitory, and the chart with the values is right here. In addition, I attached the pic as a file as well (full size) so you might be able to see the numbers a bit better. --Sorry no scanner.

 

Walter_1_3_Joystick_001.jpg

https://www.youtube.com/watch?v=yMy5dxhsdVQ

Huh…

I hashed out something in C++ that seems to works, it’s a rediculous if - else-if block though. I’ve tried all of the values at 0, 45, 90, 135, 180, 225, 270, 315 and 360 degrees in that chart. The in-betweens weren’t mentioned in the video though.Hopefully if this is what you’re looking for you can adapt it to whatever you have to write it in.

if (y <= 225 && y > 150 && x == 150)
cout << “Top Left Slide”;
else if (x <= 225 && x > 150 && y == 150)
cout << “Top Right Slide”;
else if (x <= 225 && x > 150 && y <= 225 && y > 150)
cout << “Forward”;
else if (x >= 75 && x < 150 && y >= 75 && y < 150)
cout << “Reverse”;
else if (y <= 205 && y > 150 && x >= 95 && x < 150)
cout << “Left Spin”;
else if (x <= 205 && x > 150 && y >= 95 && y < 150)
cout << “Right Spin”;
else if (x >= 75 && x < 150 && y == 150)
cout << “Bottom Left Slide”;
else if (y >= 75 && y < 150 && x == 150)
cout << “Bottom Right Slide”;

 

EDIT: I forgot to ask whether it’s full-on for the motors, or if it’s gradual depending on where the stick is. If it’s the former, this needs some changes, but just some of the logic which is easy to figure out.

Oh thanks a lot! “Pal”!
Now this is gonna keep me awake at the office all day 8-(

Dude: Take one wheel at a

Dude: Take one wheel at a time, one axle at a time:

Y axle, Left wheel:

More up, more forward, more down, more backwards.

Do the same with all wheels, all axles, spit out result.

I dont get it

Wouldn’t The position on the X axis be proportional to the desired speed of the R motor? And the same with the Y axis and L motor?

so if X goes from 151 to 225, the right motor should go forward at an increasing speed. And from 149 to 75 it should go at an increasing speed backward.

I don’t know much about aneurysms, but wouldn’t you just need to do some simple math to convert the nummerical values from 75 to 150 to 225 into the corresponding numeric values for you motor output to go -100% to 0% to +100% ??

I think I’ve misunderstood your whole question here, but please help me understand.

Slow day at the office…

And in the echonomy at large.

Chris, did you ever read this Control manual for the VEX (pdf)? I’m guessing you did. And now I did as well.

1) Do I understand correctly that you were driving your bot in “tank style” or “two-three mode”? And now you want to convert to “Arcade style” or “one-two mode”? (pages 6.5 and 6.6 resp.)

2) Do I understand correctly that you are reconfiguring your VEX transmitter to the “12-mode” as documented? Or are you trying to emulate this mode by cleverly reprogramming your picaxe. And cleverly outsourcing any accidental aneurysms along the way?

You suggest that your pots are positioned diagonally. The manual does not make any mention of this. I would never doubt the tinkerer with the actual set on his workbench, so I will accept this as fact. However, I feel that the “software signal mixing feature” in “12-mode” is making it look like the pots are placed diagonally. Perhaps this is what you are referring to, but you don’t want to confuse us. Either way, it can be considered to be diagonal.

Here’s some more links from VEX inventor’s guide:
Logic appendix
Control configurations appendix

 

Tonight, when I have Youtube access again, I will see if I can post a proper response.

It looks like: If the number

It looks like:

If the number is > 150 then you want the motor to go forward.
If the number is < 150 then you want the motor to go in reverse.
If the number = 150 then do nothing so the bot can slide.

What is the desiered result for the marks between slide and spin? (NNW, NNE, etc)

 

No twisty the joystick

Take that values from the joystick as it sits, up-down axis called Y with values given from 75 bottom to 225 top, right-left values called axis X with 225 left, 75 right.

Y
225
X 225 <> 75 Joystick
75

PWM values for left and right wheels can then be calculated from formulas :

L_PWM = (Y - X) + 150

R_PWM = (Y+ X) - 150

Evaluation of calculated output :

Direction (Y,X) :
Full Fwd (225,150): L_PWM = (225 - 150) + 150 = 225, R_PWM = (225 + 150) - 150 = 225
Full Rev (75,150) : L_PWM = (75 - 150) + 150 = 75, R_PWM = (75 + 150) - 150 = 75
spin CW (150,225): L_PWM = (150 - 225) + 150 = 75, R_PWM = (150 + 225) - 150 = 225
spin CCW (150,75): L_PWM = (150 - 75) + 150 = 225, R_PWM = (150 + 75) - 150 = 75

curve forward left (205,205): L_PWM = (205 - 205) + 150 = 150, R_PWM = (205 + 205) - 150 = 260, out of range
curve forward right (205,95): L_PWM = (205 - 95) + 150 = 260 out of range, R_PWM = (205 + 95) - 150 = 150

curve back left (95,205): L_PWM = (95 - 205) + 150 = 40 out of range, R_PWM = (95 + 205) - 150 = 150
curve back right (95,95): L_PWM = (95 - 95) + 150 = 150, R_PWM = (95 + 95) - 150 = 40 out of range

Might be needed to limit max and min range values for PWM output.

This community is simply great!
I would like to thank you all, as it is awesome to have a (few) new sets of eyes on a problem… First off rik, I should have mentioned I am moving away from the VEX controller as I would like to build my own. I know the VEX system has the arcade/tank style controls built in, but the controler I am working on will only be one stick. By the way, have you guys seen these? It is almost the same joystick as the one in a PS2 controller, pots and all for 4 bucks from Sparkfun. At first glance, I am liking Robo’s math with some min’s and max’s added but I thank everyone for their help. When I get this guy going I will be sure to do a neat walkthrough for y’all. Thanks again, folks.

You big tease!

How dissatifying 8-( .

You promised us a problem to crack! I bet your just checking your firmware version right now…

Need a bigger front page

I know robots don’t seem to stay on the front page for very long, but have you seen GreenRoomBaa? What you describe is precisely what she does.

Did you figure it out, or do you still need that algorithm? It’s 11.30pm, I’m going for Zzzz, but can probably chat tomorrow.

Yup, Robologist…

You nailed it dude…

Now, I do have to kick myself for the 4 days I racked my brain on this one… I can’t believe how simple the final code is!

Thanks again

 

Coded

Ah. you coded it already. Fairy nuff. My approach was only slightly different. My bot takes as its inputs (1) speed and (2) radius of turn. I was about to sit and figure out how to convert speed and radius of turn (the results from MY algorithm) into coaxial track PWMs!

Do I still get the Coveted Rusty Soldering Iron Trophy for doing it first?

This diagram stinks

I recreated a diagram like it, using expected values. Correcting for SIN(joystick-angle). The Y/X numbers along the SE and SSE positions are reversed. And most numbers are off from the predicted values by as much as 30 (at ESE and NNW for example).

But from the resulting values I can deduce that your stick does not move around in a circle, but in a square. And a motor does not get full power unless the other motor is completely stopped.

But maybe that is just the way I expected them to be.

I have the same problem when
I have the same problem when coding the nunchuck controller and the most clever solution I find was the if/else coding mess… I have came up with this remote controller as OddBot already metioned and it feeds my needs :slight_smile:

must try to understand the robologist solution, seems much more easier than I though

No prob, hope it gets Walter
No prob, hope it gets Walter going well. I hope to use this idea on an outdoor wanderer, to take over control when needed. Probably use an XBee link, with some of the little joysticks. I have some like you’ve shown, except no knob on the end so may have to Shapeloc something.

Normal

(Little geometry joke for you there!)

2D pots are normally like that. The X limit is flat for the full Y extents and vice-versa. I agree - it’s not intuitive. My first calculations overflowed for exactly the reasons you mention. Whatever I’d done, the bot went wherever I told it EXCEPT in a straight line.