Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   Errors with Our Joystick (http://www.chiefdelphi.com/forums/showthread.php?t=102221)

3rik 02-07-2012 09:17 PM

Errors with Our Joystick
 
For the past couple days our team has tried unsuccessfully at using our joystick in the way we would like to use it. All our experienced programmers left last year and our new programmers, myself included, are new to C++.

Our current issue is when we run our code on our robot, it doesn't respond.
The driver station returns this error:
Quote:

ERROR: Joystick axis is out of range: ...in GetStickAxis() in C:/WindRiver/workspace/WPILib/DriverStation.cpp at line 226
The file it references is DriverStaion.cpp. It seems like it's saying that we are trying to access too many axes.

Here is the code we were using to test the joystick. Our team is using mecanum wheels and joystick with a twist axis.
Code:

#include "WPILib.h"

class RobotDemo : public SimpleRobot
{
        RobotDrive myRobot;
        Joystick stick;

public:
        RobotDemo(void):
                myRobot(1, 2, 3, 4),
                stick(1, 3, 0)
        {
                myRobot.SetExpiration(0.1);
        }

        void Autonomous(void)
        {
        }

        void OperatorControl(void)
        {
                myRobot.SetSafetyEnabled(true);
                while (IsOperatorControl())
                {
                        myRobot.HolonomicDrive(stick.GetMagnitude(), stick.GetDirectionDegrees(), stick.GetTwist());
                        Wait(0.005);
                }
        }
};
START_ROBOT_CLASS(RobotDemo);


This appears with two different types of joysticks: the Logitech Extreme 3D Pro, which is the joystick we want to use, and the Logitech Attack 3.

This problem only seems to be an issue when we use commands that call GetStickAxis(). Other commands like GetRawStickAxis() seem to work fine.

If anyone can point us in the right direction, it would be much appreciated.

Halo_Kid_3633 03-23-2013 01:17 PM

Re: Errors with Our Joystick
 
Did you figure it out.

RufflesRidge 03-23-2013 01:25 PM

Re: Errors with Our Joystick
 
In case anyone else stumbles across this thread in the future, the issue is that the Joystick initializer "stick (1, 3, 0) is specifying that the joystick has 3 axes. Then stick.GetTwist() is being called, which is axis 4.

The fix should be either changing the initializer to "stick (1, 4, 0)" or just "stick(1)"


All times are GMT -5. The time now is 10:29 AM.

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