python_scripts/trial_prog.py
def semi_active_mode(activationCode, force_sensor):
    ''' 
    Semi active-strength exercise
        Constructing Admittance haptic system difference equation for
        ASSISTED resistance training.

        Args:
            activationCode [str]: activation string to determine which damper_spring 
                                  system to be used in the admittance system.
    '''
    stopCondition = False
    assist_level = assistive_constants(activationCode[1]) # assign assistive level of machine
    damper_spring = admittance1_constants(activationCode[2]) # assign which damper-spring system
    sysModel = admittance_type(damper_spring, freqSample, force_sensor) # initialize dynamic system model

    start_loop = time.time()
    print("ACTIVATION CODE: ", activationCode)
    print("training mode: Semi-assistive")
    print("Assistive constant: ", assistive_constants(activationCode[1]))
    print("Spring damper constant: ", admittance1_constants(activationCode[2]))
    print("System coef denumerator: ", sysModel.a_i)
    print("System coef numerator: ", sysModel.b_i)
    print(" ")
    print("waiting command")
    print(" ")

    sysModel.set_force_window(weightMeanWindow)    
    
    time_count = 0
    while not stopCondition:
        start_loop = time.time()
        # this time library attempts to make the system sampling frequency
        # consistent at about "freqSample"
        #time.sleep(abs(sample_period - ((time.time()-start_loop)%sample_period)))
        # this time library attempts to make the system sampling frequency
        # consistent at about "freqSample"
        pos_setpoint = sysModel.haptic_rendering_1()
        actual_pos = spf.command_actuator(pos_setpoint)
        sysModel.haptic_rendering_2(actual_pos)
        command = spf.serial_routine(ser_command)
        capture_time = time.time()
        if (time_count>under_sample_time):
            print("Input Force: ", round(sysModel.force_in0,2),
                  " N. Target position: ", round(sysModel.pos_now,2), " mm.")
            time_count = 0
            
        if command == "-s":
            stopCondition = True
           
        time_count = time_count + sample_period
        
        time.sleep(abs(sample_period - ((time.time()-start_loop)%sample_period)))
 
    Semi active-strength exercise
        Constructing Admittance haptic system difference equation for
        ASSISTED resistance training.

        Args:
            activationCode [str]: activation string to determine which damper_spring 
                                  system to be used in the admittance system.
    
Semi active-strength exercise
Constructing Admittance haptic system difference equation for
ASSISTED resistance training.

activationCode [str]: activation string to determine which damper_spring
system to be used in the admittance system.
Semi active - strength exercise Constructing Admittance haptic system difference equation for ASSISTED resistance training . activationCode [ str ] : activation string to determine which damper_spring system to be used in the admittance system .
def semi_active_mode(activationCode, force_sensor):
    stopCondition = False
    assist_level = assistive_constants(activationCode[1]) 
    damper_spring = admittance1_constants(activationCode[2]) 
    sysModel = admittance_type(damper_spring, freqSample, force_sensor) 
    start_loop = time.time()
    print("ACTIVATION CODE: ", activationCode)
    print("training mode: Semi-assistive")
    print("Assistive constant: ", assistive_constants(activationCode[1]))
    print("Spring damper constant: ", admittance1_constants(activationCode[2]))
    print("System coef denumerator: ", sysModel.a_i)
    print("System coef numerator: ", sysModel.b_i)
    print(" ")
    print("waiting command")
    print(" ")
    sysModel.set_force_window(weightMeanWindow)    
    time_count = 0
    while not stopCondition:
        start_loop = time.time()
        pos_setpoint = sysModel.haptic_rendering_1()
        actual_pos = spf.command_actuator(pos_setpoint)
        sysModel.haptic_rendering_2(actual_pos)
        command = spf.serial_routine(ser_command)
        capture_time = time.time()
        if (time_count>under_sample_time):
            print("Input Force: ", round(sysModel.force_in0,2),
                  " N. Target position: ", round(sysModel.pos_now,2), " mm.")
            time_count = 0
        if command == "-s":
            stopCondition = True
        time_count = time_count + sample_period
        time.sleep(abs(sample_period - ((time.time()-start_loop)%sample_period)))
def semi_active_mode ( activationCode , force_sensor ) : stopCondition = False assist_level = assistive_constants ( activationCode [ 1 ] ) damper_spring = admittance1_constants ( activationCode [ 2 ] ) sysModel = admittance_type ( damper_spring , freqSample , force_sensor ) start_loop = time . time ( ) print ( "ACTIVATION CODE: " , activationCode ) print ( "training mode: Semi-assistive" ) print ( "Assistive constant: " , assistive_constants ( activationCode [ 1 ] ) ) print ( "Spring damper constant: " , admittance1_constants ( activationCode [ 2 ] ) ) print ( "System coef denumerator: " , sysModel . a_i ) print ( "System coef numerator: " , sysModel . b_i ) print ( " " ) print ( "waiting command" ) print ( " " ) sysModel . set_force_window ( weightMeanWindow ) time_count = 0 while not stopCondition : start_loop = time . time ( ) pos_setpoint = sysModel . haptic_rendering_1 ( ) actual_pos = spf . command_actuator ( pos_setpoint ) sysModel . haptic_rendering_2 ( actual_pos ) command = spf . serial_routine ( ser_command ) capture_time = time . time ( ) if ( time_count > under_sample_time ) : print ( "Input Force: " , round ( sysModel . force_in0 , 2 ) , " N. Target position: " , round ( sysModel . pos_now , 2 ) , " mm." ) time_count = 0 if command == "-s" : stopCondition = True time_count = time_count + sample_period time . sleep ( abs ( sample_period - ( ( time . time ( ) - start_loop ) % sample_period ) ) )
Semi active-strength exercise
Constructing Admittance haptic system difference equation for
ASSISTED resistance training.
Semi active - strength exercise Constructing Admittance haptic system difference equation for ASSISTED resistance training .
''' 
    Semi active-strength exercise
        Constructing Admittance haptic system difference equation for
        ASSISTED resistance training.

        Args:
            activationCode [str]: activation string to determine which damper_spring 
                                  system to be used in the admittance system.
    ''' # assign assistive level of machine # assign which damper-spring system # initialize dynamic system model # this time library attempts to make the system sampling frequency # consistent at about "freqSample" #time.sleep(abs(sample_period - ((time.time()-start_loop)%sample_period))) # this time library attempts to make the system sampling frequency # consistent at about "freqSample"
activationCode
force_sensor