mirror of
https://github.com/team2059/Zaphod
synced 2025-01-07 22:14:14 -05:00
Fixed driving mathmatically, some talons dont get power still
This commit is contained in:
parent
9c88571df9
commit
5a89a6d712
@ -8,7 +8,7 @@ HHRobot::HHRobot():
|
|||||||
compressorSystem(new HHCompressor()),
|
compressorSystem(new HHCompressor()),
|
||||||
dashboard(new HHDashboard()){
|
dashboard(new HHDashboard()){
|
||||||
//sonar(new HHSonar()){
|
//sonar(new HHSonar()){
|
||||||
netTable=NetworkTable::GetTable("datatable");
|
driveTable=NetworkTable::GetTable("ZaphodDrive");
|
||||||
right1 = new Talon(DRIVE_RIGHT_MOTOR_ONE, DRIVE_RIGHT_SIDECAR);
|
right1 = new Talon(DRIVE_RIGHT_MOTOR_ONE, DRIVE_RIGHT_SIDECAR);
|
||||||
right2 = new Talon(DRIVE_RIGHT_MOTOR_TWO, DRIVE_RIGHT_SIDECAR);
|
right2 = new Talon(DRIVE_RIGHT_MOTOR_TWO, DRIVE_RIGHT_SIDECAR);
|
||||||
right3 = new Talon(DRIVE_RIGHT_MOTOR_THREE, DRIVE_RIGHT_SIDECAR);
|
right3 = new Talon(DRIVE_RIGHT_MOTOR_THREE, DRIVE_RIGHT_SIDECAR);
|
||||||
@ -22,8 +22,8 @@ void HHRobot::Init(){
|
|||||||
collector->CollectBallAtSpeed(0);
|
collector->CollectBallAtSpeed(0);
|
||||||
}
|
}
|
||||||
bool HHRobot::CheckJoystickValues(){
|
bool HHRobot::CheckJoystickValues(){
|
||||||
float x=controlSystem->GetJoystickAxis(1,1);
|
float x=controlSystem->GetJoystickAxis(1,"x");
|
||||||
float y=controlSystem->GetJoystickAxis(1,2);
|
float y=controlSystem->GetJoystickAxis(1,"y");
|
||||||
if((-.1<x && x<.1) && (-.1<y && y<.1)) {
|
if((-.1<x && x<.1) && (-.1<y && y<.1)) {
|
||||||
dashboard->PutBoolValue("Joysticks Valid",true);
|
dashboard->PutBoolValue("Joysticks Valid",true);
|
||||||
return true;
|
return true;
|
||||||
@ -32,31 +32,38 @@ bool HHRobot::CheckJoystickValues(){
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void HHRobot::DriveRobot(float x,float y){
|
void HHRobot::DriveRobot(float y,float x){
|
||||||
if(y>1.0f){
|
if(y>1.0f){
|
||||||
y=1.0f;
|
y=1.0f;
|
||||||
}else if(y!=0.0f&&y<-1.0f){
|
}else if(y!=0.0f&&y<-1.0f){
|
||||||
y=-1.0f;
|
y=-1.0f;
|
||||||
}
|
}
|
||||||
//float leftPower=((y+x)/2+1)*127+1;
|
float leftPower=((y+x)/2+1)*127+1;
|
||||||
//float rightPower=((y-x)/2+1)*127+1;
|
float rightPower=((y-x)/2+1)*127+1;
|
||||||
//printf("Left: %f\n", leftPower);
|
driveTable->PutNumber("joystickRawX",x);
|
||||||
//printf("Right: %f\n", rightPower);
|
driveTable->PutNumber("joystickRawY",y);
|
||||||
//right1->SetRaw(int(rightPower));
|
driveTable->PutNumber("leftSidePower",leftPower);
|
||||||
|
driveTable->PutNumber("rightSidePower",rightPower);
|
||||||
|
driveTable->PutNumber("right1MotorPower",right1->GetRaw());
|
||||||
|
driveTable->PutNumber("right2MotorPower",right2->GetRaw());
|
||||||
|
driveTable->PutNumber("right3MotorPower",right3->GetRaw());
|
||||||
|
driveTable->PutNumber("left1MotorPower",left1->GetRaw());
|
||||||
|
driveTable->PutNumber("left2MotorPower",left2->GetRaw());
|
||||||
|
driveTable->PutNumber("left3MotorPower",left3->GetRaw());
|
||||||
|
right1->SetRaw(int(rightPower));
|
||||||
//right2->SetRaw(int(rightPower));
|
//right2->SetRaw(int(rightPower));
|
||||||
//right3->SetRaw(int(rightPower));
|
//right3->SetRaw(int(rightPower));
|
||||||
//left1->SetRaw(int(leftPower));
|
//left1->SetRaw(int(leftPower));
|
||||||
//left2->SetRaw(int(leftPower));
|
left2->SetRaw(int(leftPower));
|
||||||
//left3->SetRaw(int(leftPower));
|
//left3->SetRaw(int(leftPower));
|
||||||
printf("Driving and stuff\n");
|
//printf("Left: %f\n",y+x);
|
||||||
printf("Left: %f\n",y+x);
|
//printf("Right: %f\n",y-x);
|
||||||
printf("Right: %f\n",y-x);
|
//right1->Set(y+x);
|
||||||
right1->Set(y+x);
|
//right2->Set(y+x);
|
||||||
right2->Set(y+x);
|
//right3->Set(y+x);
|
||||||
right3->Set(y+x);
|
//left1->Set(y-x);
|
||||||
left1->Set(y-x);
|
//left2->Set(y-x);
|
||||||
left2->Set(y-x);
|
//left3->Set(y-x);
|
||||||
left3->Set(y-x);
|
|
||||||
}
|
}
|
||||||
void HHRobot::UpdateDashboard(){
|
void HHRobot::UpdateDashboard(){
|
||||||
dashboard->PutFloatValue("Shooting Power",controlSystem->GetThrottle());
|
dashboard->PutFloatValue("Shooting Power",controlSystem->GetThrottle());
|
||||||
@ -85,8 +92,6 @@ void HHRobot::RunAuto(){
|
|||||||
time=0;
|
time=0;
|
||||||
step=1;
|
step=1;
|
||||||
}
|
}
|
||||||
//Important periodic things
|
|
||||||
netTable->PutNumber("AutoStep",step); //Debugging purposes
|
|
||||||
time++;
|
time++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +105,7 @@ void HHRobot::Handler(){
|
|||||||
compressorSystem->CompressorSystemPeriodic(allowCompressing);
|
compressorSystem->CompressorSystemPeriodic(allowCompressing);
|
||||||
collector->UpdateCollector(shooter->isShooting,shooter->GetAngle());
|
collector->UpdateCollector(shooter->isShooting,shooter->GetAngle());
|
||||||
//TODO Fix whatever the heck is wrong with this
|
//TODO Fix whatever the heck is wrong with this
|
||||||
//DriveRobot(controlSystem->GetJoystickAxis(1,1),controlSystem->GetJoystickAxis(1,2));
|
DriveRobot(controlSystem->GetJoystickAxis(1,"x"),controlSystem->GetJoystickAxis(1,"y"));
|
||||||
UpdateDashboard();
|
UpdateDashboard();
|
||||||
//Shooting button
|
//Shooting button
|
||||||
if(controlSystem->GetJoystickButton(1,SHOOTER_FIRE)){
|
if(controlSystem->GetJoystickButton(1,SHOOTER_FIRE)){
|
||||||
|
@ -15,7 +15,7 @@ class HHRobot{
|
|||||||
Talon *right1, *right2, *right3, *left1, *left2, *left3;
|
Talon *right1, *right2, *right3, *left1, *left2, *left3;
|
||||||
Joystick *rightStick, *leftStick;
|
Joystick *rightStick, *leftStick;
|
||||||
JoystickController *controlSystem;
|
JoystickController *controlSystem;
|
||||||
NetworkTable *netTable;
|
NetworkTable *driveTable;
|
||||||
HHShooter *shooter;
|
HHShooter *shooter;
|
||||||
HHCollector *collector;
|
HHCollector *collector;
|
||||||
HHCompressor *compressorSystem;
|
HHCompressor *compressorSystem;
|
||||||
|
@ -4,7 +4,7 @@ JoystickController::JoystickController(){
|
|||||||
shootJoystick=new Joystick(JOYSTICK_LEFT);
|
shootJoystick=new Joystick(JOYSTICK_LEFT);
|
||||||
}
|
}
|
||||||
float JoystickController::GetThrottle(){
|
float JoystickController::GetThrottle(){
|
||||||
return (-GetJoystickAxis(2,4)+1)/2;
|
return (-GetRawJoystickAxis(2,4)+1)/2;
|
||||||
}
|
}
|
||||||
int JoystickController::GetJoystickButton(int joystick, int button){
|
int JoystickController::GetJoystickButton(int joystick, int button){
|
||||||
switch (joystick){
|
switch (joystick){
|
||||||
@ -20,7 +20,7 @@ int JoystickController::GetJoystickButton(int joystick, int button){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
float JoystickController::GetJoystickAxis(int joystick, int axis){
|
float JoystickController::GetRawJoystickAxis(int joystick, int axis){
|
||||||
switch (joystick){
|
switch (joystick){
|
||||||
case 1:
|
case 1:
|
||||||
return driveJoystick->GetRawAxis(axis);
|
return driveJoystick->GetRawAxis(axis);
|
||||||
@ -34,4 +34,20 @@ float JoystickController::GetJoystickAxis(int joystick, int axis){
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float JoystickController::GetJoystickAxis(int joystick, std::string axis){
|
||||||
|
if (joystick == 1) {
|
||||||
|
if (axis == "x"){
|
||||||
|
return driveJoystick->GetX();
|
||||||
|
}else if (axis == "y"){
|
||||||
|
return driveJoystick->GetY();
|
||||||
|
}else if (axis == "z"){
|
||||||
|
return driveJoystick->GetZ();
|
||||||
|
}else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
@ -8,6 +8,7 @@ class JoystickController
|
|||||||
JoystickController();
|
JoystickController();
|
||||||
float GetThrottle();
|
float GetThrottle();
|
||||||
int GetJoystickButton(int,int);
|
int GetJoystickButton(int,int);
|
||||||
float GetJoystickAxis(int,int);
|
float GetRawJoystickAxis(int,int);
|
||||||
|
float GetJoystickAxis(int, std::string axis);
|
||||||
};
|
};
|
||||||
// vim: ts=2:sw=2:et
|
// vim: ts=2:sw=2:et
|
||||||
|
Loading…
x
Reference in New Issue
Block a user