Need serious help with coding!!

How can i program the part of my robot that will tilt the bridge towards me. i want it to go tilt forward then back. i am coding in netbeans (java).

The answer to your question can be affected by a lot of things:

  • Which of the many different possible bridge tipping mechanisms are you using?
  • Is it controlled by a Spike, or a speed controller? If the latter, Victor or Jaguar?
  • Are you using the IterativeRobot template, or a Command-based one?
  • Do you want it to respond to user input? If so, should it be button-controlled or joystick controlled? Do you want a button to toggle it?
  • Are there any limit switches involved?

I don’t want to give you bad advice, so a little more clarity would be helpful.

A great tool that really helped me a lot was the getting started guide(here), and the FRC Programming Cookbook(here). These are both chocked full of great resources, examples, and explanations and are a great way to overcome problems.

+1

Also, do you have code that already exists that you would like for us to take a look over/review for you?

i am using jaguars(speedcontrollers) i have something like ahand with wheels that i want to tilt. i want a button to toggle it one button tilts forward other button makes it goes backwards

and yes i have code i will post it that too

How is the mechanism supposed to know when to stop, in each direction, after you press each toggle button? i.e. are you using limit switches, or a potentiometer, or an encoder, or something else?

a basic code would be

if(joystick.getRawButton(4)
     jaguar.set(1);
else if(joystick.getRawButton(5)
     jaguar.set(-1);
else
     jaguar.set(0);

Note: This will not create a toggle effect. If 4 is pressed, the motor will go forward and if 5 is pressed the motor will go in reverse, but it will not continue to go in that direction if you let go of the button. However, this is a good, simple solution to the problem you are facing. One thing to note about how this code will perform, if both buttons are pressed, the jaguar will go forward. One way to fix this is to replace the first line with

if(joystick.getRawButton(4) && !joystick.getRawButton(5))

It is a little bit longer, but will protect you from accidentally going in the wrong direction should you hit both buttons in the heat of competition. In order to have a true toggle effect, you will probably need a limit switch or potentiometer or other sensor to tell you when you are done going up or done going down. Hope this helps!

In addition to the above, the other issue you will have to deal with is: How are you going to hold the “tilted hand with wheels” in place once it has reached the desired position?