Go to Post You can either spend lots of energy complaining about it and whining or you can try to figure out how to make a positive experience from the whole thing. - dlavery [more]
Home
Go Back   Chief Delphi > Other > FIRST Tech Challenge
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 06-11-2010, 07:58
JohnFogarty's Avatar
JohnFogarty JohnFogarty is offline
FTC, I have returned.
AKA: @doctorfogarty @GarnetSq
FTC #11444 (Garnet Squadron) & FRC#1102 (M'Aiken Magic)
Team Role: Mentor
 
Join Date: Aug 2009
Rookie Year: 2006
Location: SC
Posts: 1,555
JohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond reputeJohnFogarty has a reputation beyond repute
[FTC]: Not Deadbands now.....speed limits

I know someone somewhere out there uses a speed limit on their joysticks. Even when you've geared the motors down sometimes the speed is a little tooo fast. Soo say I want to limit on the upper values like 90 and above or -90 and below to the speed of 60/-60. The logic doesn't work like an if/then statement or rather I haven't gotten it to work.

P.S.-It seems RobotC's compiler takes two compiles sometimes just to get the robot to see a change you've made.
__________________
John Fogarty
2010 FTC World Championship Winner & 2013-2014 FRC Orlando Regional Winner
Mentor FRC Team 1102 M'Aiken Magic
"Head Bot Coach" FTC Team 11444 Garnet Squadron
Former Student & Mentor FLL 1102, FTC 1102 & FTC 3864, FRC 1772, FRC 5632
2013 FTC World Championship Guest Speaker
Reply With Quote
  #2   Spotlight this post!  
Unread 06-11-2010, 18:01
rzoeller rzoeller is offline
MN GOFIRST Recruitment Officer
AKA: Ryan Zoeller
FRC #2169 (RI3D 'Snow Problem; KING TeC)
Team Role: Alumni
 
Join Date: Nov 2009
Rookie Year: 2007
Location: Savage, MN
Posts: 111
rzoeller is a jewel in the roughrzoeller is a jewel in the roughrzoeller is a jewel in the rough
Re: [FTC]: Not Deadbands now.....speed limits

To circumvent the double compile problem (I have experienced it as well), use a different name for each version. You should do this anyways, but just tag it with a version number and it will update correctly.

One solution to the other problem is to use a parabolic system, demonstrated by the code below.
Code:
#include "JoystickDriver.c"  //Include file to "handle" the Bluetooth messages.
void initializeRobot()
{
  return;
}
void scaleMotor(char motorname, int joyVal)
{
  int sign = joyVal / abs(joyVal); //Returns a 1 or -1
  float ratio = ((joyVal * joyVal) / (16129)); //Gets a ratio from a parabolic curve
  int scaledVal = (sign * 100) * ratio;
  motor[motorname] = scaledVal;
}

task main()
{
  initializeRobot();

  waitForStart();   // wait for start of tele-op phase
  while (true)
  {
    getJoystickSettings(joystick);
    scaleMotor(DriveL, joystick.joy1_y1);
    scaleMotor(DriveR, joystick.joy1_y2);
  }
}
You add if statements to that to limit when it will scale the motors, I.E. below 75%.
__________________
Ri3D - 'Snow Problem Programmer
MN GOFIRST Recruitment Officer
FRC 2169 Alumni
Reply With Quote
  #3   Spotlight this post!  
Unread 07-11-2010, 20:31
lemiant's Avatar
lemiant lemiant is offline
the Dreamer
AKA: Alex
FRC #4334 (Alberta Tech Alliance)
Team Role: Leadership
 
Join Date: Feb 2009
Rookie Year: 2008
Location: Calgary, AB, Canada
Posts: 562
lemiant has a reputation beyond reputelemiant has a reputation beyond reputelemiant has a reputation beyond reputelemiant has a reputation beyond reputelemiant has a reputation beyond reputelemiant has a reputation beyond reputelemiant has a reputation beyond reputelemiant has a reputation beyond reputelemiant has a reputation beyond reputelemiant has a reputation beyond reputelemiant has a reputation beyond repute
Re: [FTC]: Not Deadbands now.....speed limits

Or just change the multiplier, from * 100 to whatever you want for the maximum speed. This way you keep the entirety of the joystick for driving, instead of having your code lump the outer edges together.
Reply With Quote
  #4   Spotlight this post!  
