I encountered some issues while coding, where the line
self.mtrgrp_L = vex.MotorGroup(self.mtr_LF, self.mtr_LM, self.mtr_LB)
self.mtrgrp_R = vex.MotorGroup(self.mtr_RF, self.mtr_RM, self.mtr_RB)
always throws an error: “No such attribute.” I’m not sure why this is happening
code:
# ----------------------------------------------------------------------------------------------- #
# Robot Configuration
# This class contains all the configuration for the robot, including motors, sensors, and other components.
# Do not change the configuration unless you know what you are doing.
class RobotConfig:
# Chassis Parameters
wheel_diameter_in = 3.25
gear_ratio = 60 / 36
# Brain
brain = vex.Brain()
# Motors
mtr_LF = vex.Motor(vex.Ports.PORT1, vex.GearSetting.RATIO_18_1, False)
mtr_LM = vex.Motor(vex.Ports.PORT2, vex.GearSetting.RATIO_18_1, False)
mtr_LB = vex.Motor(vex.Ports.PORT3, vex.GearSetting.RATIO_18_1, False)
mtr_RF = vex.Motor(vex.Ports.PORT4, vex.GearSetting.RATIO_18_1, False)
mtr_RM = vex.Motor(vex.Ports.PORT5, vex.GearSetting.RATIO_18_1, False)
mtr_RB = vex.Motor(vex.Ports.PORT6, vex.GearSetting.RATIO_18_1, False)
# IMU
imu = vex.Inertial(vex.Ports.PORT21)
# Pneumatics
pneumatics = vex.Pneumatics(brain.three_wire_port.a)
# Encoders
enc_x = vex.Rotation(vex.Ports.PORT7, True)
enc_y = vex.Rotation(vex.Ports.PORT8, True)
# Vision Sensor
vision = vex.AiVision(vex.Ports.PORT11)
# Control Parameters
brake_type = StandardBrakeTypes.COAST
# ----------------------------------------------------------------------------------------------- #
# Robot Class
# This class is the instantiation of robot configuration.
# It contains all the components of the robot.
# Do not change the code in this class. If you want to change the configuration, change the `RobotConfig` class.
class Robot():
def __init__(self):
# Chassis Parameters
self.wheel_diameter_in = RobotConfig.wheel_diameter_in
self.wheel_diameter_mm = self.wheel_diameter_in * 25.4
self.wheel_circum_mm = self.wheel_diameter_mm * math.pi
self.gear_ratio = RobotConfig.gear_ratio
# Brain
self.brain = RobotConfig.brain
# Motors
self.mtr_LF = RobotConfig.mtr_LF
self.mtr_LM = RobotConfig.mtr_LM
self.mtr_LB = RobotConfig.mtr_LB
self.mtr_RF = RobotConfig.mtr_RF
self.mtr_RM = RobotConfig.mtr_RM
self.mtr_RB = RobotConfig.mtr_RB
# Motor Groups
self.mtrgrp_L = vex.MotorGroup(self.mtr_LF, self.mtr_LM, self.mtr_LB)
self.mtrgrp_R = vex.MotorGroup(self.mtr_RF, self.mtr_RM, self.mtr_RB)
# IMU
self.imu = RobotConfig.imu
# Pneumatics
self.pneumatics = RobotConfig.pneumatics
# Encoders
self.enc_x = RobotConfig.enc_x
self.enc_y = RobotConfig.enc_y
# Vision Sensor
self.vision = RobotConfig.vision
# Control Parameters
self.brake_type = RobotConfig.brake_type
robot = Robot()