#                                  name = "Tilt_Completion")
#    
#    pan_completion = task_share.Share ('f', thread_protect = False, 
#                                  name = "Pan_Completion")

    # Create any Class task objects (change pins...)
    
    pan_encoder = encoder_task_func.Encoder_Task(pan_position, 4, 
                                     pyb.Pin.board.PB6, pyb.Pin.board.PB7)
    
    tilt_IMU = IMU_task_func.IMU_Task(tilt_angle) #what to put here 0 for tilt angle
    
    #0.02
    pan_motor = motor_task_func.Motor_Task(pan_position, 
                                           pan_coords, 3, 
                                           pyb.Pin.board.PA10, 
                                           pyb.Pin.board.PB4,
                                           pyb.Pin.board.PB5, 0.01, .0115, 500)
    #1.2
    tilt_motor = motor_task_func.Motor_Task(tilt_angle, 
                                            tilt_coords, 5,
                                            pyb.Pin.board.PC1, 
                                            pyb.Pin.board.PA0, 
                                            pyb.Pin.board.PA1, 2.2, 0.145, 200)
    
    turret_hub = turret_hub_task_func.Turret_Hub_Task(pan_position, tilt_angle, pan_coords,
                                                      tilt_coords, FEED_BULLETS, WINDUP_GUN)

    nerf_gun = nerf_task_func.Nerf_Task(WINDUP_GUN, FEED_BULLETS, pyb.Pin.board.PC7, pyb.Pin.board.PC6)

    ####################################################################
    ########################## TASK OBJECTS ############################
    ####################################################################

    pan_encoder = encoder_task_func.Encoder_Task(pan_position, 4,
                                                 pyb.Pin.board.PB6,
                                                 pyb.Pin.board.PB7)

    tilt_IMU = IMU_task_func.IMU_Task(
        tilt_angle)  #what to put here 0 for tilt angle

    #0.02
    pan_motor = motor_task_func.Motor_Task(pan_position, pan_coords, 3,
                                           pyb.Pin.board.PA10,
                                           pyb.Pin.board.PB4,
                                           pyb.Pin.board.PB5, 0.0075, 0.0065,
                                           0.00, 1000)
    #1.2
    tilt_motor = motor_task_func.Motor_Task(tilt_angle, tilt_coords, 5,
                                            pyb.Pin.board.PC1,
                                            pyb.Pin.board.PA0,
                                            pyb.Pin.board.PA1, 1.25, 0.135, 0,
                                            175)

    turret_hub = turret_hub_task_func.Turret_Hub_Task(pan_position, tilt_angle,
                                                      pan_coords, tilt_coords,
                                                      FEED_BULLETS, WINDUP_GUN)

    nerf_gun = nerf_task_func.Nerf_Task(WINDUP_GUN, FEED_BULLETS,
                                        pyb.Pin.board.PC7, pyb.Pin.board.PC6)
Exemple #3
0
    #    pan_completion = task_share.Share ('f', thread_protect = False,
    #                                  name = "Pan_Completion")

    # Create any Class task objects (change pins...)

    pan_encoder = encoder_task_func.Encoder_Task(pan_position, 4,
                                                 pyb.Pin.board.PB6,
                                                 pyb.Pin.board.PB7)

    tilt_IMU = IMU_task_func.IMU_Task(
        tilt_angle)  #what to put here 0 for tilt angle

    #0.02
    pan_motor = motor_task_func.Motor_Task(pan_position, pan_coords, 3,
                                           pyb.Pin.board.PA10,
                                           pyb.Pin.board.PB4,
                                           pyb.Pin.board.PB5, 0.005, .0125,
                                           0.001, 500)
    #1.2
    tilt_motor = motor_task_func.Motor_Task(tilt_angle, tilt_coords, 5,
                                            pyb.Pin.board.PC1,
                                            pyb.Pin.board.PA0,
                                            pyb.Pin.board.PA1, .3, 0.3, 4, 200)

    turret_hub = turret_hub_task_func.Turret_Hub_Task(pan_position, tilt_angle,
                                                      pan_coords, tilt_coords,
                                                      FEED_BULLETS, WINDUP_GUN)

    nerf_gun = nerf_task_func.Nerf_Task(WINDUP_GUN, FEED_BULLETS,
                                        pyb.Pin.board.PC7, pyb.Pin.board.PC6)
