Example #1
0
 def change_rudder_angle(self, delta_rudder_angle):
     """Method to change the rudder angle by a given delta_rudder_angle.
     Keyword arguments:
     delta_rudder_angle -- The change in angle to be processed
     Side effects:
     Calls the rudder_turn_to method with the constrained angle
     """
     self.turn_to(
         constrain(self.current_rudder_angle + delta_rudder_angle,
                   self.full_port_angle, self.full_starboard_angle))
Example #2
0
    def trim_in_by(self, degrees_in):
        """Method to change the sail angle by a given delta_sail_angle.

        Keyword arguments:
        delta_sail_angle -- The change in angle to be processed

        Side effects:
        Calls the sail_turn_to method with the constrained angle
        """
        self.trim_boom_to(
            constrain(self.current_boom_angle + degrees_in, 0,
                      self.max_boom_angle))
Example #3
0
 def turn_to(self, rudder_angle):
     """Method to send the rudder to a given angle. Uses rudder_angle_to_servo_angle
     to get the servo angle and sends that to the regular turn_to method.
     Keyword arguments:
     rudder_angle -- The desired angle of the rudder
     Side effects:
     Calls the turn_to method of the servo class
     """
     constrained_rudder_angle = constrain(rudder_angle,
                                          self.full_port_angle,
                                          self.full_starboard_angle)
     self.servo.turn_to(
         self.rudder_angle_to_servo_angle(constrained_rudder_angle))
     self.current_rudder_angle = constrained_rudder_angle
Example #4
0
    def turn_to(self, angle):
        """Method to send the servo to the given angle.

        Automatically constrains the angle to the servo's given limits.

        Keyword arguments:
        angle -- The desired angle

        Side effects:
        - Sets the duty cycle using the calc_duty_cycle()
        - Sends the physical servo to the angle
        - Sets the current_angle to the new angle
        """
        constrained_angle = constrain(angle, self.full_left_angle,
                                      self.full_right_angle)
        self.pwm_pin.set_duty_cycle(self.calc_duty_cycle(constrained_angle))
        self.current_angle = constrained_angle
Example #5
0
    def trim_boom_to(self, boom_angle):
        """Sends the boom to a given angle.

        Uses sail_angle_to_servo_angle to get the servo angle and sends that to
        the servo's turn_to method.

        Keyword arguments:
        sail_angle -- The desired boom angle

        Returns:
        The constrained boom angle that the servo was set to

        Side effects:
        Calls the turn_to method of the servo class
        """
        constrained_boom_angle = constrain(boom_angle, 0, self.max_boom_angle)
        self.servo.turn_to(
            self.boom_angle_to_servo_angle(constrained_boom_angle))
        self.current_boom_angle = constrained_boom_angle
        return constrained_boom_angle
Example #6
0
    def trim_boom_to(self, boom_angle):
        """Sends the boom to a given angle.

        Uses sail_angle_to_motor_angle to get the motor angle and sends that to
        the motor's turn_to method.

        Keyword arguments:
        sail_angle -- The desired boom angle

        Returns:
        The constrained boom angle that the motor was set to

        Side effects:
        Calls the turn_to method of the motor class
        """
        constrained_boom_angle = constrain(boom_angle, 0, self.max_boom_angle)
        pub.sendMessage(
            "turn sail to",
            sail_ang=self.boom_angle_to_motor_angle(constrained_boom_angle))
        self.current_boom_angle = constrained_boom_angle
        return constrained_boom_angle