How to program a macanum drive?

Hello, I am new to java and I need to get code for a mecanum drive ASAP. My team needs it and our programmer is not able to help us. I need to finish these soon and I can’t seem to figure it out myself yet. Would someone be willing to program me a mecanum drive based on these requirements?

Requirements

Command-Based, Java

These are the controls

public static XboxController driver = new XboxController(0);

  // ----------- CONTROLS -----------

  // Left Stick
  private final int swerveAxisX = XboxController.Axis.kLeftX.value;
  // private final int swerveAxisY = XboxController.Axis.kLeftY.value;

  // Right Stick
  private final int turnAxis = XboxController.Axis.kRightX.value;

  // Triggers
  private final int leftTrigger = XboxController.Axis.kLeftTrigger.value;
  private final int rightTrigger = XboxController.Axis.kRightTrigger.value;

Uses these motors as the mecanum motors.

frontLeft = new Talon(0);
rearLeft = new Talon(1);
frontRight = new Talon(2);
rearRight = new Talon(3);

Please make sure it is mecanum based and uses those before you send me the code. I am new to java programming and I need to finish our robot sense our programmer is leaving soon. I also need a Tank Drive if someone wants to help program one of those for me too. The requirements are basically the same, but the controls are different, and it is a Tank Drive. Note: This means the Motors can be grouped.

Thanks everyone for the help

I highly doubt youre going to get anyone here to just create you a full working project.

The good news is that there are example projects that will get you 90% of the way there! allwpilib/wpilibjExamples/src/main/java/edu/wpi/first/wpilibj/examples at main · wpilibsuite/allwpilib · GitHub

8 Likes

Have you looked at Using the WPILib Classes to Drive your Robot — FIRST Robotics Competition documentation

2 Likes

Please speak with others on the form in a more polite manner. We’re people here who volunteer our time to help and discuss topics in a civil manner.

Your original post reads like an AI prompt, does not make me feel good reading it. I get you are frustrated, and things may be over your head, however a lot of the resources linked are meant to build up from zero. Specific questions in the form of “I read X and Y, I didn’t understand a and b, here is what I tried and here is the weird result I got” will get you better help.

Please and thank you get you a long way in life.

11 Likes

You’re getting :-1: reactions because that’s the wrong attitude to take. Regardless of reality, it gives the impression that you’re unwilling to even try.

A much better approach would be to read through the documentation and example projects that have already been linked above, and try to implement it. If you get stuck or come across something you dont understand, then you can absolutely ask for help, but ask direct questions about the parts that are stumping you, not a generic “do it for me” comment.

7 Likes

The point of this program is to learn. There’s a difference between using libraries and example code to fill in knowledge gaps (good) and demanding that someone else writes code for you because you need the code to work and you don’t know how to make it work (bad). There are a ton of awesome community members who will bend over backward to help you get your code working - keywords help and your code.

4 Likes

Hey there, my team did a mecanum in 2023, here is our github if it would help you as an example and kind of give you an idea of what direction you want to go in. If you have any questions feel free to ask.
P.S this code was the second time I coded for an frc bot so the code isnt as optimized and may be sloppy in some parts but yeah.
If you need help feel free to ask, it just may take me a little while to respond since 5ap classes and 3 dual enrollment classes take up most of my time and I have to grind that before build season.
Thanks

dude mightve actually gotten a full project if he sent this post to a LLM instead

5 Likes

Seems like you’re in a rush. Why are you trying to do this so quickly instead of methodically learning it yourself? I’d the team placing unfair pressure on you?

Seems as though you’re panicking and just need a little help.

I, nor anyone else is likely to supply you with raw code for you to paste in.

However I think I speak for most of us when I say we are more than willing to work with you.

I have to rush it sense our programmer is leaving and he can’t help us. We have a competition pretty soon and they need me to have it ready.

Funny thing is I tried that and everything is outdated like 5 years. :frowning:

Sorry for not being polite, I apologize. I am just trying my best to get the robot working. I have tried doing many things and I just don’t know what to do. Sorry if it sounds like an AI prompt, I am not really sure what you mean when you said it reads like an AI prompt, but I am trying my best to get this ready for my team.

Hope I clarified and didn’t sound rude,
Best Wishes

3 Likes

Thank you so much, this is really useful.
I will do my best to write the code using this.

Hope you had a wonderful day!