示例#1
0
def turn_left_by_degree(angle, speed = 40, index = 1):
    global rocky_stop_flag
    if (not type_check(angle, int, float)) or (not type_check(speed, int, float)):
        return
    if angle < 0:
        turn_right_by_degree(-angle, speed)
        return
    speed = math.fabs(speed)
    angle_a = 50 
    now_angle = motion_sensor_o.get_attitude(2)
    turn_angle = angle * math.cos(angle_a / 180 * 3.1415926)
    dis_angle = now_angle + turn_angle

    rocky_stop_flag = False
    while True: 
        delt = motion_sensor_o.get_attitude(2) - dis_angle
        if delt <= -5:
            drive(-speed, speed)
        if delt > -5 and delt < -2:
            drive(-speed * 0.5, speed * 0.5)
        elif delt > -1:
            break
        if rocky_stop_flag:
            rocky_stop_flag = False
            break
    drive(0, 0)
示例#2
0
 def get_yaw(self):
     ret = motion_sensor_o.get_attitude(YAW_ID)
     while ret < 0:
         ret = ret + 360
     while ret > 360:
         ret = ret % 360
     return round(int(ret))
示例#3
0
 def get_pitch(self):
     ret = motion_sensor_o.get_attitude(PITCH_ID)
     return round(int(ret))
示例#4
0
 def get_roll(self):
     ret = motion_sensor_o.get_attitude(ROLL_ID)
     return round(int(ret))