Turn to the left, staying on the spot

        :param angle_degrees: How far to turn (degrees)
        :param rate: The trurning speed (degrees/second)
        :return:
326507
def turn_left(self, angle_degrees, rate=RATE):
        
        flight_time = angle_degrees / rate

        self.start_turn_left(rate)
        time.sleep(flight_time)
        self.stop()
838310
def orient(mag_azimuth, field_dip, or_con):
    
    or_con = str(or_con)
    if mag_azimuth == -999:
        return "", ""
    if or_con == "1":  # lab_mag_az=mag_az;  sample_dip = -dip
        return mag_azimuth, -field_dip
    if or_con == "2":
        return mag_azimuth - 90., -field_dip
    if or_con == "3":  # lab_mag_az=mag_az;  sample_dip = 90.-dip
        return mag_azimuth, 90. - field_dip
    if or_con == "4":  # lab_mag_az=mag_az;  sample_dip = dip
        return mag_azimuth, field_dip
    if or_con == "5":  # lab_mag_az=mag_az;  sample_dip = dip-90.
        return mag_azimuth, field_dip - 90.
    if or_con == "6":  # lab_mag_az=mag_az-90.;  sample_dip = 90.-dip
        return mag_azimuth - 90., 90. - field_dip
    if or_con == "7":  # lab_mag_az=mag_az;  sample_dip = 90.-dip
        return mag_azimuth - 90., 90. - field_dip
    print("Error in orientation convention")
546964
def on_timer(self, event):
        

        # Set relative speed and acceleration
        rel_speed = event.dt
        rel_acc = 0.1

        # Get what's forward
        pf, pr, pl, pu = self._get_directions()

        # Increase speed through acceleration
        # Note that self._speed is relative. We can balance rel_acc and
        # rel_speed to get a nice smooth or direct control
        self._speed += self._acc * rel_acc

        # Reduce speed. Simulate resistance. Using brakes slows down faster.
        # Note that the way that we reduce speed, allows for higher
        # speeds if keys ar bound to higher acc values (i.e. turbo)
        reduce = np.array([0.05, 0.05, 0.05, 0.1, 0.1, 0.1])
        reduce[self._brake > 0] = 0.2
        self._speed -= self._speed * reduce
        if np.abs(self._speed).max() < 0.05:
            self._speed *= 0.0

        # --- Determine new position from translation speed

        if self._speed[:3].any():

            # Create speed vectors, use scale_factor as a reference
            dv = np.array([1.0/d for d in self._flip_factors])
            #
            vf = pf * dv * rel_speed * self._scale_factor
            vr = pr * dv * rel_speed * self._scale_factor
            vu = pu * dv * rel_speed * self._scale_factor
            direction = vf, vr, vu

            # Set position
            center_loc = np.array(self._center, dtype='float32')
            center_loc += (self._speed[0] * direction[0] +
                           self._speed[1] * direction[1] +
                           self._speed[2] * direction[2])
            self._center = tuple(center_loc)

        # --- Determine new orientation from rotation speed

        roll_angle = 0

        # Calculate manual roll (from speed)
        if self._speed[3:].any():
            angleGain = np.array([1.0, 1.5, 1.0]) * 3 * math.pi / 180
            angles = self._speed[3:] * angleGain

            q1 = Quaternion.create_from_axis_angle(angles[0], -1, 0, 0)
            q2 = Quaternion.create_from_axis_angle(angles[1], 0, 1, 0)
            q3 = Quaternion.create_from_axis_angle(angles[2], 0, 0, -1)
            q = q1 * q2 * q3
            self._rotation1 = (q * self._rotation1).normalize()

        # Calculate auto-roll
        if self.auto_roll:
            up = {'x': (1, 0, 0), 'y': (0, 1, 0), 'z': (0, 0, 1)}[self.up[1]]
            up = np.array(up) * {'+': +1, '-': -1}[self.up[0]]

            def angle(p1, p2):
                return np.arccos(p1.dot(p2))
            #au = angle(pu, (0, 0, 1))
            ar = angle(pr, up)
            al = angle(pl, up)
            af = angle(pf, up)
            # Roll angle that's off from being leveled (in unit strength)
            roll_angle = math.sin(0.5*(al - ar))
            # Correct for pitch
            roll_angle *= abs(math.sin(af))  # abs(math.sin(au))
            if abs(roll_angle) < 0.05:
                roll_angle = 0
            if roll_angle:
                # Correct to soften the force at 90 degree angle
                roll_angle = np.sign(roll_angle) * np.abs(roll_angle)**0.5
                # Get correction for this iteration and apply
                angle_correction = 1.0 * roll_angle * math.pi / 180
                q = Quaternion.create_from_axis_angle(angle_correction,
                                                      0, 0, 1)
                self._rotation1 = (q * self._rotation1).normalize()

        # Update
        if self._speed.any() or roll_angle or self._update_from_mouse:
            self._update_from_mouse = False
            self.view_changed()
