Sandbox
From Team1370
(Difference between revisions)
(→Exponential Output) |
(→Exponential Output) |
||
Line 25: | Line 25: | ||
By using an exponential equation, the output may be ramped. | By using an exponential equation, the output may be ramped. | ||
- | *By using <m> (root{3} | + | *By using <m> (root{3}{x-127} * 16129) + 127 </m>, as the joystick is pressed forward or backward, speed gains very quickly at first, then increases at a slowing rate. |
*To get the robot to go slowly at first, then faster and faster, try <m> ((x-127)^3 / 16129) + 127 </m> | *To get the robot to go slowly at first, then faster and faster, try <m> ((x-127)^3 / 16129) + 127 </m> |
Revision as of 17:26, 14 February 2006
A workspace for temporary things
Contents |
Joystick Config
- Control values will range from 0 to 254.
- Each value corresponds to a specific motor speed on the robot. 127 is neutra, <127 is reverse, >127 is forward.
Motion
- Forward and backward motion will be achieved by cycling Joystick 1 and Joystick 2 forwards or backwards at the same time
- Turning will be achieved using a track configuration. Moving Joystick 1 forward at a higher rate than Joystick 2 will result in a left turn, and vice versa for right. Moving left forwards equal to right backwards will result in a 360 degree left turn and vice versa for right.
- The throttle will change the thrust multiplyer and/or additive.
Sensitivity
- Joystick sensitivity is a problem, but there are a few solutions
Linear Output
- We currently operate on linear output, where every joystick value x corresponds to motor value reception y plus or minus throttle setting z.
- Throttle can count as a speed shifter. If we have max and min output value limiting functions, we can shift the throttle to achieve a higher max forward speed and a lower max reverse speed and vice versa if necessary on the fly.
Exponential Output
By using an exponential equation, the output may be ramped.
- By using <m> (root{3}{x-127} * 16129) + 127 </m>, as the joystick is pressed forward or backward, speed gains very quickly at first, then increases at a slowing rate.
- To get the robot to go slowly at first, then faster and faster, try <m> ((x-127)^3 / 16129) + 127 </m>
Notice that 16129 is 254^2 / 4
Math for throttling
Stick stuff here
if (Joystick >= 255) Joystick = 254; if (Throttle >= 255) Throttle = 254; pwm = ((Joystick - 127) * (Throttle) / 254) + 127;
- The (Joystick - 127) means that the joystick value is shifted so that it goes from -127 to 127.
- The +127 at the end shifts the system back up to the 0 to 254 range.
- The limit_mix function could be added in to prevent the pwm from recieving a number outside of 0-255 (although I don't see how that could happen).
The above code allows for a centered joystick to always leave the robot sitting still. When the throttle is at full, the joysticks work normally. When the throttle is at 0, the joystick range is cut from 0-254 all the way to just 127 (thus there is no movement). At a throttle of 127 (halfway), the joystick can go from 63.5 to 190.5. Here is the chart:
254 | 127 | 0 | |
---|---|---|---|
254 | 254 | 127 | 0 |
127 | 190.5 | 127 | 63.5 |
0 | 127 | 127 | 127 |