# =========================================================================== #
# ======================== Run the Turret Code ============================== #
# =========================================================================== #

if __name__ == "__main__":

    ####################################################################
    ############################ VARIABLES #############################
    ####################################################################

    ####################################################################
    ########################## TASK OBJECTS ############################
    ####################################################################

    pwm1 = motor_task_func.Motor_Task(20, 1, 5, 3, pyb.Pin.board.PA2, 2)
    pwm2 = motor_task_func.Motor_Task(20, 1, 5, 4, pyb.Pin.board.PA3, 2)
    pwm3 = motor_task_func.Motor_Task(1, 20, 8, 2, pyb.Pin.board.PC8, 2)
    pwm4 = motor_task_func.Motor_Task(1, 20, 8, 1, pyb.Pin.board.PC6, 2)
    # pwm2 = motor_task_func.Motor_Task(500, 5, 1, 3, pyb.Pin.board.PB15, 1)

    ####################################################################
    ############################## TASKS ###############################
    ####################################################################

    #Turret Hub Timing => Timing: 100 ms, Priority 1 (Lowest)
    task0 = cotask.Task(pwm1.mot_fun,
                        name='Task_0',
                        priority=1,
                        period=100,
                        profile=True,
    pan_completion = task_share.Share('f',
                                      thread_protect=False,
                                      name="Pan_Completion")

    # Create any Class task objects (change pins...)

    pan_encoder = encoder_task_func.Encoder_Task(pan_position, 4,
                                                 pyb.Pin.board.PB6,
                                                 pyb.Pin.board.PB7)

    tilt_IMU = IMU_task_func.IMU_Task(
        tilt_angle)  #what to put here 0 for tilt angle

    #0.02
    pan_motor = motor_task_func.Motor_Task(pan_completion, pan_position,
                                           pan_coords, 3, pyb.Pin.board.PA10,
                                           pyb.Pin.board.PB4,
                                           pyb.Pin.board.PB5, 0.019, 10 / 1000)
    #1.2
    tilt_motor = motor_task_func.Motor_Task(tilt_completion, tilt_angle,
                                            tilt_coords, 5, pyb.Pin.board.PC1,
                                            pyb.Pin.board.PA0,
                                            pyb.Pin.board.PA1, 10, .05 / 1000)

    turret_hub = turret_hub_task_func.Turret_Hub_Task(pan_position, tilt_angle,
                                                      pan_coords, tilt_coords,
                                                      FEED_BULLETS, WINDUP_GUN,
                                                      pan_completion,
                                                      tilt_completion)

    nerf_gun = nerf_task_func.Nerf_Task(WINDUP_GUN, FEED_BULLETS,
                                        pyb.Pin.board.PC7, pyb.Pin.board.PC6)
    # Create any Class task objects (change pins...)

    #    pan_encoder = encoder_task_func.Encoder_Task(pan_position, 4,
    #                                     pyb.Pin.board.PB6, pyb.Pin.board.PB7)

    tilt_IMU = IMU_task_func.IMU_Task(
        tilt_angle)  #what to put here 0 for tilt angle

    #    pan_motor = motor_task_func.Motor_Task(pan_completion, pan_position,
    #                                           pan_coords, 3,
    #                                           pyb.Pin.board.PA10,
    #                                           pyb.Pin.board.PB4,
    #                                           pyb.Pin.board.PB5, 0, 0)

    tilt_motor = motor_task_func.Motor_Task(tilt_completion, tilt_angle,
                                            tilt_coords, 5, pyb.Pin.board.PC1,
                                            pyb.Pin.board.PA0,
                                            pyb.Pin.board.PA1, 5, 0)

    #    turret_hub = turret_hub_task_func.Turret_Hub_Task(pan_position, tilt_angle, pan_coords,
    #                                                      tilt_coords, FEED_BULLETS, WINDUP_GUN,
    #                                                      pan_completion, tilt_completion)

    #    nerf_gun = nerf_task_func.Nerf_Task(WINDUP_GUN, FEED_BULLETS, pyb.Pin.board.PC6, pyb.Pin.board.PC7)

    # Create the tasks. If trace is enabled for any task, memory will be
    # allocated for state transition tracing, and the application will run out
    # of memory after a while and quit. Therefore, use tracing only for
    # debugging and set trace to False when it's not needed

    #    #Turret Hub Timing => Timing: 100 ms, Priority 1 (Lowest)
    #    task0 = cotask.Task (turret_hub.turret_hub_fun, name = 'Task_0', priority = 1,
                                       name="Tilt_Completion")

    pan_completion = task_share.Share('f',
                                      thread_protect=False,
                                      name="Pan_Completion")

    # Create any Class task objects (change pins...)

    pan_encoder = encoder_task_func.Encoder_Task(pan_position, 4,
                                                 pyb.Pin.board.PB6,
                                                 pyb.Pin.board.PB7)

    #    tilt_IMU = IMU_task_func.IMU_Task(tilt_angle) #what to put here 0 for tilt angle

    pan_motor = motor_task_func.Motor_Task(pan_completion, pan_position,
                                           pan_coords, 3, pyb.Pin.board.PA10,
                                           pyb.Pin.board.PB4,
                                           pyb.Pin.board.PB5, 0.02, 0)

    #    tilt_motor = motor_task_func.Motor_Task(tilt_completion, tilt_angle,
    #                                            tilt_coords, 5,
    #                                            pyb.Pin.board.PC1,
    #                                            pyb.Pin.board.PA0,
    #                                            pyb.Pin.board.PA1, 5, 0)

    #    turret_hub = turret_hub_task_func.Turret_Hub_Task(pan_position, tilt_angle, pan_coords,
    #                                                      tilt_coords, FEED_BULLETS, WINDUP_GUN,
    #                                                      pan_completion, tilt_completion)

    #    nerf_gun = nerf_task_func.Nerf_Task(WINDUP_GUN, FEED_BULLETS, pyb.Pin.board.PC6, pyb.Pin.board.PC7)

    # Create the tasks. If trace is enabled for any task, memory will be
                                      thread_protect=False,
                                      name="Pan_Completion")

    # Create any Class task objects (change pins...)

    pan_encoder = encoder_task_func.Encoder_Task(pan_position, 4,
                                                 pyb.Pin.board.PB6,
                                                 pyb.Pin.board.PB7)

    tilt_IMU = IMU_task_func.IMU_Task(
        tilt_angle)  #what to put here 0 for tilt angle

    #0.02
    pan_motor = motor_task_func.Motor_Task(pan_completion, pan_position,
                                           pan_coords, 3, pyb.Pin.board.PA10,
                                           pyb.Pin.board.PB4,
                                           pyb.Pin.board.PB5, 0.021, 0.00035,
                                           25000)
    #1.2
    tilt_motor = motor_task_func.Motor_Task(tilt_completion, tilt_angle,
                                            tilt_coords, 5, pyb.Pin.board.PC1,
                                            pyb.Pin.board.PA0,
                                            pyb.Pin.board.PA1, 1.35, 0.01,
                                            4000)

    turret_hub = turret_hub_task_func.Turret_Hub_Task(pan_position, tilt_angle,
                                                      pan_coords, tilt_coords,
                                                      FEED_BULLETS, WINDUP_GUN,
                                                      pan_completion,
                                                      tilt_completion)
