예제 #1
0
    def lim_accel(self, ls, state): #zeigt, was das Fzg kann
        k = ls.trackmap.curvature[ls.counter]
        cp = ls.counter in ls.critical_points
        ay = np.abs(state.speed**2*k)

        ay_max = self.lim_ay(state.speed)
        if (ay <= ay_max) | cp:
            if cp:
                ay_norm = np.array([[1.0]])
            else:
                ay_norm = ay/ay_max
                
            if ls.dir == 1:
                ax = self.lim_f(np.concatenate([state.speed, ay_norm],axis=1))  #forward
            else:
                ax = self.lim_r(np.concatenate([state.speed, ay_norm],axis=1))  #backward

            ls.run = True

        else:   #no CPs
            ax = 0
            ls.run = False

        state.speed = np.sqrt(state.speed**2 + 2 * ax * ls.trackmap.ds * ls.dir)
        state.AccelX = ax
        
        #Initialize motor
        Motor = motor_TDL(self.gearRatio, self.tireRadius, self.CoG_X, self.m, self.CoP_X, self.C_la, self.rho, self.fr, self.Lift2Drag, self.DriveType)
        self.DrivingRes = Motor.Driving_Resistances(state.speed)    #calculate driving resistances
        
        return state
예제 #2
0
    def AccelTime(self):
        VehicleSpeed = np.array([np.linspace(0.0001, 60, 200), np.zeros(200)])
        VehicleSpeed = np.transpose(
            VehicleSpeed).tolist()  #calculate vehicle speed

        #initialize vehicle motor
        Motor = motor_TDL(self.Vehicle.gearRatio, self.Vehicle.tireRadius,
                          self.Vehicle.CoG_X, self.Vehicle.m,
                          self.Vehicle.CoP_X, self.Vehicle.C_la,
                          self.Vehicle.rho, self.Vehicle.fr,
                          self.Vehicle.Lift2Drag, self.Vehicle.DriveType)
        ax_Motor = Motor.ax_motor(VehicleSpeed)  #calculate acceleration in x

        speed = np.linspace(0.0001, 60, 200)
        a = interpolate.interp1d(speed,
                                 ax_Motor,
                                 bounds_error=False,
                                 fill_value=0)

        #set start lists
        v = [0.0001]
        s = [0]
        t = [0]
        delta_t = 0.005
        t_end = 6

        while t[-1] <= t_end:  #calculate acceleration, speed and distance
            a_v = a(v[-1])
            v_t = a_v * delta_t + v[-1]
            s_t = 0.5 * a_v * delta_t**2 + v[-1] * delta_t + s[-1]

            v.append(v_t)
            s.append(s_t)
            t.append(t[-1] + delta_t)

        index2 = np.nonzero(np.asarray(s) <= 75)
        index_75m = np.max(index2)  #get last value from distance array

        return t[index_75m]  #get time value for last distance value
예제 #3
0
    def lim_accel(self, ls, state):
        k = ls.trackmap.curvature[[ls.counter]]
        cp = ls.counter in ls.critical_points
        ay = np.abs(state.speed**2 * k)
        if (ay <= self.ay_max) | cp:
            if cp:
                ay = self.ay_max

            if ls.dir == 1:
                ax = ((1 - (ay**2 / self.ay_max**2)) * self.ax_max**2)**0.5
            else:
                if self.DriveType == '2WD':
                    ax = (-2) * (
                        (1 - (ay**2 / self.ay_max**2)) * self.ax_max**2)**0.5
                if self.DriveType == '4WD':
                    ax = (-1) * (
                        (1 - (ay**2 / self.ay_max**2)) * self.ax_max**2)**0.5

            ls.run = True

        else:
            ax = 0
            ls.run = False

        state.speed = np.sqrt(state.speed**2 +
                              2 * ax * ls.trackmap.ds * ls.dir)
        state.AccelX = ax

        #Initialize motor
        Motor = motor_TDL(self.gearRatio, self.tireRadius, self.CoG_X, self.m,
                          self.CoP_X, self.C_la, self.rho, self.fr,
                          self.Lift2Drag, self.DriveType)
        self.DrivingRes = Motor.Driving_Resistances(
            state.speed)  #calculate driving resistances

        return state