Lack of pneumatic functions

So, my team recently got pneumatics, and we are usin them on the robot. So far, I have no complaints except for one thing: the lack of functions in the pneumatics class. For example, there is no way to tell if a cylinser is extended or retracted, even though the solonoid has a light for it. Is there something I am missing, or is there really no function to check the extended/retracted state for a cylinder? If there is none, why isn’t there?

Because a sensor to tell you that would mean running BOTH a wire and tubing to the cylinder.

Just track it in your code.

if needs_to_extend {
    cylinder.extend();
    extended = true;
}
if needs_to_retract {
   cylinder.retract();
   extended = false;
}

status will give you information about what the solenoid thinks is happening. play with that function, should be easy to figure out what the returned value means.

I tried this, and somehow the cylinder got de-synched with the controller. I am also using a touchLED for driver feedback, so having those two synched together is important. I am also using a bumper sensor to automatically retract the cylinder when pressed. I’m not sure if the de-synching is a logic issue (it probably is) I just a confused on how to check if the cylinder is extended or retracted.

Code
           if launchingBumper.pressing(): bumperPressing = True
            else: bumperPressing = False

            if bumperActivated and not bumperPressing:
               pneumatic.extend(CYLINDER1)
               bumperActivated = False
               count1 += 1
               tLED.set_color(Color.RED)

            if controller.buttonEUp.pressing() and count1 % 2 == 0 and not controller_e_Up_button_held:
                # Extends the cylinder only if the E_Up button is pressed, count1 is even, and the button is not already held.
                pneumatic.extend(CYLINDER1) # Extends the cylinder
                count1 += 1 # Increases the count by one
                controller_e_Up_button_held = True # lets me know that the button is held
                tLED.set_color(Color.RED) # Sets the touch LED to red (ball can not go through)
            elif controller.buttonEUp.pressing() and count1 % 2 == 1 and not controller_e_Up_button_held or bumperPressing:
                # Retracts the cylinder only if the E_Up button is pressed, count1 is odd, and the button is not already held.
                if bumperPressing:
                    bumperActivated = True
                pneumatic.retract(CYLINDER1) # Retracts the cylinder
                count1 += 1 # Increases the count by one
                controller_e_Up_button_held = True # lets me know that the button is held
                tLED.set_color(Color.GREEN) # Sets the touch LED to green (ball can go through)
            elif not controller.buttonEUp.pressing() and not bumperPressing: 
                # If the button is not being pressed, lets me know that it is not being held with...
                controller_e_Up_button_held = False # ...this

How do you place your code in the extendable window in such cool way?

@gsereda Common knowledge on the forums (I believe); there are two methods.

  • Three backticks in a row before and after. (```)
  • [code] before and [/code] after (known as code tags)
2 Likes

I didn’t know that this existed…

Also, for the box, I did this:

1 Like