Go to Post I can follow directions, but if it's not in the directions, I'm lost. - rclothier [more]
Home
Go Back   Chief Delphi > Technical > Control System
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 20-02-2007, 18:21
jkjohnson jkjohnson is offline
Registered User
AKA: jasmin johnson
FRC #1748 (Lab Rats)
Team Role: Programmer
 
Join Date: Feb 2007
Rookie Year: 2007
Location: Baltimore
Posts: 4
jkjohnson is an unknown quantity at this point
Inverting x-axis

When my team and I were testing the usb chicklet with the Logitech Dual action gamepad we experinced some difficulties with the x-axis of the left joystick. When attempting to turn the robot left it turned right, when attempting to turn right it turned left. We have tried re-calibrating it but it continued to give us the same reaction. Although it turns correctly with the KOP joystick we would really like the usb chicklet to work for us. We are not looking for advice on adjusting our program because we want the program to work with either the KOP joystick or the usb chicklet. If anyone knows any solution to this to problem we would greatly appreciate it.
Reply With Quote
  #2   Spotlight this post!  
Unread 20-02-2007, 18:36
lukevanoort lukevanoort is offline
in between teams
AKA: Luke Van Oort
no team
 
Join Date: Oct 2005
Rookie Year: 2005
Location: Waterloo, ON, Canada
Posts: 1,873
lukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond reputelukevanoort has a reputation beyond repute
Send a message via AIM to lukevanoort
Re: Inverting x-axis

You can flip the 'direction' of an analog input by using something like this (from our 2007 code)
Code:
DRIVE_LEFT = 254 - p1_y;
DRIVE_RIGHT = 254 - p2_y;
__________________
Team 1219: 2009 - Mentor
Team 587: 2005 - Animator, 2006-2008 - Team Captain
Reply With Quote
  #3   Spotlight this post!  
Unread 21-02-2007, 08:07
Mike Copioli's Avatar
Mike Copioli Mike Copioli is offline
You make it pretty We make it dance
no team (Retired(3539, 217))
Team Role: Engineer
 
Join Date: Jan 2006
Rookie Year: 2001
Location: Romeo
Posts: 453
Mike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond reputeMike Copioli has a reputation beyond repute
Exclamation Re: Inverting x-axis

Quote:
Originally Posted by jkjohnson View Post
When my team and I were testing the usb chicklet with the Logitech Dual action gamepad we experinced some difficulties with the x-axis of the left joystick. When attempting to turn the robot left it turned right, when attempting to turn right it turned left. We have tried re-calibrating it but it continued to give us the same reaction. Although it turns correctly with the KOP joystick we would really like the usb chicklet to work for us. We are not looking for advice on adjusting our program because we want the program to work with either the KOP joystick or the usb chicklet. If anyone knows any solution to this to problem we would greatly appreciate it.
By default you will have to change the mapping of the joysticks when transitioning from two joy drive to a gamepad. Since the gamepad uses one port and joysticks require two. So no matter what you will have to change your code. My suggestion is to use preprocessor defines to make the transition easy.

For example:


// set the condition to 1 for gamepad assignments
#if (1)
#define LEFT_DRIVE 254-p1_y
#define RIGHT_DRIVE 254-p1_x


// change the above condition to 0 to use joystick assignments
#else
#define LEFT_DRIVE p1_y
#define RIGHT_DRIVE p2_y

Or if you like, you could use a switch on the O/I to select from joy to gamepad. Preprocessor define will not work for this. You would use the same logic but during program flow.

#define LEFT_DRIVE pwm01
#define RIGHT_DRIVE pwm02

// if switch is true, use gamepad assignments
if(switch_x)
{
LEFT_DRIVE = 254-p1_y;
RIGHT_DRIVE = 254-p1_x;
}

// if switch is not true, use joystick assignments
else
{
LEFT_DRIVE = p1_y;
RIGHT_DRIVE = p2_y;
}
__________________
Mike Copioli
CTRE Hardware Engineer
http://www.ctr-electronics.com

Team 3539 The Byting Bull Dogs
2013 Michigan State Champions
Team 217 The Thunder Chickens
2006 World Champions
2008 World Champions
2009 Michigan State Champions
Reply With Quote
  #4   Spotlight this post!  
Unread 21-02-2007, 12:42
tdlrali tdlrali is offline
Registered User
FRC #0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Sep 2006
Rookie Year: 2006
Location: MI
Posts: 377
tdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud of
Re: Inverting x-axis

