Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A question about your swerve auto #18

Open
mendax1234 opened this issue Oct 4, 2021 · 4 comments
Open

A question about your swerve auto #18

mendax1234 opened this issue Oct 4, 2021 · 4 comments

Comments

@mendax1234
Copy link

You use a holonomicDriveController in the auto. How do you draw a trajectory, is there any method to draw it? And how do you tune your 3 PIDcontroller's paramater?

Any help is appreciated.

@MarkGhebrial
Copy link
Member

Hi,

Are you talking about our 2021 robot? This repository is for our 2020 robot, which uses a tank drive. Swerve drive and mecanum robots use a holonomicDriveController for trajectory following, and tank drive robots use a RAMSETE controller.

We use WPILib's PathWeaver tool to draw trajectories. It's a really easy way to draw spline curve trajectories for autonomous routines, if you write the correct code.

As for tuning the PID gains for the holonomic controller, it's just like tuning any other PID controller. The first and second PID controllers for the holonomicDriveController constructor are used for getting the robot to the correct position on the field. To follow a trajectory, you must know where your robot is on the field. What the trajectory tells your code is where the robot needs to be at a given time. The holonomic or RAMSETE controller is responsible for getting the robot to that location.

Suppose that you tell the holonomic controller to move your robot to (2m, 4m) and your robot is at (0m, 0m). The first PID controller that you give the holonomic controller is used to get the robot to the x value, and the second is for y. What the holonomic controller does is set the target of the first controller to 2m. The output of that controller is sent to the resulting chassis speeds object, which you use to set the velocities of the robot.

I assume that you are using a swerve drive. If that's the case, then the PID gains should be the same for the first two controllers. The third, profiled, PID controller is used for setting the heading of the robot.

I hope this helps!

@mendax1234
Copy link
Author

Are you talking about our 2021 robot?

Yes, l am sorry to open the issue at a wrong place.

I assume that you are using a swerve drive

Yes, l use a swerve drive.

We use WPILib's PathWeaver tool to draw trajectories. It's a really easy way to draw spline curve trajectories for autonomous routines, if you write the correct code.

But , does it mean that l need to draw the trajectory as l want? For example , if l want to draw a bounce path. l should draw like below?
image

If l draw like above, how can l control my swerve's heading? Besides, l use the SwerveControllerCommand, is it different from the holonomicController?

As for tuning the PID gains for the holonomic controller, it's just like tuning any other PID controller.

The docs.wpilib says that l can tune the PID gains with robot characterization tool. But is there any other method to tune it? And if l use a swerve drive , it seems that need to characterize two parts in the characterization tool. The turning part and the driving part. How should l tune each of them? And after tuning , how to set the PID gains of the first two controllers. At last , how can l tune thte ProfiledPIDController?

Any help is appreciated!

@MarkGhebrial
Copy link
Member

But , does it mean that l need to draw the trajectory as l want? For example , if l want to draw a bounce path. l should draw like below?

Yeah, that's how you do it.

If l draw like above, how can l control my swerve's heading?

The PathWeaver tool is designed for normal tank drive robots, so it automatically points your robot's heading in its direction of travel, which should be ok for most autos.

l use the SwerveControllerCommand, is it different from the holonomicController?

Yes, the SwerveControllerCommand uses the holonomic controller. You can browse its source here

The docs.wpilib says that l can tune the PID gains with robot characterization tool.

Really? I thought that was only for tank drive robots. Could you share that page?

But is there any other method to tune it?

Yeah, you can tune it by hand, which is what I did.

And if l use a swerve drive , it seems that need to characterize two parts in the characterization tool. The turning part and the driving part. How should l tune each of them?

The same way you'd tune any PID controller.

And after tuning , how to set the PID gains of the first two controllers.

Change the gains in your code.

how can l tune thte ProfiledPIDController?

Honestly, I'm not entirely sure, but here's the documentation for it.

@mendax1234
Copy link
Author

Yeah, that's how you do it.

But it seems that my swerve can't drive the path smoothly and l can't control its heading. l wonder whether should l seperate the path into several trajectories. However , how many path should l seperate? And what does the blue straight line in the picture mean? Does it mean the head of my robot?

I thought that was only for tank drive robots.

Maybe you are right.

Yeah, you can tune it by hand, which is what I did.

How can l tune it by hand . Since the PIDController of ProfiledController is only used in the auto , so how can l tune it by hand? Can l tune it in the Phoneix tuner?

Any answer is appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants