My team has decided that we want to use Speed PID because they think it will be better for fine tuning on the bridge. However, the only problem I see with it is that we have to use Arcade Drive because our driver prefers it over anything else. We use the CAN Speed settings on our jaguars to indicate our velocity and we are wondering if we can use RobotDrive with the Speed PID. Note we are also using Master/ Slave mode. Do we have to come up with our own algorithm to do Arcade Drive in master slave mode or can we just use some of the Robot Drive functions given to us?
From my experience, it will be most effective in the long run to completely create your own form of the drive code, it can still take in the inputs from the joysticks as Arcade Drive does, however you can take the values and figure out a PID setpoint and run the PID algorithm to calculate your motor speeds.
Joystick->PID->SpeedController
If you need any help with any of this I am very experienced with writing custom drive codes for robots, feel free to send me a message if you need help…
By Speed PID, do you mean using the CAN Jaguar kSpeed control mode? If so, you should be able to use RobotDrive::ArcadeDrive with speed control mode. According to the code, you should be able to call RobotDrive::SetMaxOutput to set the maximum speed of your robot and then just feed RobotDrive::ArcadeDrive with your joystick values that’s in the range of -1.0 to 1.0, the SetLeftRightMotorOutputs() code in RobotDrive will scale your -1.0 to 1.0 range to your -maxOutput to maxOutput range which is your speed range.
If no rotation is being commanded and the vehicle is traveling in a straight line, you could do that.
Otherwise, it wouldn’t work very well.
The input commands to an arcade algorithm are vehicle forward speed and vehicle rotational speed.
The arcade algorithm performs a reverse kinematic calculation on those commands to determine the necessary left and right wheel speeds to give the commanded vehicle motion.
The signals from the 2 wheel encoders are left and right wheel speed.
In order to obtain a usable process variable to do what you have suggested, you would have to reverse-engineer the PID’s reverse kinematic calculation to obtain a forward kinematic calculation, which you would then apply to the encoder signals to obtain estimated vehicle forward speed which could be used as a process variable.
It would probably be a lot easier and cleaner to just write your own arcade code, and close the loop on left and right wheel speeds directly.