Precision Mode

My team has used this technique with great results, and I thought that I would share it with everyone. We all want our robot to be as fast and possible, but precision is also key. We solved this problem by having our robot move at half speed while a certain button is pressed. Here’s the code.


task main(){
  int precision = 1;
  while true(){
    precision = vexRT[Btn6U] ? 2 : 1;
    //Sets precision equal to 2 if button 6U is pressed, and 1 if it's not

    motor[leftWheel] = vexRT[Ch2] / precision;
    motor[rightWheel] = vexRT[Ch2] / precision;
  }
}

Very nice… I’m learning a lot from people like you posting their code. :slight_smile:

Thank you!

You’re very welcome. What’s the point of having ideas if you don’t share them with others?

Very good idea! I love it! I think our team may implement something like this, sometimes we just go too fast.:smiley: (If such a thing is possible?)

hah!
nice thats what we did!
we used easyc cortex to program our robot so the code was a lot longer than yours
its the exact same concept though
but now with easyc pro you cant “/2” because the value is from 0 -255 rather than -127 - 127 :frowning:
and we dont have time to figure it out before competition this weekend
maybe for the next one :slight_smile:

btw whats your drive ratio?
fast enough that you need a code like that? :wink:

Just say: if joystick value is more than 0, divide by 2. Am I not understanding your problem? I don’t know easyC at all, sorry. I like to write everything from scratch by myself :stuck_out_tongue:

And as to weather you need it, think about a 4 wheel robot powered by just two motors with the driving wheels being 5". If you try and turn to pick up a ring a just little bit to the left at the same speed that you drive, you’re going to overshoot. Or the drivers can carfully nudge the joysticks back and forth, but that wastes a lot of time. I find that the precision button really helps.

The half-speed algorithm for EasyC Pro is simple.
You just need to add 64 back to the value to re-center it around 128:


half_speed = ( speed / 2 ) + 64 ;

If speed = 0, half_speed = 0/2+64 = 0+64 = 64
If speed = 128, half_speed = 128/2+64 = 64+64 = 128
If speed = 255, half_speed = 255/2 + 64 = 127+64 = 191

Cheers,

  • Dean

We had to do a similar thing with our robot, actually having to scale down to about 1/3 speed, as 1/2 wasn’t enough…

~Jordan

thanks!
been thinking about that for a while
but now our vexnet is still glitchy and were scared to reprogram :stuck_out_tongue:
lets see if i can do it on the bus ride there XD
thanks again for the sample code!

MM

i tried to do this on easyC but i keep getting a syntax error (line 26)
http://min.us/jBZaa.bmp
is there something im missing in the “user code” blocks?
i tried the “help” button but that wasn’t any help
thanks

You are missing the semicolons at the ends of the lines. You have to remember to add those yourself with user code blocks.

Cheers,

  • Dean

thanks!
i tried () ;
because that was how i ended my go to “function” user blocks
thanks again! :slight_smile:

sorry for yet another programming question :frowning:
http://min.us/jTMPA.bmp
i tried “setting” a motor to a particular variable (so i can edit the values later on)
but the variable value “nmotor7” is not getting the Radio input, it is just getting the “0” value in the variable box (i didn’t put value down but it defaults to 0)
therefore the motor just spins continuously
this happened to my main code but i simplified it until this to catch the error
thanks :slight_smile:

Thanks!

I tried putting something like in out holonomic drive (or X drive what ever you prefer), but it caused all of the motors to not work when the channel for rotating was added in. Any tips on how to solve this problem?

If you were helping someone with a similar problem, what information would you need to help them?
Post your code.