Help Coding a "Creep Mode"

Hi,

I’m trying to figure out how to attenuate the drive motor speed at the push of a button. For example, if normal operation allows for a value of 0 to 1, we’d like to be able to push a button and have the new value be 0 to 0.5.

I’ve been searching around for how to do this and I can’t seem to find anything definitive. I used Team 358’s examples but I’m not sure that I got it right. I’ve been using the LabVIEW simulator to test out the code. The robot moves but does not slow when I activate the joystick push button on the xbox controller (button 9). I’ve attached what I have so far.

Any ideas?

Thanks!





Does “Button 9” mean the ninth button counting from 1, or counting from zero? Don’t forget that the first button is at array index 0, so the ninth button is actually at index 8. You can set a probe on the Buttons array to verify which one you need to be reading.

Thanks for the quick reply! I used the mapping that’s been floating around CD: http://www.chiefdelphi.com/forums/showpost.php?p=1298473&postcount=2

However, now I found a map saying the left joystick is button 8, not 9… Odd that it’s from the same source.

The 9th light comes on in the dashboard when I press it but I’ll go back to the simulator and try button 8. Is there anything wrong with the code?

During the Beta Test, there was a strong preference among the Java and C++ teams for the button numbers in the code to match the labels on the joysticks/gamepads. The LabVIEW functions stayed with the zero-based arrays. It’s a little confusing if you’re moving between programming environments.

You do want the ninth button. But its value is in array index 8, because the first button is in index 0.

That post is from 2013 and applied to the cRIO and pre-2015 code. The xbox mapping has changed with the 2015 control system.

Aside from that your code looks fine once you change the index from a 9 to an 8.
Just make sure, depending on your drive train, that the rotate is still getting enough power to act against any wheel scrub at low power.

Instead of limiting the voltage that can be supplied, a different option would be to contour the joystick’s output to reduce the gain at low joystick commands but still allow full joystick output at high joystick commands.

This can be done with a smooth mapping function, or a piecewise-linear function, or a lookup table.

Here are some links to more info:

http://www.chiefdelphi.com/media/papers/2421

http://www.chiefdelphi.com/forums/showpost.php?p=1438321&postcount=15

http://www.chiefdelphi.com/forums/showpost.php?p=988803&postcount=13

http://www.chiefdelphi.com/forums/showpost.php?p=1236655&postcount=13

http://www.chiefdelphi.com/forums/showpost.php?p=1432221&postcount=4

What I would do is make a true/false case structure so that when the “button pressed?” reads false it does nothing but when it reads true it divides the value by 2.

Voilà!

(Although if it IS a controller problem the above posts should help fix that :))

Thanks everyone! I changed the array index from 9 to 8 and it works.