Go to Post All the "official game hint" is is an "official red herring" - Cory [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Spotlight this post!  
Unread 27-06-2016, 10:00
MrRoboSteve MrRoboSteve is offline
Mentor
AKA: Steve Peterson
FRC #3081 (Kennedy RoboEagles)
Team Role: Mentor
 
Join Date: Mar 2012
Rookie Year: 2011
Location: Bloomington, MN
Posts: 570
MrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond reputeMrRoboSteve has a reputation beyond repute
Re: Is my code good?

There is lots to like about your code. It's well organized and generally easy to read. A couple specific comments:

1. We like to use constants in RobotMap.java, organized by kind of interface. We can then print this out and use it as instructions for wiring.

For example:

Code:
 	/** 
 	 * PWM   	 */ 
        public static final int CHASSIS_JAGUAR_FRONT_LEFT = 2; 
 	public static final int CHASSIS_JAGUAR_BACK_LEFT = 3; 
 	public static final int CHASSIS_JAGUAR_FRONT_RIGHT = 0; 
 	public static final int CHASSIS_JAGUAR_BACK_RIGHT = 1; 
 	public static final int BALL_SHOOTER_LEFT_SPEED_CONTROLLER = 4; 
 	public static final int BALL_SHOOTER_RIGHT_SPEED_CONTROLLER = 5; 
 	public static final int ARM_EXTEND_SPEED_CONTROLLER = 6; 
 	public static final int CAMERA_TILT_MOTOR = 7;
I'd then recommend moving the declarations out of RobotMap and into the subsystem that owns the device/controller. We generally make each controller/encoder/gyro be owned by exactly one subsystem, and hide the reference inside the subsystem (make them private). This way we know that there's only one place to look for code that changes those entities.

You're almost there with your final references in the subsystems, but they are copies of reference and the actual controller/encoder/gyro is available to everyone.

2. In AvancerHerse, consider using more descriptive variable names:

Code:
	int h1 = 950;
	int h2 = 450;
and think about simplifying "!(Robot.bras.distPot() < h1)" a bit:

Code:
		if (!Robot.pelle.herseAcotee()) {
			// h1, h2 = hauteur pelle
			if ((Robot.bras.distPot() > h1)) {
				Robot.chassis.reculer(-0.4, 0);
			} else if ((Robot.bras.distPot() > h2) && !(Robot.bras.distPot() < h1)) {
				Robot.chassis.reculer(-0.6, 0);
			} else {
				Robot.chassis.reculer(-0.9, 0);
			}
		}
3. In BrasCommand, you say:

Code:
		Timer.delay(0.005);
Wondering why this is necessary here and in the other places in the code. Delay like this is needed only in very specialized cases.

4. In BrasCommand, you didn't put this in braces:

Code:
		} else
			Robot.bras.controlBras(0);
For student code, I recommend that every block be enclose in braces as it's consistent and simple to think about.

5. Generally you want the same code in end() and interrupted() -- see Reculer.
__________________
2016-17 events: 10000 Lakes Regional, Northern Lights Regional, FTC Burnsville Qualifying Tournament

2011 - present · FRC 3081 Kennedy RoboEagles mentor
2013 - present · event volunteer at 10000 Lakes Regional, Northern Lights Regional, North Star Regional, Lake Superior Regional, Minnesota State Tournament, PNW District 4 Glacier Peak, MN FTC, CMP
http://twitter.com/MrRoboSteve · www.linkedin.com/in/speterson
Reply With Quote
 


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 08:50.

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