Need Help programming OTB intake set positions

Hello, I am trying to program an OTB intake to have certain set positions such as zero, amp, ground etc. However, I am struggling to do so with the new phoenix6 and am not sure how to do it. My code is here. It currently does not work. Also I have a few question regarding motor configurations. Are brake and coast mode now set in tuner x? And what about current limits? Thanks!

Can you describe what your issue is? What specifically is going wrong with the commands?

  • Is nothing happening?
  • Is the intake not stopping at the correct location?
  • Is it moving in the wrong direction?

Answering this, or even taking a video, would allow us to better help you. From a quick glance at your code, I’m not seeing where you are using the commands that you’ve defined.

It looks like your trying to control phoenix 6 devices with the old phoenix 5 library. this doesn’t look like it should even compile. check here for a guide to the new configuration and control mode api.

here is also a quick example for controlling motors in the new phoenix 6:

Create a control request object. there are different types of control requests for all the different ways to drive your motor such as DutyCycleOut and PositionDutyCycle.

final DutyCycleOut motorRequest = new DutyCycleOut(0.0);

To make move the motor it would look like this:

yourMotor.setControl(motorRequest.withOutput(0.5));

This will run your motor at 50% power

They have a nice migration guide in the CTRE docs that will help you make the transition to Phoenix 6.

Specifically, if you want to continue to use Position control, you need this set of documentation.

Lastly, as already said, currently your code doesn’t instantiate the subsystem, or bind the commands to triggers, so it can’t work.

1 Like

I have worked on the code a bit and am struggling with setting up the configurations. I am not sure what I am doing wrong. I also want to know how to be able to control the pivot speed. Can someone please take a look. I know that I have not instantiated the subsystem, or binded the commands to triggers. I was planning to do that after writing the intake subsystem. Thanks!

I am trying to program on OTB intake that is the same as Cranberry Alarm’s except that we are using falcon motors and no encoder. However I seem to be having trouble setting up the configurations properly for the TalonFX. Can someone please take a look? Right now it does not compile properly. I have not instantiated the subsystem, or binded the commands to triggers. I was planning to do that after writing the intake subsystem. Thanks!

Some advice on how to ask a question:

Post the things that are going wrong, what you have tried, and what were the results.

For example, you said it doesn’t compile. What is your compilation error? The fix is probably identifiable just in the message alone. People are happy to help, but you have to make it easy for them to help you rather than force them to go digging for the problem.

3 Likes

Is this still the same issue as in the other thread or a new issue?

They seem to be pretty similar threads and starting another thread about the same thing is going to split where people are answering

1 Like

Falcon’s have an integrated encoder, which will allow for relative positioning. It wouldn’t “remember” its starting location, but it still can move relative to it.

1 Like

I finished programming the intake here. Can someone please take a quick look to make sure there is nothing that stands out that might break the robot when I test it? This is my first year programming lol. Thanks!

We tested the code today. There is an issue where when we enable the intake motors start spinning. Also none of the buttons work… We have tried to isolate the error by commenting out things but still can’t figure it out. When we comment out all the button bindings the motors stop spinning upon enable. Can someone help me please?

Welcome to FRC programming! Take a look at motion magic here, which is an easy-to-use closed-loop position control method. I got position control working relatively easily on our OTB intake with motion magic + our own PID value calculator that I can link here if needed.

Couple of things that stand out to me when I looked at your code:

  • You’re trying to use angles as set points. I’m not too sure how well that would work, but I’d just keep it motor rotations, which is what is used by the v6 API for positions
  • You have a state machine that seems to be complicating things – while I’m a big fan of state machines, I only ever implement them later in the programming process because issues are difficult to troubleshoot
  • You’re using a WPILib PID controller, and then feeding the voltage that it outputs to the motor. I’d get rid of this logic and instead use the motor.setControl() method in the v6 API with motion magic as seen in the docs linked above.

Hope you get the intake working!

Hi, is it possible you can link your code and the PID calculator so I can take a look? Thank you so much!