Compiling erorrs

How do I fix these errors?

Scroll up in the error log please.

You have variables with the same names. Variables need to have unique names. Specifically you have 2 variables named left motor and 2 variables named right motor.

1 Like

I need to know how to make two Left motors and two right motors.

You can create a differential drive object with multiple motors per side by using a SpeedControllerGroup like this:

  frc::PWMVictorSPX m_frontLeft{1};
  frc::PWMVictorSPX m_rearLeft{2};
  frc::SpeedControllerGroup m_left{m_frontLeft, m_rearLeft};

  frc::PWMVictorSPX m_frontRight{3};
  frc::PWMVictorSPX m_rearRight{4};
  frc::SpeedControllerGroup m_right{m_frontRight, m_rearRight};

  frc::DifferentialDrive m_robotDrive{m_left, m_right};

This is the code I’m using and it won’t drive. Is there something else I need? I also need to know how to add two left and right motors.

You’re going to need to include some descriptions of your set-up, what you’ve tried, etc.

Make sure that your motors are plugged into the correct ports.
Check that your joystick is in the right position on the USB section of the driver station.
Are you connected to the robot?

One thing that I like to do is print to the console or smart dashboard. Printing the values of what the joystick is getting can be helpful.

Ok, we are actually using CAN. How would I make that work?

Replace the PWMVictorSPX with the SpeedController object that corresponds to your speed controllers on the robot.

Ok what would the code look like?

If you’re using a CTRE product, you’ll need to install Phoenix from CTRE -> http://www.ctr-electronics.com/talon-srx.html#product_tabs_technical_resources

If you’re using the nidec speed controller, look here -> https://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/wpilibj/NidecBrushless.html

1 Like

We already have the Phoenix library installed. What would the code look like for it since we’re using CAN instead of PWM?

Lots of examples here:

2 Likes