Exemple #1
0
def make_circle_right(power, radius, degree):
    global O, car_width
    calibrate()
    outer_distance = ((radius + car_width / 2.0) * 2) * math.pi
    inned_distance = ((radius - car_width / 2.0) * 2) * math.pi
    outer_rotations = outer_distance / O
    inner_rotations = inned_distance / O
    inner_degrees = inner_rotations * degree
    outer_degrees = outer_rotations * degree
    ratio = inner_degrees / outer_degrees
    motorRotateDegree([power, int(power * ratio)], [int(outer_degrees), int(inner_degrees)], [PORT_A, PORT_B])
Exemple #2
0
def make_circle_left(power, radius, degree):  # radius in cm
    global O, car_width
    calibrate()
    outer_distance = (2 * radius + car_width) * math.pi
    inned_distance = (2 * radius - car_width) * math.pi
    outer_rotations = outer_distance / O
    inner_rotations = inned_distance / O
    inner_degrees = inner_rotations * degree
    outer_degrees = outer_rotations * degree
    ratio = inner_degrees / outer_degrees
    motorRotateDegree([power, int(power * ratio)], [int(outer_degrees), int(inner_degrees)], [PORT_B, PORT_A])
Exemple #3
0
def rotate_right_angle(power, angle):
    # Angle in degrees
    goal_angle_wheel = int((angle * car_width * 2) / 5.6)  # in graden
    motorRotateDegree([power, 0], [goal_angle_wheel, 0], [PORT_A, PORT_B])