Please use 255, not 254.
If you use 254, and your joystick goes to max in one direction (255), you would get -1. Since the joystick input is an unsigned char, the value will "wrap around", making it 255 again.

If you were trying to go left, it would suddenly go full power to the right.

So:
Code:
inverted = 255 - normal;

Last edited by tdlrali : 21-02-2007 at 12:45.
Reply With Quote
  #5   Spotlight this post!  
Unread 21-02-2007, 14:20
gabrielse's Avatar
gabrielse gabrielse is offline
Registered User
FRC #1748 (Lab Rats)
Team Role: Teacher
 
Join Date: Jun 2005
Rookie Year: 2004
Location: Baltimore
Posts: 55
gabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to behold
Re: Inverting x-axis

We are using the Logitech Dual-Action gamepad. Our programmer calibrated it in mode 2 for one joystick drive.

We want to be able to use either the gamepad or a joystick without reprogramming.

Currently the USB-Chicklet inverts the output from the x-axis of the left stick on the gamepad. We want the gamepad to emulate the joystick. Changing the code on the robot controller or switching the wires attached to the speed controllers will not fix this.

Changing the code on the USB-Chicklet could fix it. Is there a jumper setting on the chicklet that will do this for us?
Reply With Quote
  #6   Spotlight this post!  
Unread 21-02-2007, 14:39
tdlrali tdlrali is offline
Registered User
FRC #0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Sep 2006
Rookie Year: 2006
Location: MI
Posts: 377
tdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud of
Re: Inverting x-axis

I have no experience with the chicklet, sorry.

However:
Check out http://www.ifirobotics.com/docs/usbc...ual-rev1-2.pdf, calibration might be able to fix this.

Otherwise, you will have to resort to the software solution. You could put a switch on the OI that will let you select joystick or gamepad mode.
Reply With Quote
  #7   Spotlight this post!  
Unread 21-02-2007, 20:41
gabrielse's Avatar
gabrielse gabrielse is offline
Registered User
FRC #1748 (Lab Rats)
Team Role: Teacher
 
Join Date: Jun 2005
Rookie Year: 2004
Location: Baltimore
Posts: 55
gabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to beholdgabrielse is a splendid one to behold
Re: Inverting x-axis

Calibration does not seem to fix the problem. Our programmer followed the user's guide and tried both mode 2 & 3 several times.

I do not understand why the Chicklet was not programmed so it's joysticks output matches standard/KOP joysticks.

Is this just a problem with the Logitech gamepad? Is there a way to change the code on our Chicklet?
Reply With Quote
  #8   Spotlight this post!  
Unread 21-02-2007, 21:46
tdlrali tdlrali is offline
Registered User
FRC #0469 (Las Guerrillas)
Team Role: Programmer
 
Join Date: Sep 2006
Rookie Year: 2006
Location: MI
Posts: 377
tdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud oftdlrali has much to be proud of
Re: Inverting x-axis

I bet CTRE tried to design it so it matches analog joysticks. However, not all controllers have the same design (inverted x or y axis).

I would contact CTRE (http://crosstheroadelectronics.com/contact.html) and ask them whether there is anything you can do. I doubt there is, however.
Reply With Quote
  #9   Spotlight this post!  
Unread 22-02-2007, 02:24
Stvn's Avatar
Stvn Stvn is offline
FIRST Competition Competer
AKA: Steven Rhodes
FRC #0100 (WHS/CHS - WildHats)
Team Role: Leadership
 
Join Date: Feb 2007
Rookie Year: 2004
Location: Woodside, CA
Posts: 90
Stvn is an unknown quantity at this point
Send a message via AIM to Stvn
Re: Inverting x-axis

You can always just have something built into the code that you can quickly change. For example, you can have something like:
Code:
#ifdef USB
    pwm1 = p1_Y;
#endif
#ifdef JOYSTICK
    pwm1 = 255 - p1_Y;
#endif
and define as needed.
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
Inverting Joysticks? The yellowdart Programming 5 20-02-2006 20:05
Dual-Axis Accelerometer naor52 Programming 18 27-01-2006 22:06
Reversing the joystick axis JBotAlan Programming 3 09-02-2005 19:47
Inverting Y axis on joystick FormatteD_C Programming 7 24-02-2004 16:56
switching joystick axis????? team222badbrad Technical Discussion 9 16-01-2002 23:07


All times are GMT -5. The time now is 20:22.

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