Go to Post I always thought a trained bio mechanical monkey wrapped in aluminum foil would be the best robot, but every year my team says "No Pete, go sit down." - BuddyB309 [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Closed Thread
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 15-02-2015, 21:43
Cyan's Avatar
Cyan Cyan is offline
Vegeta SSJ4
AKA: Sayan Dutta
FRC #2642 (Pitt Pirates)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Utopia
Posts: 27
Cyan is an unknown quantity at this point
Re: CodeProblem

Quote:
Originally Posted by legts View Post
I think I know what your problem is. If, and if being the key word, button1 works, then my theory is correct. When declaring buttons, you need to have then declared exactly as button1 is declared. Namely, having "Button" before the button name. Hope I helped!
I don't believe this is the problem. Notice there are commas instead of semicolons at the end of each line; this should be the correct syntax.


As for AnnaliseDonavan, could you be more specific in your question? Also, which IDE do you use? Your code is relatively messy, so if you could show me one instance where your code does not work, you could troubleshoot through that pathway and follow example with the rest of the buttons.
  #2   Spotlight this post!  
Unread 15-02-2015, 21:45
legts legts is offline
Autonomous Queen
FRC #2399 (The Fighting Unicorns)
Team Role: Programmer
 
Join Date: Jan 2015
Rookie Year: 2012
Location: Ohio
Posts: 73
legts is an unknown quantity at this point
Re: CodeProblem

Quote:
Originally Posted by Cyan View Post
I don't believe this is the problem. Notice there are commas instead of semicolons at the end of each line; this should be the correct syntax.
I did not notice that before, thanks for pointing that out!
  #3   Spotlight this post!  
Unread 15-02-2015, 23:09
AnnaliseDonavan AnnaliseDonavan is offline
Registered User
FRC #4284
 
Join Date: Jan 2015
Location: Cincinnati,Ohio
Posts: 20
AnnaliseDonavan is an unknown quantity at this point
Re: CodeProblem

As for the needing of semi colons for this set up when I place semi colons it produces an error and when I looked up the correct way to do the button control this is what I found.

And I apologist I am new to coding but no one on my team knows how to code so we are lost. For the one instance currently all I have in the implementing stage is the buttons so that is all the is and it dose not work.
  #4   Spotlight this post!  
Unread 16-02-2015, 00:08
Cyan's Avatar
Cyan Cyan is offline
Vegeta SSJ4
AKA: Sayan Dutta
FRC #2642 (Pitt Pirates)
Team Role: Programmer
 
Join Date: Apr 2014
Rookie Year: 2014
Location: Utopia
Posts: 27
Cyan is an unknown quantity at this point
Re: CodeProblem

Try moving this code:
Code:
Button button1 = new JoystickButton(joystick, 1),
button2 = new JoystickButton(joystick, 2),
button3 = new JoystickButton(joystick, 3),
button4 = new JoystickButton(joystick, 4),
button5 = new JoystickButton(joystick, 5),
button6 = new JoystickButton(joystick, 6),
button7 = new JoystickButton(joystick, 7),
button8 = new JoystickButton(joystick, 8),
button9 = new JoystickButton(joystick, 9),
button10 = new JoystickButton(joystick, 10),
button11 = new JoystickButton(joystick , 11);
from Robot.teleopPeriodic() to Robot.robotInit(), and see if that leads to anything.
  #5   Spotlight this post!  
Unread 16-02-2015, 00:12
om_nom_nom om_nom_nom is offline
Registered User
AKA: Nam
FRC #0708 (Hardwired Fusion)
Team Role: Programmer
 
Join Date: Jan 2014
Rookie Year: 2012
Location: Pennsylvania
Posts: 6
om_nom_nom is an unknown quantity at this point
Re: CodeProblem

This may not solve much, but I suggest moving your button code into teleopInit(), otherwise you are creating buttons in a loop during teleop.

Also, have you tested your commands without the buttons? The issue may be that your commands are not working, not the buttons. To do this in Java, you can add
Code:
SmartDashboard.putData(new Command());
into your robotInit(). Then open up SmartDashboard from the driver station or a double-clicking on the program. You should see a button on the Dashboard after you compile that code. Click it to run, and click it again to cancel.
  #6   Spotlight this post!  
Unread 16-02-2015, 00:39
GeeTwo's Avatar
GeeTwo GeeTwo is online now
Technical Director
AKA: Gus Michel II
FRC #3946 (Tiger Robotics)
Team Role: Mentor
 
Join Date: Jan 2014
Rookie Year: 2013
Location: Slidell, LA
Posts: 3,614
GeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond reputeGeeTwo has a reputation beyond repute
Re: CodeProblem

Quote:
Originally Posted by legts View Post
I did not notice that before, thanks for pointing that out!
This is one of the important reasons to follow programming style conventions - that is, make your code look like programmers expect. In this case, the usual convention for objects is that the commas are only used if they are not being set. It's also common to keep columns aligned as you go down parallel code; this is why code is traditionally displayed in a fixed-width font. The usual style conventions would look like:
Code:
Button button1  = new JoystickButton(joystick,  1);
Button button2  = new JoystickButton(joystick,  2);
Button button3  = new JoystickButton(joystick,  3);
Button button4  = new JoystickButton(joystick,  4);
Button button5  = new JoystickButton(joystick,  5);
Button button6  = new JoystickButton(joystick,  6);
Button button7  = new JoystickButton(joystick,  7);
Button button8  = new JoystickButton(joystick,  8);
Button button9  = new JoystickButton(joystick,  9);
Button button10 = new JoystickButton(joystick, 10);
Button button11 = new JoystickButton(joystick, 11);
Following programming style conventions is nearly as important as following wiring color code conventions, and for exactly the same reason -- so that the guy (or gal) who comes behind you can easily figure out what you did. So far, it's not the law, or even in the FRC rules, but maybe it should be. Or maybe not -- do we really want code inspectors?
__________________

If you can't find time to do it right, how are you going to find time to do it over?
If you don't pass it on, it never happened.
Robots are great, but inspiration is the reason we're here.
Friends don't let friends use master links.
Closed Thread


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 01:47.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi