Sequential command help

We are checking to see if we are finished with one command, and then once we finish we want to run it again. We are getting an illegal modifer while using the .andThen() function, stumped. Any help is appreciated.

Post your code to github or somewhere so we can see it and help.

If you scheduled the command as the last thing you did in end() of that command you would start an infinite loop right? I’m trying to do the same thing.

No, because the command is removed after end() is called. It’ll just be ignored, as the command is already scheduled.

You could do a ConditionalCommand where the condition is whether or not the first command was successful.

If you don’t want it to end, why not make it a PerpetualCommand?

1 Like

turn to angle and auto angle.

That sounds like what we were trying to do but it is always successful in code, not the real world so we need to run TurnToAngle twice

I do

So do you really just want to turn to an angle based on the Camera?

Why does this need to be run, and then scheduled again when it ends? I’m not following the requirement of the sequence here, unless the PID turning is not working or something.

No, we don’t. We want to get an angle that we first see and use that as a set point for our gyro. The problem is we are consistently over shooting our actual target, even though our reported error from the gyro PID is .2. When we run the command again it updates the setpoint for the gyro with the error from the camera, lets say 4, and then it finally hits our real life setpoint accurately. the thing is, though, we don’t want to hit the button twice as that takes time and might interfere with some sequential command ideas we have later down the road.

Does that mean if your setpoint is 90 degrees your gyro reports you’ve turned 90.2 degrees (according to the Gyro) but in actuality the turn was much further?

Are you sure you’re not just under-dampened in your PID loop, and your not allowing enough time for the oscillation to be visible?

No, when we are at 20 degrees yaw our gyro says it needs to turn 20 degrees, as it should. The thing is the 20 degrees the gyro turns is different from the 20 degrees the camera reports.

How does your gyro tell you it needs to turn 20 degrees? Can you clarify?

Sounds to me like your main problem is that the logic you use in the camera is not reporting the actual angle properly, assuming of course that your Gyro is calibrated and accurate.

I suspect your gyro latency may be high, which causes the pid controller to use older value.
Which gyro are you using and how is it connected to roborio?

I doubt that. We have a setpoint that doesn’t change which is the purpose of our command frame work.

I think the issue is that AutoAngleCommand and TurnToAngleCommand both require the driveSubsystem While one is using it, the other can’t.

Then in end(), turnToAngle is cancelled, just when it has a chance of being scheduled.

At least that’s my instant analysis .

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.