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

        Args:
            activationCode [str]: activation string to determine which damper_spring 
                                  system to be used in the admittance system.
    '''
    stopCondition = False
    damper_spring = admittance2_constants(activationCode[2]) # assign which damper-spring system
    sysModel = admittance_type(damper_spring, freqSample, force_sensor) # initialize dynamic system model
    #    sysModel.set_initial_position(round(distance_sensor.distance*1000, 0))

    
    print("ACTIVATION CODE: ", activationCode)
    print("training mode: full-active")
    print("training mode: isotonic")
    print("Spring damper constant: ", admittance2_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)    
    start_code = time.time()
    
    time_count = 0.0
    start_us = time.time()
    print("Force   position   time")
    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 ((capture_time-start_us)>under_sample_time):
            print(round(sysModel.force_in0,2),
                  "   ", round(sysModel.pos_now,2),
                  "   ", round(capture_time-start_code,2))
            
            '''("Input Force: ", round(sysModel.force_in0,2),
                  " N. Target position: ", round(sysModel.pos_now,2),
                  " mm. Time: ", capture_time-start_code,
                  " s. One loop execution: ", round(time.time()-start_loop, 5),
                  " s. Sample time: ", sample_period, " s.") #time.time()-start_loop, 5'''
            start_us = time.time()
            
        if command == "-s":
            stopCondition = True
           
        
        time.sleep(sample_period - (time.time()-start_loop))
 
    Full active-strength exercise-isotonic training
        Constructing Admittance haptic system difference equation for
        resistance training.

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

activationCode [str]: activation string to determine which damper_spring
system to be used in the admittance system.
Full active - strength exercise - isotonic training Constructing Admittance haptic system difference equation for resistance training . activationCode [ str ] : activation string to determine which damper_spring system to be used in the admittance system .
def isotonic_training(activationCode, force_sensor): 
    stopCondition = False
    damper_spring = admittance2_constants(activationCode[2]) 
    sysModel = admittance_type(damper_spring, freqSample, force_sensor) 
    print("ACTIVATION CODE: ", activationCode)
    print("training mode: full-active")
    print("training mode: isotonic")
    print("Spring damper constant: ", admittance2_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)    
    start_code = time.time()
    time_count = 0.0
    start_us = time.time()
    print("Force   position   time")
    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 ((capture_time-start_us)>under_sample_time):
            print(round(sysModel.force_in0,2),
                  "   ", round(sysModel.pos_now,2),
                  "   ", round(capture_time-start_code,2))
            start_us = time.time()
        if command == "-s":
            stopCondition = True
        time.sleep(sample_period - (time.time()-start_loop))
def isotonic_training ( activationCode , force_sensor ) : stopCondition = False damper_spring = admittance2_constants ( activationCode [ 2 ] ) sysModel = admittance_type ( damper_spring , freqSample , force_sensor ) print ( "ACTIVATION CODE: " , activationCode ) print ( "training mode: full-active" ) print ( "training mode: isotonic" ) print ( "Spring damper constant: " , admittance2_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 ) start_code = time . time ( ) time_count = 0.0 start_us = time . time ( ) print ( "Force   position   time" ) 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 ( ( capture_time - start_us ) > under_sample_time ) : print ( round ( sysModel . force_in0 , 2 ) , "   " , round ( sysModel . pos_now , 2 ) , "   " , round ( capture_time - start_code , 2 ) ) '''("Input Force: ", round(sysModel.force_in0,2),
                  " N. Target position: ", round(sysModel.pos_now,2),
                  " mm. Time: ", capture_time-start_code,
                  " s. One loop execution: ", round(time.time()-start_loop, 5),
                  " s. Sample time: ", sample_period, " s.") #time.time()-start_loop, 5''' start_us = time . time ( ) if command == "-s" : stopCondition = True time . sleep ( sample_period - ( time . time ( ) - start_loop ) )
Full active-strength exercise-isotonic training
Constructing Admittance haptic system difference equation for
resistance training.
Full active - strength exercise - isotonic training Constructing Admittance haptic system difference equation for resistance training .
''' 
    Full active-strength exercise-isotonic training
        Constructing Admittance haptic system difference equation for
        resistance training.

        Args:
            activationCode [str]: activation string to determine which damper_spring 
                                  system to be used in the admittance system.
    ''' # assign which damper-spring system # initialize dynamic system model #    sysModel.set_initial_position(round(distance_sensor.distance*1000, 0)) # 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" '''("Input Force: ", round(sysModel.force_in0,2),
                  " N. Target position: ", round(sysModel.pos_now,2),
                  " mm. Time: ", capture_time-start_code,
                  " s. One loop execution: ", round(time.time()-start_loop, 5),
                  " s. Sample time: ", sample_period, " s.") #time.time()-start_loop, 5'''
activationCode
force_sensor