206909
def turn_right():
    """"""
    motors.left_motor(-150)  # spin CCW
    motors.right_motor(-150)  # spin CCW
    board.sleep(0.5)
    motors.brake();
    board.sleep(0.1)
1225571
def smooth_angle_channels(self, channels):
        """"""
        for vertex in self.vertices:
            for col in vertex.meta['rot_ind']:
                if col:
                    for k in range(1, channels.shape[0]):
                        diff=channels[k, col]-channels[k-1, col]
                    if abs(diff+360.)<abs(diff):
                        channels[k:, col]=channels[k:, col]+360.
                    elif abs(diff-360.)<abs(diff):
                        channels[k:, col]=channels[k:, col]-360.
58680
def rotate_z(self, angle):
        
        axis_rotation(self.points, angle, inplace=True, axis='z')
828083
def rotate_x(self, angle):
        
        axis_rotation(self.points, angle, inplace=True, axis='x')
810658
def angle_and_rate(self):
        
        self._ensure_mode(self.MODE_GYRO_G_A)
        return self.value(0), self.value(1)
116347
function turnToDegrees (turn, speed, degrees) {
  turn = Math.max(Math.min(turn, 100), -100)

  var opts = turnToSpeeds(turn, speed)
  opts.left = { speed: opts.left }
  opts.right = { speed: opts.right }

  var reducedSpeed = otherSpeed(turn, speed)
  var reducedDegrees = Math.round((reducedSpeed / speed) * degrees)

  opts.left.degrees = turn < 0 ? reducedDegrees : degrees
  opts.right.degrees = turn > 0 ? reducedDegrees : degrees

  return opts
}
671229
def circmean(dts, axis=2):
    """"""
    return np.exp(1.0j * dts).mean(axis=axis).angle()
1034948
def cmd_gimbal_rate(self, args):
        ''''''
        if len(args) != 3:
            print("usage: gimbal rate ROLL PITCH YAW")
            return
        (roll, pitch, yaw) = (float(args[0]), float(args[1]), float(args[2]))
        self.master.mav.gimbal_control_send(self.target_system,
                                            mavutil.mavlink.MAV_COMP_ID_GIMBAL,
                                            radians(roll),
                                            radians(pitch),
                                            radians(yaw))
411751
def dstr(self, places=1, warn=True):
        """"""
        if warn and self.preference != 'degrees':
            raise WrongUnitError('dstr')
        if self.radians.size == 0:
            return '<Angle []>'
        degrees = self._degrees
        signed = self.signed
        shape = getattr(degrees, 'shape', ())
        if shape and shape != (1,):
            return "{0} values from {1} to {2}".format(
                len(degrees),
                _dstr(min(degrees), places, signed),
                _dstr(max(degrees), places, signed),
                )
        return _dstr(degrees, places, signed)
162621
public static int rotateCCW (int direction, int ticks)
    {
        for (int ii = 0; ii < ticks; ii++) {
            direction = FINE_CCW_ROTATE[direction];
        }
        return direction;
    }
1262714
def possible_moves(self, position):
        
        for direction in [0, 1, 2, 3]:
            angles = self._rotate_direction_ninety_degrees(direction)
            for angle in angles:
                try:
                    end_loc = self.location.shift(angle).shift(direction).shift(direction)
                    if position.is_square_empty(end_loc):
                        status = notation_const.MOVEMENT
                    elif not position.piece_at_square(end_loc).color == self.color:
                        status = notation_const.CAPTURE
                    else:
                        continue

                    yield Move(end_loc=end_loc,
                               piece=self,
                               status=status,
                               start_loc=self.location)

                except IndexError:
                    pass
804029
def on_arc_left(self, speed, radius_mm, distance_mm, brake=True, block=True):
        
        self._on_arc(speed, radius_mm, distance_mm, brake, block, False)
228209
def start_circle_left(self, radius_m, velocity=VELOCITY):
        
        circumference = 2 * radius_m * math.pi
        rate = 360.0 * velocity / circumference

        self._set_vel_setpoint(velocity, 0.0, 0.0, -rate)
1098324
def smallest_signed_angle(source, target):
    """"""
    dth = target - source
    dth = (dth + np.pi) % (2.0 * np.pi) - np.pi
    return dth