If (position) Statement Help Needed

Continuing the discussion from Coding Positioning Help:

Didn’t get any responses for help. My team has state coming up and could really use the assistance. Thanks!

I guarantee you that it has something to do with the fact that the code starts to that that instantaneously, and then defaults to the controller code, which probably is set to not move the tray at all. Without stepping into territory of tasks that I’m not that familiar with, I would do something along the lines of

(as part of your variables at the start of the program)
bool checkpoint = true;

if(RightTower.position(degrees) <= -100)
checkpoint = false;

if(abs((FourBarMotor.position) + 120)<5) //so, if your motor is within range of your desired position, set the flag to true to allow the controller to pivot the tray
checkpoint = true;

(skip forward to your joystick code)

{//this is where you put the logic for controlling your tray

Note, that this is completely mocked-up code made off the top of my head, so treat this more like pseudocode than something you can copy and paste. Also, this might not be the most efficient code, and there could be problems with this approach (one of which I can think of off the top of my head is that you might need to code a button to override and allow manual control), but that is up to you to figure out.


Thank you so much for the timely response, this will help us greatly!