Go to Post The question is like asking "Is it better to drive by looking at a map the whole time or by remembering where you want to go and watching the road instead?" - lukevanoort [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 12-03-2015, 15:44
414cnewq 414cnewq is offline
Registered User
FRC #3844 (Kentucky Wildbots)
Team Role: Alumni
 
Join Date: Jul 2014
Rookie Year: 2014
Location: KY
Posts: 86
414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of
Why isn't my slowdown working?

Okay. I have this code to add joystick sensitivity(it seems to work):
void joystickSanatizer(float*x, float*y){
//Pointers All the Way!!! #starmaster
if(*x<0){
*x*=*x;
*x*=0-1;
}
else *x*=*x;
if(*y<0){
*y*=*y;
*y*=0-1;
}
else *y*=*y;
}
in TeleopPeriodic:
float joyx=stick->GetRawAxis(0);
float joyy=stick->GetRawAxis(1);
joystickSanatizer(&joyx, &joyy);
if(stick->GetRawButton(10)){
multiplier=0.4;
}
else multiplier=1;
and then, after some unrelated code:
rBot->ArcadeDrive(joyy*multiplier, joyx*multiplier);
Where stick is an XBox 360 controller and rBot is a a RobotDrive object

The point of this code is to slow down the robot... but it doesn't.
Can someone help me fix this code or give me another way to slow down the robot.
Reply With Quote
  #2   Spotlight this post!  
Unread 12-03-2015, 16:12
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 431
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Why isn't my slowdown working?

Have you added debug print statements for you code to see if your inputs and outputs make sense?
THat might help you get a quick sanity check of where your code is going wrong.


Is there's a reason you don't want to do something a little simpler?

Code:
float joyx = stick->GetRawAxis(0);
float joyy = stick->GetRawAxis(1);
 
if(stick->GetRawButton(10)){
  multiplier = 0.4;
} else {
  multiplier = 1;
}
rBot->ArcadeDrive(joyy * multiplier, joyx * multiplier);
Just change your multiplier variable to affect commanded rate of travel.

It doesn't give you X^2 scaling, but not sure you need that.


Keeping the x^2 implementation:
Code:
float joyx = stick->GetRawAxis(0);
float joyy = stick->GetRawAxis(1);

//#nostarmaster
joyx = joyx * abs(joyx); 
joyy = joyy * abs(joyy);

if(stick->GetRawButton(10)){
  multiplier = 0.4;
} else {
  multiplier = 1;
}
rBot->ArcadeDrive(joyy * multiplier, joyx * multiplier);
I think this one does exactly what you were trying to do in your code.
__________________
http://team2168.org

Last edited by otherguy : 12-03-2015 at 17:22. Reason: added another option closer to original implementation
Reply With Quote
  #3   Spotlight this post!  
Unread 12-03-2015, 17:24
GeeTwo's Avatar
GeeTwo GeeTwo is offline
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,654
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: Why isn't my slowdown working?

Or even simpler, with squaring:
Code:
float joyx=stick->GetRawAxis(0);
float joyy=stick->GetRawAxis(1);
multiplier = stick->GetRawButton(10) ? 0.4 : 1;

rBot->ArcadeDrive(joyy*abs(joyy)*multiplier, joyx*abs(joyx)*multiplier);
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Reply With Quote
  #4   Spotlight this post!  
Unread 12-03-2015, 17:53
414cnewq 414cnewq is offline
Registered User
FRC #3844 (Kentucky Wildbots)
Team Role: Alumni
 
Join Date: Jul 2014
Rookie Year: 2014
Location: KY
Posts: 86
414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of
Re: Why isn't my slowdown working?

Well, there's another portion of my code affected by the slowdown (the tote pickup motor) that is affected by the slowdown:
outside TeleopPeriodic:
float motorpower;
inside:
if(stick->GetRawButton(10))
motorpower=0.4;
else
motorpower=1;
later in TeleopPeriodic(where vmc is a talon object):
vmc->Set(motorpower);
and that does not work.
any thoughts?
Reply With Quote
  #5   Spotlight this post!  
Unread 12-03-2015, 23:40
otherguy's Avatar
otherguy otherguy is offline
sparkE
AKA: James
FRC #2168 (The Aluminum Falcons)
Team Role: Mentor
 
Join Date: Feb 2010
Rookie Year: 2009
Location: CT
Posts: 431
otherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to beholdotherguy is a splendid one to behold
Re: Why isn't my slowdown working?

Can you share an actual excerpt from your code?

Can you elaborate on "doesn't work"? What action are you performing and how is the robot responding that leads you to the conclusion that it's not doing what you want?

The 'code' looks reasonable, but you haven't really described what is happening, just that what happened isn't want you expected.
__________________
http://team2168.org
Reply With Quote
  #6   Spotlight this post!  
Unread 17-03-2015, 15:30
414cnewq 414cnewq is offline
Registered User
FRC #3844 (Kentucky Wildbots)
Team Role: Alumni
 
Join Date: Jul 2014
Rookie Year: 2014
Location: KY
Posts: 86
414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of414cnewq has much to be proud of
Re: Why isn't my slowdown working?

Quote:
Originally Posted by 414cnewq View Post
Well, there's another portion of my code affected by the slowdown (the tote pickup motor) that is affected by the slowdown:
outside TeleopPeriodic:
float motorpower;
inside:
if(stick->GetRawButton(10))
motorpower=0.4;
else
motorpower=1;
later in TeleopPeriodic(where vmc is a talon object):
vmc->Set(motorpower);
and that does not work.
any thoughts?
What I mean by it doesn't work is that the motor doesn't slow down. It keeps at the same speed.
Reply With Quote
  #7   Spotlight this post!  
Unread 17-03-2015, 21:52
JefferMC JefferMC is offline
Registered User
AKA: Jeff Corbett
FRC #1319 (Flash)
Team Role: Mentor
 
Join Date: Nov 2012
Rookie Year: 2005
Location: United States
Posts: 44
JefferMC will become famous soon enough
Re: Why isn't my slowdown working?

Are you sure you're pushing "Button #10"?
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


All times are GMT -5. The time now is 15:04.

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