![]() |
Acceleration Curve java help
Hey does anyone know how to program an acceleration curve for cim motors??
|
Re: Acceleration Curve java help
What are you trying to accomplish?
If you really want to control/limit acceleration, you can set up a PIDController using the motor speed(s) as the system input and the acceleration (from the RoboRIO's built-in accelerometer, for example) as the system output. |
Re: Acceleration Curve java help
Quote:
If you are simply wanting to prevent driver "jackrabbit" starts and stops so the totes won't fall off the stack you are carrying, a simple solution would be to add a slew rate limiter to your joystick commands. |
Re: Acceleration Curve java help
I'm assuming you want something like this.
Code:
double magnitude = Math.pow(2,(driveStick.getMagnitude())-1; It is an exponential function that increases the speed of the robot when reaching the upper bounds. You can just edit this so that it works with your drive and controls. Or, if you post the code I will do it for you. |
Re: Acceleration Curve java help
Quote:
You might also caution that your suggestion maps the domain -1..+1 to the range 0.769..1.3 |
Re: Acceleration Curve java help
Quote:
Code:
Joystick stick1, stick2; |
Re: Acceleration Curve java help
We are trying to fix the automatic jump the robot gets as soon as you move the joysticks.
|
Re: Acceleration Curve java help
Can you show us your code right now? Otherwise, tell me the type of drive you are using.
Tank Drive: Code:
Joystick stick1, stick2;Code:
double magnitude = Math.pow(driveStick.getMagnitude(),3); |
Re: Acceleration Curve java help
Quote:
Quote:
|
Re: Acceleration Curve java help
This is our regular code
package org.usfirst.frc.team4640.robot; import edu.wpi.first.wpilibj.CameraServer; import edu.wpi.first.wpilibj.SampleRobot; import edu.wpi.first.wpilibj.RobotDrive; import edu.wpi.first.wpilibj.Joystick; import edu.wpi.first.wpilibj.Timer; public class Robot extends SampleRobot { RobotDrive myRobot; // class that handles basic drive operations Joystick leftStick; // set to ID 1 in DriverStation Joystick rightStick; // set to ID 2 in DriverStation CameraServer server; public Robot() { myRobot = new RobotDrive(0, 1); myRobot.setExpiration(0.1); leftStick = new Joystick(0); rightStick = new Joystick(1); server = CameraServer.getInstance(); server.setQuality(50); //the camera name (ex "cam0") can be found through the roborio web interface server.startAutomaticCapture("cam0"); } /** * Runs the motors with tank steering. */ public void operatorControl() { myRobot.setSafetyEnabled(true); while (isOperatorControl() && isEnabled()) { myRobot.tankDrive(leftStick, rightStick); Timer.delay(0.005); // wait for a motor update time } } } |
Re: Acceleration Curve java help
Code:
|
Re: Acceleration Curve java help
For those trying to learn from this thread, the non-whitespace differences between the intitial (21:04) and updated (21:27) code are:
Code:
# diff -w initial.txt updated.txt |
Re: Acceleration Curve java help
How about using Talon.setVoltageRampRate()? The only downside is it would also slow down deceleration, and I think it only works on CANTalons.
|
Re: Acceleration Curve java help
I wanted Can Motor controllers but we ended up using regular one. I was going to use the setVoltageRampRate function, because we are top heavy, but I had to create something else. The acceleration curve by Math.pow(val, x) wasn't good enough for us, where x is an int. Why? because if the joystick slips, we don't want the robot to rapidly accelerate. So, what I do is that I read the "ReachVal" from the joystick, then, read the "CurrentVal" from what I set to the CIMs (CurrentVal is initialized to 0). Then, I take the difference, divide that by 7500 (trial and error lead me to this constant), add that to "CurrentVal", in my drive thread. This results in a smooth drive and we don't topple over even though we are quite top heavy.
Hope that helps! |
Re: Acceleration Curve java help
Quote:
Quote:
Quote:
Code:
Quote:
|
| All times are GMT -5. The time now is 11:23. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi