I have programmed my auton to do this:
def autonomous():
global remote_control_code_enabled
remote_control_code_enabled = False
brain.screen.print("RC OFF")
conveyor.set_velocity(180, RPM)
intake.set_velocity(180, RPM)
drivetrain.set_drive_velocity(40,PERCENT)
drivetrain.set_turn_velocity(20, PERCENT)
drivetrain.drive_for(FORWARD, 6, INCHES)
drivetrain.stop()
drivetrain.turn_for(RIGHT, 90, DEGREES)
drivetrain.stop()
drivetrain.drive_for(FORWARD, 64, INCHES)
drivetrain.stop()
intake.spin(REVERSE)
conveyor.spin(FORWARD)
wait(3,SECONDS)
intake.stop()
conveyor.stop()
drivetrain.drive_for(REVERSE, 24, INCHES)
drivetrain.stop()
drivetrain.turn_for(LEFT, 90, DEGREES)
drivetrain.stop()
drivetrain.drive_for(REVERSE, 24, INCHES)
drivetrain.stop()
conveyor.spin(FORWARD)
wait(1, SECONDS)
conveyor.stop()
But it just does 2 360s when it gets to this line of code:
drivetrain.turn_for(RIGHT, 90, DEGREES)
Is there anyone that knows how to fix this? Thanks!
Does it turn to the right (clockwise) ?
are you using an inertial sensor ?
It is turning right, and no, I am not using any sensors.
Do you want the robot config? Maybe there’s a problem with that.
Then it will be using motor encoders, the drivetrain setup is very important, the gearing (which users often get backwards), wheel size etc. One measurement to be careful of is the wheelbase, see details in these posts about the clawbot.
Wheelbase really depends on which wheels are being driven, just two or all four.
for example, this is V5 clawbot that just drives the front two wheels, wheelbase is measured using the center of rotation in this case.
[image]
I didn’t explain the diagram, should have done that.
and this only applies when not using the inertial sensor for turns.
The calculation to determine how to turn the robot a given number of degrees uses three parameters (well, and gearing but I’m ignoring that here)
wheel circumference (c)
trackwidth, the distance between the wheels, (t)
wheelbase (b)
The wheelbase is where the difficulty comes in, it may be the distance between the wheel axles, but for a robot that, for example, only driv…
Thank you @jpearman ! I have one more question. (This is my first year doing Python with VEX, so sorry for all of the questions)
I asked some mentors, and they said that the robot configuration looked wrong. Can you verify if this new one is more realistic?
# Robot config
left_motor_a = Motor(Ports.PORT18, GearSetting.RATIO_18_1, True)
left_motor_b = Motor(Ports.PORT10, GearSetting.RATIO_18_1, True)
left_drive_smart = MotorGroup(left_motor_a, left_motor_b)
right_motor_a = Motor(Ports.PORT12, GearSetting.RATIO_18_1, False)
right_motor_b = Motor(Ports.PORT1, GearSetting.RATIO_18_1, False)
right_drive_smart = MotorGroup(right_motor_a, right_motor_b)
drivetrain = DriveTrain(left_drive_smart, right_drive_smart, 101.6, 101.6, 355.6, MM, 0.6)
controller_1 = Controller(PRIMARY)
intake_motor_a = Motor(Ports.PORT20, GearSetting.RATIO_18_1, False)
intake_motor_b = Motor(Ports.PORT11, GearSetting.RATIO_18_1, True)
intake = MotorGroup(intake_motor_a, intake_motor_b)
conveyor = Motor(Ports.PORT19, GearSetting.RATIO_18_1, False)
Here is the old one too (forgot to add that)
# Robot configuration code
left_motor_a = Motor(Ports.PORT18, GearSetting.RATIO_18_1, True)
left_motor_b = Motor(Ports.PORT10, GearSetting.RATIO_18_1, True)
left_drive_smart = MotorGroup(left_motor_a, left_motor_b)
right_motor_a = Motor(Ports.PORT12, GearSetting.RATIO_18_1, False)
right_motor_b = Motor(Ports.PORT1, GearSetting.RATIO_18_1, False)
right_drive_smart = MotorGroup(right_motor_a, right_motor_b)
drivetrain = DriveTrain(left_drive_smart, right_drive_smart, 299.24, 285.75, 254, MM, 0.6)
controller_1 = Controller(PRIMARY)
intake_motor_a = Motor(Ports.PORT20, GearSetting.RATIO_18_1, False)
intake_motor_b = Motor(Ports.PORT11, GearSetting.RATIO_18_1, True)
intake = MotorGroup(intake_motor_a, intake_motor_b)
conveyor = Motor(Ports.PORT19, GearSetting.RATIO_18_1, False)
Mainly where I define the drivetrain.