Unread 28-11-2010, 16:42
PSHRobotics PSHRobotics is offline
Registered User
FRC #1182
Team Role: Programmer
 
Join Date: Feb 2010
Rookie Year: 2008
Location: Missouri
Posts: 38
PSHRobotics is an unknown quantity at this point
Re: [FTC]: Not Deadbands now.....speed limits

Quote:
Originally Posted by lemiant View Post
Or just change the multiplier, from * 100 to whatever you want for the maximum speed. This way you keep the entirety of the joystick for driving, instead of having your code lump the outer edges together.
I know this is a slightly old topic, but the original poster has not responded saying how he fixed his issue and it is something that I had been looking into earlier and would like to see if anyone has actually found an effective solution.

That's how we have been doing it for the past couple of years. In which case, he would scale the joystick values by dividing by 127 and then just multiplying by 90. (I use LabView, but I believe the logic works the same).

What I am curious about, however, is that the original poster seems to want the values to be above 60 (and under 90). I am unsure how I would actually do this.
I would think the best way to do it would be to find the "sign" of the joystick value (which rzoeller has shown in his code) and split into an if, then, and else sequence where if the sign is positive (1) you take the joystick value divide by 127 then multiply by 30 and finally add 60. While if the sign is negative you take the joystick value divide by 127 then multiply by 30 and finally subtract 60.
Reply With Quote
  #5   Spotlight this post!  
Unread 28-11-2010, 20:07
EricVanWyk EricVanWyk is offline
Registered User
no team
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Boston
Posts: 1,597
EricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond reputeEricVanWyk has a reputation beyond repute
Send a message via AIM to EricVanWyk
Re: [FTC]: Not Deadbands now.....speed limits

NOTE: I am relatively unfamiliar with Robot C, I have one season of coaching BEST worth of experience with it. Please check that my assumptions are correct. The first bit might not actually be an issue...

There may be a bug hiding in this line:
float ratio = ((joyVal * joyVal) / (16129));
If Robot C handles casting like C does, the actual math will be done in integer math, and then cast to a float at the end. Follow it through the parenthesis to find this:
  1. float ratio = ((joyVal * joyVal) / (16129));
  2. float ratio = float ((int * int) / (const int));
  3. float ratio = float (int / const int);
  4. float ratio = float (int);

In the 3rd step, dividing an int by a const int will truncate to an int. When it is cast to a float in the 4th step, the information is already lost. It is likely that this doesn't really matter, but it makes for a confusing read.

I'd recommend replacing the line with
float ratio = ((joyVal * joyVal) / (16129.0));
Now you are dividing an int by a const float, which will be done in floating point math.



Do you want to rescale the sticks so that full forward on the stick is 60%, and everything in between is rescaled? Or, do you just want to chop off the top of the sticks so that anything above 60 is limited to 60?

Rescale:
The key to rescaling is to find center of your range, pull it to zero, do your scaling, and then push it back to the real center. Then, shuffle your math around until it looks good for a computer.

For example, lets rescale around 127:
recentered = input - 127;
scaled = recentered * ratio;
output = scaled + 127;

Put it all on one line:
output = (input-127) * ratio + 127;

If ratio is a floating point number between 0 and 1, you are done. If you want to rephrase it as your new maximum value, write it like this:
output = (input-127) * max_value / 127.0 + 127;

You can likely leave off the ".0" from "127.0". Just be sure you follow the golden rule of integer division: Multiply, then divide. Going the other way around kills your accuracy.


PS/EDIT: I'm confused as to your goal still. Could you please draw a graph of what you want to do, with "input from the joystick" on the x axis and "output to the motors" on the y axis? You can sketch it in mspaint or whatever, just label a few key spots.

Last edited by EricVanWyk : 28-11-2010 at 20:15.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[FTC]: Deadbands (axis/motor power restrictions) JohnFogarty FIRST Tech Challenge 4 04-11-2010 19:03
[FTC]: Anyone new to FTC or TETRIX, READ THIS NOW! PhilBot FIRST Tech Challenge 21 04-12-2009 17:34
[FTC]: DC Motor Speed ethan_orion FIRST Tech Challenge 8 28-10-2009 12:36
[FTC]: Your in Atlanta...now what? gdo FIRST Tech Challenge 0 10-04-2008 21:49
Speed Controller Limits yaman Technical Discussion 11 15-01-2003 18:40


All times are GMT -5. The time now is 17:16.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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