![]() |
Java CANJaguar PID Issues
We are trying to do position control with a CANJaguar and a potentiometer. If we enable the motor with PID control, and try to set the PIDs to 0.0, 0.0, 0.0, they don't change. A .getP() returns the last higher value etc.
More problematic, if we setup and enable the PID loop in init(), then select teleop or autonomous and enable then the motor will move. Always. If we do not enable the motor in init(), don't define it yet, but do so in teleop, then the motor does not move the first time. But if we disable, then reenable teleop the motor moves. Similarly if we then go to auto the motor moves. Since we want to enable and use the position control in auto, we run the risk of the motors moving when we go from auto to teleop. We have not found a method to disable the motor once initialized such that we may go into teleop or autonomous without the motor moving. Its as if enabling teleop or auto gives the motor an enable which starts it moving prior to the PID loop taking over. Disabling (.disable() ) the motor doesn't work as the motor moves when we enable. We have also tried .enable(initialPosition). Setting the PID values to 0.0, 0.0, 0.0, doesn't take. We print them out and they didn't change. No error generated. The CANJaguar appears to like our initial settings so much it won't let us overwrite them with zeros. Must think we don't know what we're doing. Any help or ideas would be appreciated. Thanks. |
Re: Java CANJaguar PID Issues
The PID constants being zero will make the motor never move. It will make the output to the motor = error * P + intergral(error) * I + derivative of error * D. If P,I, and D are zero, then the output will also be zero. Try P = .01 and I = .001 or something similar, and see of you get any output.
|
Re: Java CANJaguar PID Issues
Setting PID to 0.01, 0.001, 0.0 does not work. The motor moves when going into Teleop and into Autonomous.
Coming out of Teleop does not run code that we can find so trying to turn motors off while in teleop before teleop is disabled doesn't work. |
Re: Java CANJaguar PID Issues
It sounds like you're wanting to use position control only in autonomous mode, and use percent voltage mode for teleop. If this is correct, make sure that you set the control mode back to percent voltage after you disable position control. When you change back to position control mode, you'll have to reset the PID constants as well. Disabling the PID control of the Jaguar does not take it out of position control mode -- it only disables the output. That is, calling set() or setX() on the Jaguar will still be interpreted as a position command and not a percent voltage command.
At the start of autonomous: Code:
// Switch to Position control modeAt the beginning of teleop: Code:
// Switch to percent voltage mode.Hope this helps. |
Re: Java CANJaguar PID Issues
We would really rather stay in position control and not deal with velocity mode at all. However when we "enable" teleop mode the motors move. When we "enable" autonomous mode the motors move. It appears that the CANJaguars have a glitch such that once initialized during robotInit() as PID position control using a potentiometer; then when one goes to auto or tele mode they are instructed to start up, yet the PID loop is either not initialized or worse yet they start as velocity devices until further initialization is performed. Note we are not starting with a potentiometer position of zero as that is close to the dead zone. Rather we are starting with an input voltage near 0.145 V.
Even this isn't clear though as sometimes the motors move to a greater voltage direction and other times they move to a lower voltage direction. The main common theme is that the speed is the same. Its as if the starting position we give the CANJaguars during init becomes a speed when teleop or autonomous is enabled. Until the CANJaguar realizes that it was programmed as a position device and then it stops moving. Basically we have been unable to successfully program a CANJaguar as a position device prior to calling teleop or autonomous. For competition we decided to control the CANJaguar limit inputs using digital I/O such that we may disable the CANJaguars prior to calling Teleop and Autonomous. We have successfully performed this by hardwiring the inputs, however we have not successfully done this programatically. ie the motors still run. There may be a race condition between the motors running and the digital output disabling the CANJaguars by going high. Our contingency plan is that the hardware will run against a hard stop and crash into itself so it can't go backwards. Hopefully the forward motion won't kill us while crashing backwards into hardware for a short period doesn't burn out the motors or put the potentiometers passed their zero voltage output. (Once the pots go less than zero they read as greater than 0.90 volts and then a position command runs backwards through more hardware to get to the 0.145 volt starting position. Not.) There must be a reason that a CANJaguar that is programmed for position control with PID inputs of -1400, 500, 0, start to run a motor whenever teleop or autonomous is enabled from the driver station. The pots are not slipping. They are Cherry AN8 360º encoders monitoring a magnetic pickup screwed into a shaft. Repeated moves to two voltage positions (0.145 and 0.5 V) replicate fabulously over and over many times regardless of enabling and disabling. And yet enabling teleop causes the motor to move. Our starting position is 0.145 V. We .disable() the CANJaguar, set the mode to PID position mode, set PID to -1400, 500, 0; set the potentiometer to a 1 turn pot, set the position to 0.145 using .set( 0.145). We don't enable until we get to Teleop. When teleop is called the motors move a while at a slow speed in a random direction then stop. Eventually after enabling the CANJaguars in Teleop and commanding them to 0.145 they go to 0.145 where a .get() returns 0.145. |
| All times are GMT -5. The time now is 08:31 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi