def teleopPeriodic(self): """This function is called periodically during operator control.""" oi.read_all_controller_inputs() x = state["mov_x"] * .7 y = state["mov_y"] * .7 z = state["mov_z"] * .5 powerX = 0 if x < 0.15 and x > -0.15 else x powerY = 0 if y < 0.15 and y > -0.15 else y powerZ = 0 if z < 0.15 and z > -0.15 else z self.drive.driveCartesian(powerX, -powerY, powerZ, 0) #print(self.encoder.get()) if state["ir"] == True: if self.ir5.get() or self.ir6.get(): self.drive.driveCartesian(0, -1, 0, 0) elif self.ir.get() or self.ir2.get(): self.drive.driveCartesian(0, 1, 0, 0) elif self.ir3.get() or self.ir4.get(): self.drive.driveCartesian(1, 0, 0, 0) self.timer.start() if self.timer.get() <= 3: """self.timer.start()""" self.drive.driveCartesian(1, 0, 0, 0) else: self.drive.driveCartesian(0, 0, 0, 0)
def teleopPeriodic(self): #se leen constantemente los botones y joysticks oi.read_all_controller_inputs() #código para el funcionamiento del movimiento # de las mecanum a través del control de xbox x = state["mov_x"] * .7 y = state["mov_y"] * .7 z = state["mov_z"] * .7 powerX = 0 if x < 0.15 and x > -0.15 else x powerY = 0 if y < 0.15 and y > -0.15 else y powerZ = 0 if z < 0.15 and z > -0.15 else z if state["button_x_active"]: if self.sensor_principal.get(): self.drive.driveCartesian(0, 0, 0, 0) elif self.sensor_izquierdo.get(): self.drive.driveCartesian(0.4, 0, 0, 0) elif self.sensor_derecho.get(): self.drive.driveCartesian(-0.4, 0, 0, 0) else: self.drive.driveCartesian(0, -0.5, 0, 0) else: self.drive.driveCartesian(powerX, powerY, powerZ, 0) #código para el funcionamiento del elevador y la garra if state["activating_lift"]: state["timer_lift"] += 1 if state["timer_lift"] <= 100: self.lift_motor.set(1) elif state["timer_lift"] <= 200: self.lift_motor.set(0) self.cargo_motor.set(-1) elif state["timer_lift"] <= 300: self.lift_motor.set(-1) self.cargo_motor.set(0) else: self.lift_motor.set(0) self.cargo_motor.set(0) else: state["timer_lift"] = 0 self.lift_motor.set(0) self.cargo_motor.set(0)
def teleopPeriodic(self): def getThrottle(self): return self._getRawAxis(0) #se leen constantemente los botones y joysticks oi.read_all_controller_inputs() #código para el funcionamiento del movimiento # de las mecanum a través del control de xbox x = state["mov_x"] y = state["mov_y"] * 0.7 z = state["mov_z"] * 0.7 if state["mov_xr"] != 0 and state["mov_xl"] == 0: x = state["mov_xr"] * 0.7 if state["mov_xl"] != 0 and state["mov_xr"] == 0: x = state["mov_xl"] * 0.7 powerX = 0 if x < 0.05 and x > -0.05 else x powerY = 0 if y < 0.05 and y > -0.05 else y powerZ = 0 if z < 0.05 and z > -0.05 else z self.drive.driveCartesian(powerX, powerY, powerZ, 0) #código para el funcionamiento del elevador y la garra if state["activating_lift"]: state["timer_lift"] += 1 if state["timer_lift"] <= 100: self.lift_motor.set(1) elif state["timer_lift"] <= 200: self.lift_motor.set(0) self.cargo_motor.set(-1) elif state["timer_lift"] <= 300: self.lift_motor.set(-1) self.cargo_motor.set(0) else: self.lift_motor.set(0) self.cargo_motor.set(0) else: state["timer_lift"] = 0 self.lift_motor.set(0) self.cargo_motor.set(0)
def teleopPeriodic(self): self.PID() self.timer.start() oi.read_all_controller_inputs() if state["button_x_active"]: if self.rcw >= 68213.80: self.lift.set(0.8) self.lift2.set(0.8) elif self.rcw <= 68213.80 and self.rcw >= 58009.74: self.lift.set(0.7) self.lift2.set(0.7) elif self.rcw <= 58009.74 and self.rcw >= 37601.74: self.lift.set(0.6) self.lift2.set(0.6) elif self.rcw <= 37601.74 and self.rcw >= 12091.74: self.lift.set(0.5) self.lift2.set(0.5) elif self.rcw <= 12091.74 and self.rcw >= 102.04: self.lift.set(0.4) self.lift2.set(0.4) elif self.rcw <= 102.04: self.lift.set(0) self.lift2.set(0) wpilib.DriverStation.reportWarning(str(self.PID()), False) wpilib.DriverStation.reportWarning(str(self.encoder.get()), False) elif state["button_y_active"] == True: self.lift.set(-0.4) self.lift2.set(-0.4) else: self.lift.set(0) self.lift2.set(0) """if state["button_x_active"]:
def teleopPeriodic(self): #print(PIDController.get(self)) # print(self.setpoint) #print(self.rcw) #print (Encoder.getFPGAIndex(self.encoder)) #self.encoder.reset() #se leen constantemente los botones y joysticks #print(self.encoder.get()) oi.read_all_controller_inputs() #código para el funcionamiento del movimiento # de las mecanum a través del control de xbox v = max(self.ir.getVoltage(), 0.00001) d = 62.28 * math.pow(v, -1.092) print(self.ir2.get()) # Constrain output #print(max(min(d, 145.0), 22.5)) x = state["mov_x"] * .7 y = state["mov_y"] * .7 z = state["mov_z"] * .7 powerX = 0 if x < 0.15 and x > -0.15 else x powerY = 0 if y < 0.15 and y > -0.15 else y powerZ = 0 if z < 0.15 and z > -0.15 else z if state["button_x_active"]: if self.sensor_principal.get(): drive_for() self.drive.driveCartesian(0, 0, 0, 0) elif self.sensor_izquierdo.get(): self.drive.driveCartesian(0.4, 0, 0, 0) elif self.sensor_derecho.get(): self.drive.driveCartesian(-0.4, 0, 0, 0) else: self.drive.driveCartesian(0, -0.5, 0, 0) else: self.drive.driveCartesian(powerX, powerY, powerZ, 0) #código para el funcionamiento del elevador y la garra if state["activating_lift"]: state["timer_lift"] += 1 if state["timer_lift"] <= 100: self.lift_motor.set(1) elif state["timer_lift"] <= 200: self.lift_motor.set(0) self.cargo_motor.set(-1) elif state["timer_lift"] <= 300: self.lift_motor.set(-1) self.cargo_motor.set(0) else: self.lift_motor.set(0) self.cargo_motor.set(0) else: state["timer_lift"] = 0 self.lift_motor.set(0) self.cargo_motor.set(0)