Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   autonomous mode (http://www.chiefdelphi.com/forums/showthread.php?t=53145)

seanl 31-01-2007 12:58

autonomous mode
 
hi im the programmer for team 867, i was wondering is there any default code for autonomous. and i have another question, how can we activate autonomous mode for testing.

Dave Scheck 31-01-2007 13:01

Re: autonomous mode
 
This thread may help you out
http://www.chiefdelphi.com/forums/sh...threadid=53137

seanl 31-01-2007 13:14

Re: autonomous mode
 
ok kool i got it. this has nothing to do with this but i want to add a dead zone on the joystick. so like the robot wont move the split second you touch the joystick, how can i do this.

mluckham 31-01-2007 13:38

Re: autonomous mode
 
1 Attachment(s)
Quote:

I want to add a dead zone on the joystick. so like the robot wont move the split second you touch the joystick
There is already a dead zone built into the Victor speed controllers. But whether you realize that or not, the joysticks must not be giving the response you want.

You could try something simple like this, to basically ignore the values near the centre of travel:

Code:

if ((joy >= 120) && (joy <= 140))  joy = 127;
Or a more sophisticated "exponential" method:

Code:

speed = joy - 127;
newspeed = ((speed * speed) / 127) * sign(speed);

I have attached a Labview 8 application that demonstrates various joystick response curves.

Good luck,

Mike

seanl 31-01-2007 13:56

Re: autonomous mode
 
i have 2 questions
1. where do i splice in the code you gave me i was looking through the code i cant see where to put it.
2. do i connect the user interface to my computer for running the labview program.

Dave Scheck 31-01-2007 14:41

Re: autonomous mode
 
Quote:

Originally Posted by mluckham (Post 568888)
You could try something simple like this, to basically ignore the values near the centre of travel:

Code:

if ((joy >= 120) && (joy <= 140))  joy = 127;

This is a good idea, but I would propose the following enhancement to make it a little more flexible
Code:

#define JOYSTICK_DEADZONE  5
...
if((joy >= (127 - JOYSTICK_DEADZONE)) && (joy <= (127 + JOYSTICK_DEADZONE)))
{
  joy = 127;
}

Then, to extend that even further, you could create a macro so that you could apply deadzones whenever you needed to.
Code:

#define JOYSTICK_DEADZONE  5

#define DEADZONE(input, dz) (if(((input) >= (127 - (dz))) && ((input) <= (127 + (dz)))) (input) = 127;)

...

DEADZONE(joy1, JOYSTICK_DEADZONE)
DEADZONE(joy2, JOYSTICK_DEADZONE)

Notice that the lines that "call" the macto don't have semicolons. This is because there is a terminating semicolon at the end of the macro itself.
Quote:

Originally Posted by seanl
1. where do i splice in the code you gave me i was looking through the code i cant see where to put it.

Well, if you think about this logically, your outputs (pwm/relay/analog/digital outs) are based on your inputs, so it makes sense that deadzone code would be placed somewhere after the inputs are read, but before the outputs are written. Depending on how your inputs map to outputs, you may have intermediate calculations. It would then make sense to place your deadzone code before those calculations. When in doubt, take a deep breath and think through the problem. Programming is about thinking logically. Go step by step and you'll figure it out.
Quote:

Originally Posted by seanl
2. do i connect the user interface to my computer for running the labview program.

I don't know anything about the way that labview works. Hopefully someone else can answer that question.

mluckham 31-01-2007 15:59

Re: autonomous mode
 
1 Attachment(s)
Quote:

i have 2 questions
1. where do i splice in the code you gave me i was looking through the code i cant see where to put it.
2. do i connect the user interface to my computer for running the labview program.
If you are using MPLAB, you will see (in the default code) where the joystick values are read, then the resulting values are assigned to the Victor pwm output variables. So you put the joystick code JUST AFTER the joystick value is read. You will have to make your own decisions for variable names, etc. And the code I provided is only for one joystick axis - you will have two joystick axes, so will need twice the amount of code.

Labview is a graphical development environment that runs on your PC. A copy of Student Labview was included in the KOP this year. I am attaching a screen shot of the Labview program running the Joystick application - you will get the idea that it is only useful to ILLUSTRATE how joystick values might be processed. The simulated joystick input is the horizontal slider at upper left. The three scales below show linear (direct), exponential, and logarithmic conversions.


All times are GMT -5. The time now is 11:27.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi