The problem of driving a FRC robot with Falcon 500

My question is how to code to drive a robot with basic program.
Another question is how can the robot turn right or left

1 Like

A great resource for starting to code is the wpilib documentation. They will give you tons of information on the in’s and out’s of coding. For more specific cases with Falcon 500 motors, you will want to check CTRE’s documentation located under API Docs link on this page. Finally, the Compass Alliance Pathways page provides an excellent roadmap of programming goals.
If you have more specific questions, feel free to follow up with those questions!


Thank you very much ! And l also have another question ,that’s can l use the CTRE’s example program directly on my robot and will the robot be able to be driven normally?

You would have to be more specific about which example and the current configuration of your robot. For example, the Differential Drive example assumes the use of only 4 motors in the drivetrain, so if you have 6 you will have to adjust the coding.

After that, you will have to adjust the motor id’s to match the id of your Falcons. You can do this with the Phoenix tuner.

Depending on your drivetrain, you may need to invert the motors (in code) to make sure the drive runs in the correct direction.

The above assumes you have followed the WPILIB tutorial for setting up your robot (docs linked in my above post). You also will need a robot project with your team’s number associated with it. I don’t believe you can just pull the github repo from CTRE and deploy.

So, I just need to copy the Differential Drive example to my own project (I have 4 motors) and correct the id and then deploy it to my robot. Then , my robot will be driven normally? Is my idea right ?

In theory yes, I’d everything else got set up correctly. If you run into problems, spend some time trying to trouble shoot them yourself, and if you still can’t get it, just ask.
Its beneficial if you can post your code as well, it helps the community trouble shoot more effectively.


Thank you very much ! I will try it tomorrow!

Hello , my robot can be driven successfully , but the speed is too fast if I push the joystick to the max , and l don’t want to set another speed to control it and is there any solution to it?

Change the gearing of the robot drive, or else modify the robot code to cap the speed somewhere below the max (e.g. by multiplying the joystick value by some constant between 0 and 1).

I recommend the former fix rather than the latter.

How can l change the gearing of my Robot ? And how to modify the speed below the max? And is the max speed 1.0?

Changing the gearing of the robot requires a mechanical change to how the robot is built; you’ll have to consult with your mechanical team.

Capping the speed in code is easy, and can be done in a number of ways, but will always boil down to “making the commanded speed smaller.” Multiplying your commanded speed by a constant between 0 and 1 will reduce it.

Whether the max speed is “1.0” in code depends specifically on your code - if you call the set function on a WPILib SpeedController, then yes, the max output will be 1.0 (or -1.0, depending on direction), but if you call setVoltage then it’s either 12.0 or -12.0.

Ok and l will try it soon

Looks like @Oblarg beat me to it. I’ll try to fill in with other things.

The max speed is -1.0 to 1.0, where sign is the direction of the motor.

Conviently, most joysticks are set to output a range of -1.0 to 1.0, so we can directly plug in the joystick value to the drivetrain power.

If you multiple the joystick value by a range of 0.0 to 1.0, you cap your top power. So if you multiple by 0.5, the max power you can set your robot to is 0.5. Unfortunately, this also means your drivetrain only operates at 50% max power (approximately).
Also, know that your robot has to overcome static frictionwhen it starts to move, so by capping the max power by a scalar, this make that dead range higher on the joystick. I.e. if you robot can’t move until at least 0.2 power is provided, then by multiple your joystick by 0.5, you increase the deadband by 4 times on your joystick.

If you change your gearing, you can still run full power by going a slower speed.

Power approximately equals speed. More advanced physics says this is otherwise, but for now you can think of them as almost equivalent. Just know they aren’t actually.

1 Like

But l use the arcadedrive and does this method fit it ?

Yep, it would work.

Ok , that’s really cool

Hi, l have a problem again. It’s still about how to set the max speed. This time I want to ask whether there is an method to set the max speed directly. And l still want to ask whether there is a method to set the “a” and how to use it

When you say “set the a”, do you mean acceleration?


And does the method “.configOpenloopRamp” really work on TalonFX and what’s the most moderate value that l should use.