Team2168 / 2015_Main_Robot

Source code for the 2015 season
2 stars 0 forks source link

Change all Drive With Joystick Commands #60

Closed NotInControl closed 9 years ago

NotInControl commented 9 years ago

Modify all DriveWithJoystick commands to have a constructor which takes in a Joystick type and a axis number, and remove the default constructors.

The reason for this change is so that we can keep track of which axis is tied to what function. Right now since all of the drive with joystick commands are buried within the command itself, it is possible to assign multiple axis to multiple commands, unintentionally.

The change will be something like the following:

For example you will have

//drive with joystick command file
Joystick joy;
int leftAxis;
int rightAxis;
DriveWithJoysticks(Joystick joy, int leftAxis, int rightAxis)
{
this.Joy = joy;
this.leftAxis = leftAxis;
this.rightAxis = rightAxis;
}

Then the execute command will change to something like this:

void execute()
{
Robot.drivetrain.tankdrive(joy.getRawAxis(leftAxis), joy.getRawAxis(rightAxis));
}

We can then add all the F310 axis in Robot Map and map the commands, such that the default commands in the subsystems will look something like this:

//Robot Map file

public static final int leftDriveAxis = F310.AXIS_LEFT_Y;
public static final in rightDriveAxis = F310.AXIS_RIGHT_Y;
//DriveTrain Subsystem file

public void initDefaultCommand() { 

setDefaultCommand(new DriveWithJoysticks(OI.driverJoystick, RobotMap.leftDriveAxis , RobotMap.rightDriveAxis )); 
} 

I think this will work, and RobotMap can keep track of all Axis for each controller, Or you can Put it in OI I don't care. The code I wrote is just pseudo and will need to be checked.

Also for this to work, you will need to make all of these static fields public in the F310 class:

https://github.com/Team2168/2015_Main_Robot/blob/master/src/org/team2168/utils/F310.java#L16-22

jcorcoran commented 9 years ago

closed by #64

NotInControl commented 9 years ago

I would make it so that robotmap or maybe even in OI spelt out every axis for the controllers for example:

//Driver Joystick Public final int leftDriveAxis = F310.LeftaxisY; Public final int rightDriveAxis = F310.RightAxisY

//operator Joysrick Public final in winchDriveAxis = F310.TriggerAxis; Public final int intakeDriveAxis = F310.LeftAxisY; Public final int liftDriveAxis = F310.RightAxisY;

This way we have a map of axis for all controllers just like OI maps all of the buttons

jcorcoran commented 9 years ago

Can we keep all this stuff in OI?

Id prefer having a single place defining controls.