python_scripts/subProgramFunctions.py
def haptic_rendering_1(self):
        '''
        Position calculation using difference equation.
            Difference equation format: 
            y[n] = a_1*y[n-1] + b_0*x[n] + b_1*x[n-1]

            in admittance term:
            X[n] = a_1*X[n-1] + b_0*F[n] + b_1*F[n-1]
            where X: position, F: force

            Args:
                NA
                    
            ADMITTANCE-type device algorithm (mass-spring-damper)
            1. read force of the user
            2. calculate target position
            3. send corresponding position to low level controller
                (in other words, send how much 
                delta position the motor must move)
            4. CHANGE virtual environment STATE 

        '''
        
        # Step 1. Read force of user and filter
        self.new_force_reading()
        self.force_data_unfiltered.append(self.force_in0_unf)
        self.force_in0 = self.LPF_first_order()
        self.force_data.append(self.force_in0)

        # Step 2. calculate target position
        position_term = self.a_i[1]*self.pos_out1
        force_term = self.b_i[0]*self.force_in0 + self.b_i[1]*self.force_in1
        self.pos_target = position_term + force_term
        
        return self.pos_target

        Position calculation using difference equation.
            Difference equation format: 
            y[n] = a_1*y[n-1] + b_0*x[n] + b_1*x[n-1]

            in admittance term:
            X[n] = a_1*X[n-1] + b_0*F[n] + b_1*F[n-1]
            where X: position, F: force

            Args:
                NA
                    
            ADMITTANCE-type device algorithm (mass-spring-damper)
            1. read force of the user
            2. calculate target position
            3. send corresponding position to low level controller
                (in other words, send how much 
                delta position the motor must move)
            4. CHANGE virtual environment STATE 

        
Position calculation using difference equation.



NA

ADMITTANCE-type device algorithm (mass-spring-damper)
1. read force of the user
2. calculate target position
3. send corresponding position to low level controller
(in other words, send how much
delta position the motor must move)
4. CHANGE virtual environment STATE
Position calculation using difference equation . NA ADMITTANCE - type device algorithm ( mass - spring - damper ) 1 . read force of the user 2 . calculate target position 3 . send corresponding position to low level controller ( in other words send how much delta position the motor must move ) 4 . CHANGE virtual environment STATE
def haptic_rendering_1(self):
        self.new_force_reading()
        self.force_data_unfiltered.append(self.force_in0_unf)
        self.force_in0 = self.LPF_first_order()
        self.force_data.append(self.force_in0)
        position_term = self.a_i[1]*self.pos_out1
        force_term = self.b_i[0]*self.force_in0 + self.b_i[1]*self.force_in1
        self.pos_target = position_term + force_term
        return self.pos_target
def haptic_rendering_1 ( self ) : self . new_force_reading ( ) self . force_data_unfiltered . append ( self . force_in0_unf ) self . force_in0 = self . LPF_first_order ( ) self . force_data . append ( self . force_in0 ) position_term = self . a_i [ 1 ] * self . pos_out1 force_term = self . b_i [ 0 ] * self . force_in0 + self . b_i [ 1 ] * self . force_in1 self . pos_target = position_term + force_term return self . pos_target
Position calculation using difference equation.
Position calculation using difference equation .
'''
        Position calculation using difference equation.
            Difference equation format: 
            y[n] = a_1*y[n-1] + b_0*x[n] + b_1*x[n-1]

            in admittance term:
            X[n] = a_1*X[n-1] + b_0*F[n] + b_1*F[n-1]
            where X: position, F: force

            Args:
                NA
                    
            ADMITTANCE-type device algorithm (mass-spring-damper)
            1. read force of the user
            2. calculate target position
            3. send corresponding position to low level controller
                (in other words, send how much 
                delta position the motor must move)
            4. CHANGE virtual environment STATE 

        ''' # Step 1. Read force of user and filter # Step 2. calculate target position
self