working dipper boom, pivot
This commit is contained in:
@@ -4,7 +4,7 @@ XboxSeriesXControllerESP32_asukiaaa::Core xboxController; //"40:8e:2c:41:e4:eb")
|
|||||||
uint32_t lastcontrollernotify = 0;
|
uint32_t lastcontrollernotify = 0;
|
||||||
|
|
||||||
uint16_t joymax = 0;
|
uint16_t joymax = 0;
|
||||||
#define deadband 7000
|
#define deadband 10000
|
||||||
|
|
||||||
direction getdirection(int setpoint)
|
direction getdirection(int setpoint)
|
||||||
{
|
{
|
||||||
@@ -51,16 +51,19 @@ void loop_controller()
|
|||||||
{
|
{
|
||||||
log_i("joyLHori rate: %u", xboxController.xboxNotif.joyLHori);
|
log_i("joyLHori rate: %u", xboxController.xboxNotif.joyLHori);
|
||||||
log_i("joyLVert rate: %u", xboxController.xboxNotif.joyLVert);
|
log_i("joyLVert rate: %u", xboxController.xboxNotif.joyLVert);
|
||||||
log_i("joyRHori rate: %0.0f", ((float)xboxController.xboxNotif.joyRHori / joymax *100));
|
log_i("joyRHori rate: %u", xboxController.xboxNotif.joyRHori);
|
||||||
log_i("joyRVert rate: %0.0f",((float)xboxController.xboxNotif.joyRVert / joymax *100));
|
log_i("joyRVert rate: %u", xboxController.xboxNotif.joyRVert);
|
||||||
log_i("battery %d %", xboxController.battery);
|
log_i("battery %d %", xboxController.battery);
|
||||||
log_i("joymax:%d",joymax );
|
log_i("joymax:%d",joymax );
|
||||||
lastcontrollernotify = millis();
|
lastcontrollernotify = millis();
|
||||||
}
|
}
|
||||||
controlMotor("Boom", getdirection(xboxController.xboxNotif.joyLHori));
|
controlMotor("Pivot", getdirection(xboxController.xboxNotif.joyLHori));
|
||||||
controlMotor("Pivot", getdirection(xboxController.xboxNotif.joyLVert));
|
controlMotor("Dipper", getdirection(xboxController.xboxNotif.joyLVert));
|
||||||
|
|
||||||
controlMotor("Bucket", getdirection(xboxController.xboxNotif.joyRHori));
|
controlMotor("Bucket", getdirection(xboxController.xboxNotif.joyRHori));
|
||||||
controlMotor("Dipper", getdirection(xboxController.xboxNotif.joyRVert));
|
controlMotor("Boom", getdirection(xboxController.xboxNotif.joyRVert));
|
||||||
|
|
||||||
|
//controlMotor("TrackLeft", getdirection(xboxController.xboxNotif.trigLT)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ std::vector<motor> motors;
|
|||||||
|
|
||||||
void setup_motors()
|
void setup_motors()
|
||||||
{
|
{
|
||||||
|
mcp.begin_I2C();
|
||||||
for (int i = 0; i < NUMMOTORS; i++)
|
for (int i = 0; i < NUMMOTORS; i++)
|
||||||
{
|
{
|
||||||
motor newmotor(initlist[i]);
|
motor newmotor(initlist[i]);
|
||||||
@@ -110,82 +111,3 @@ void motor::run(direction dir)
|
|||||||
}
|
}
|
||||||
current = dir;
|
current = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//uint32_t lastmotorlog = 0;
|
|
||||||
|
|
||||||
|
|
||||||
// void drivemotor(uint8_t num, int dirspeed)
|
|
||||||
// {
|
|
||||||
// if (num <= motorPins.size())
|
|
||||||
// {
|
|
||||||
// if(dirspeed > 46 && dirspeed < 55) //deadband
|
|
||||||
// {
|
|
||||||
// motors[num].stop();
|
|
||||||
// log_v("stop");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// uint8_t mapspeed = map(dirspeed, 0, 100, 100, -100);
|
|
||||||
// motors[num].move(mapspeed);
|
|
||||||
// motors[num].prevsetpoint = mapspeed;
|
|
||||||
// if (millis() - lastmotorlog > MOTORLOGTIME)
|
|
||||||
// {
|
|
||||||
// log_i("drive motor %u, speed %d%(%d)", num, dirspeed, mapspeed);
|
|
||||||
// lastmotorlog = millis();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// log_e("invalid motor num %d", num);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// int prevBucketAngle = 0;
|
|
||||||
// uint32_t lastbuckettimer = 0;
|
|
||||||
// void bucketTilt(int bucketServoValue)
|
|
||||||
// {
|
|
||||||
// if(millis()- lastbuckettimer > BUCKETTIMER)
|
|
||||||
// {
|
|
||||||
// log_v("bucket command received = %i", bucketServoValue);
|
|
||||||
// int servo = 0;
|
|
||||||
// if(bucketServoValue == 0)
|
|
||||||
// {
|
|
||||||
// log_v("bucket stop");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
// else if(bucketServoValue > 0)
|
|
||||||
// {
|
|
||||||
// servo = prevBucketAngle + SERVOSTEP;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// servo = prevBucketAngle - SERVOSTEP;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if(servo > SERVOMAX) servo = SERVOMAX;
|
|
||||||
// if(servo < SERVOMIN) servo = SERVOMIN;
|
|
||||||
|
|
||||||
// bucketServo.write(servo);
|
|
||||||
// log_v("bucket (%i) angle=(%d)", bucketServoValue, servo);
|
|
||||||
|
|
||||||
// lastbuckettimer = millis();
|
|
||||||
// prevBucketAngle = servo;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void AbsBucketTilt(int bucketServoValue)
|
|
||||||
// {
|
|
||||||
// log_v("drive bucket servo, angle %d", bucketServoValue);
|
|
||||||
// delay(5);
|
|
||||||
// bucketServo.write(bucketServoValue);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// void auxControl(int auxServoValue)
|
|
||||||
// {
|
|
||||||
// log_v("drive aux servo, angle %d", auxServoValue);
|
|
||||||
// delay(5);
|
|
||||||
// auxServo.write(auxServoValue);
|
|
||||||
// }
|
|
||||||
|
|||||||
Reference in New Issue
Block a user