Exemple #9
0
                                                    pyb.Pin.board.P,pyb.Pin.board.P)
    z_feedback = feedback_task_func.Feedback_Task(z_encoder, z_limit, z_zero,
                                                    4, pyb.Pin.board.PB6, pyb.Pin.board.PB7,
                                                    pyb.Pin.board.P,pyb.Pin.board.P)
    y_feedback = feedback_task_func.Feedback_Task(y_encoder, y_limit, y_zero,
                                                    4, pyb.Pin.board.PB6, pyb.Pin.board.PB7,
                                                    pyb.Pin.board.P,pyb.Pin.board.P)
    p_feedback = feedback_task_func.Feedback_Task(p_encoder, p_limit, p_zero,
                                                    4, pyb.Pin.board.PB6, pyb.Pin.board.PB7,
                                                    pyb.Pin.board.P,pyb.Pin.board.P)

    # Create Motor Tasks
    x_motor = motor_task_func.Motor_Task(x_params, x_enable,
                                           pyb.Pin.board.PA11,
                                           pyb.Pin.board.PB1,
                                           pyb.Pin.board.PC8,
                                           pyb.Pin.board.PC9,
                                           pyb.Pin.board.PC2,
                                           timer, channel)
    z_motor = motor_task_func.Motor_Task(z_params, z_enable,
                                           pyb.Pin.board.PB12,
                                           pyb.Pin.board.PB15,
                                           pyb.Pin.board.PC6,
                                           pyb.Pin.board.PB9,
                                           pyb.Pin.board.PC3,
                                           timer, channel)
    y_motor = motor_task_func.Motor_Task(y_params, y_enable,
                                           pyb.Pin.board.PB11,
                                           pyb.Pin.board.PB14,
                                           pyb.Pin.board.PC5,
                                           pyb.Pin.board.PA15,
Exemple #10
0
                                                  pyb.Pin.board.PA9,
                                                  pyb.Pin.board.PB4,
                                                  pyb.Pin.board.PC13, 'X ')
    # z_feedback = feedback_task_func.Feedback_Task(z_encoder, z_limit, z_zero,
    #                     2, pyb.Pin.board.PA0, pyb.Pin.board.PA1,
    #                         pyb.Pin.board.PB5, pyb.Pin.board.PA11, 'Z ')
    # y_feedback = feedback_task_func.Feedback_Task(y_encoder, y_limit, y_zero,
    #                     3, pyb.Pin.board.PA6, pyb.Pin.board.PA7,
    #                         pyb.Pin.board.PB3, pyb.Pin.board.PB2, 'Y ')
    # p_feedback = feedback_task_func.Feedback_Task(p_encoder, p_limit, p_zero,
    #                     4, pyb.Pin.board.PB6, pyb.Pin.board.PB7,
    #                         pyb.Pin.board.PA4, pyb.Pin.board.PH0, 'P ')

    # Create Motor Tasks
    x_motor = motor_task_func.Motor_Task(x_params, x_steps, x_enable, x_status,
                                         x_limit, pyb.Pin.board.PC8,
                                         pyb.Pin.board.PB1, pyb.Pin.board.PH1,
                                         pyb.Pin.board.PC2, 8, 3, 5, 3, 'X ')
    # z_motor = motor_task_func.Motor_Task(z_params, z_steps, z_enable, z_status, z_limit,
    #                 pyb.Pin.board.PC6, pyb.Pin.board.PC11, pyb.Pin.board.PA15,
    #                     pyb.Pin.board.PC3, 8, 1, 5, 1, 'Z ')
    # y_motor = motor_task_func.Motor_Task(y_params, y_steps, y_enable, y_status, y_limit,
    #                 pyb.Pin.board.PC7, pyb.Pin.board.PC5, pyb.Pin.board.PD2,
    #                     pyb.Pin.board.PC1, 8, 2, 5, 2, 'Y ')
    # p_motor = motor_task_func.Motor_Task(p_params, p_steps, p_enable, p_status, p_limit,
    #                 pyb.Pin.board.PC9, pyb.Pin.board.PA5, pyb.Pin.board.PB9,
    #                     pyb.Pin.board.PC0, 8, 4, 5, 4, 'P ')

    ####################################################################
    ############################## TASKS ###############################
    ####################################################################