I am trying to program a test chassi for mecanum but currently running into the edu.wpi.first.wpilibj.MotorSafety.check(MotorSafety.java:139): error
this is my code
Not directly related to your reported problem, but one thing I notice is that when you create the Drive
command in RobotContainer.RobotContainer()
, you are passing in integer axis channel numbers that you are then treating as doubles to be passed to MechanumDrive.driveCartesian
.
You probably want to switch to using DoubleSupplier
s here. See this example code and also this article.
Also, you’re probably going to decide you want field-oriented control, which means you should be using the four-parameter version of driveCartesian
, except I don’t see a gyro in your code.
I’m not sure what’s causing your MotorSafety
problem. This problem is caused by not calling feed
often enough.
In your code, feed
is called by MecanumDrive.driveCartesian()
, which you are calling in Drive_sub.drive()
, called from Drive.execute()
, which is set as the default command.
When I see this issue, it’s usually because there is another command running that isn’t using the same interface, or sometimes because some method in the main event loop is taking too much time. I don’t see that this should be the case in your code.
Can you show us a screenshot of your error message, with as much context as possible?
Aha! I see the problem. You’re not creating RobotContainer
in Robot.robotInit()
. Also, you should not have the m_DriveSub
be a static
member in RobotContainer()
.
Thank you, I will try to implement these things next time I get my hands on the robot.
One question though: how would you make it robot oriented?
You already have robot-oriented with the three-parameter version of driveCartesian
. The common wisdom is that most drivers prefer field-oriented, but if you have no gyro, then there’s not much you can do.
Do you just put the gyro on the 4 parameter, and can I use the built in gyro in the robo rio
Yes (using m_gyro.getRotation2d()
), but no because:
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.