Code

So I have this question.

m_axisMotor.Set(m_stick.GetRawAxis(4));

if m_axisMotor is a pointer to the motor and m_stick is a pointer to the joystick. Isn’t this suppose to get the Y position of the right button of the Joystick and setting the motor to have that value?

This is really really impotent.

In C++, if the two are pointers, it should be m_axisMotor->Set(m_stick->GetRawAxis(4));. Which axis this maps to on the physical joystick depends on the joystick.

Like Peter said, if they both are pointers then you should replace the . (dots) with ->
Other than that, the code should work fine, except I believe axis 4 is the X position of the right analog stick. If 4 does not work, then try 3 or 5. To know for sure you can just the joystick tab of the driver station.

According to the docs I have, for an xbox-style controller 4 is the X axis (side-to-side) and 5 is the Y axis (forward-and-back). Also, all the xbox-style controllers we’ve worked with send a -1 when pushed all the way forward and a +1 when pulled all the way back.

thanks everyone for the help.

and also just one more thing. Can anyone give an example of using the PWMSpeedController to control the other speed controller that we bought separately.

Don’t use PWMSpeedController directly. You should use one of the concrete classes, e.g. Victor, Talon, etc. e.g.

frc::Victor* m3 = new frc::Victor(3);
...
m3->Set(0.25);

Did you mean m3->set?

Yep, sorry, fixed.

ok so this would be the last question I hope.

So I don’t know but for some reason it’s saying that the raw axis could not be found I tried doing both 4 and 5 to get the raw axis but it is not working is there a specific way that it is suppose to be. because the GetX and GetY works but not the GetRawAxis();

In need of urgent urgent help.

Is this at run time or compile time? Can you post the exact error message?

  • Joystick Axis missing, check if all controllers are plugged in

  • Joystick Axis missing, check if all controllers are plugged in

  • Default DisabledInit() method… Overload me!

so it is giving this error but the joystick is plugged in. So i don’t know what is happening.

Do you have multiple joysticks plugged in to the driver station? What does the joysticks tab in the DS show? It could be that you are trying to access an axis on the wrong joysticks because the IDs are wrong.

no It was the only joystick. But it’s OK I couldn’t get the value that I would have Ideally wanted but I used GetZ which is kinda the same value it just instead of the Y it is giving the x value. but finding out what the problem is will definitely help with next year.

Great, glad you solved it.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.