def __init__(self, physics_controller): self.logger = logging.getLogger("PhysicsEngine") self.physics_controller = physics_controller self.drivetrain = drivetrains.MecanumDrivetrain() self.initial = True self.simulated_position = 0.0 self.user_renderer = get_user_renderer()
def __init__(self, physics_controller): """ :param physics_controller: `pyfrc.physics.core.Physics` object to communicate simulation effects to """ self.physics_controller = physics_controller # Motors self.lf_motor = hal.simulation.PWMSim(1) self.lr_motor = hal.simulation.PWMSim(2) self.rf_motor = hal.simulation.PWMSim(3) self.rr_motor = hal.simulation.PWMSim(4) # Gyro self.gyro = hal.simulation.AnalogGyroSim(1) self.drivetrain = drivetrains.MecanumDrivetrain() # Precompute the encoder constant self.frontLeftEncoder = hal.simulation.EncoderSim(0) self.rearLeftEncoder = hal.simulation.EncoderSim(1) self.frontRightEncoder = hal.simulation.EncoderSim(2) self.rearRightEncoder = hal.simulation.EncoderSim(3) # -> encoder counts per revolution / wheel circumference self.encoderDistanceCalculation = 1024 / (0.0254 * 6 * math.pi) self.frontLeftEncoderDistance = 0 self.rearLeftEncoderDistance = 0 self.frontRightEncoderDistance = 0 self.rearRightEncoderDistance = 0
def __init__(self, controller): self.controller = controller self.drive = drive.Drive() self.odemetry = odemetry.Odemetry() self.drivetrain = drivetrains.MecanumDrivetrain(x_wheelbase=units.inchesToFeet(Constants.X_WHEEL_BASE), y_wheelbase=units.inchesToFeet( Constants.Y_WHEEL_BASE), speed=units.inchesToFeet(Constants.THEORETICAL_MAX_VELOCITY)) self.starting_x = units.feetToInches( config.config_obj['pyfrc']['robot']['starting_x']) self.starting_y = units.feetToInches( config.config_obj['pyfrc']['robot']['starting_y'])
def __init__(self, physics_controller): """ :param physics_controller: `pyfrc.physics.core.Physics` object to communicate simulation effects to """ self.physics_controller = physics_controller # Motors self.lf_motor = hal.simulation.PWMSim(1) self.lr_motor = hal.simulation.PWMSim(2) self.rf_motor = hal.simulation.PWMSim(3) self.rr_motor = hal.simulation.PWMSim(4) # Gyro self.gyro = hal.simulation.AnalogGyroSim(1) self.drivetrain = drivetrains.MecanumDrivetrain()
def __init__(self, physics_controller): """ :param physics_controller: `pyfrc.physics.core.PhysicsInterface` object to communicate simulation effects to """ self.physics_controller = physics_controller # Motors self.lf_motor = hal.simulation.PWMSim(1) self.lr_motor = hal.simulation.PWMSim(2) self.rf_motor = hal.simulation.PWMSim(3) self.rr_motor = hal.simulation.PWMSim(4) self.navx = hal.simulation.SimDeviceSim("navX-Sensor[4]") self.navx_yaw = self.navx.getDouble("Yaw") self.drivetrain = drivetrains.MecanumDrivetrain()
def __init__(self, physics_controller: PhysicsInterface, robot: "MyRobot"): """ :param physics_controller: `pyfrc.physics.core.Physics` object to communicate simulation effects to :param robot: your robot object """ self.physics_controller = physics_controller # Motors self.lf_motor = wpilib.simulation.PWMSim( robot.frontLeftMotor.getChannel()) self.lr_motor = wpilib.simulation.PWMSim( robot.rearLeftMotor.getChannel()) self.rf_motor = wpilib.simulation.PWMSim( robot.frontRightMotor.getChannel()) self.rr_motor = wpilib.simulation.PWMSim( robot.rearRightMotor.getChannel()) self.navx = wpilib.simulation.SimDeviceSim("navX-Sensor[4]") self.navx_yaw = self.navx.getDouble("Yaw") self.drivetrain = drivetrains.MecanumDrivetrain()
def __init__(self, physics_controller): """ :param physics_controller: `pyfrc.physics.core.Physics` object to communicate simulation effects to """ self.fl_encoder = self.fr_encoder = self.rl_encoder = self.rr_encoder = 0 self.physics_controller = physics_controller """ # Change these parameters to fit your robot! """ # Create a lift simulation self.lift_motion = motion.LinearMotion("Lift", 6, 360) self.mecaum_drivetrain = drivetrains.MecanumDrivetrain(x_wheelbase=2, y_wheelbase=2, speed=5) self.tank_drivetrain = drivetrains.FourMotorDrivetrain(x_wheelbase=2, speed=5) self.physics_controller.add_device_gyro_channel("navxmxp_spi_4_angle")