赞
踩
车辆动力学模型是描述汽车运动规律的微分方程,它通常基于牛顿第二定律(F=ma)来推导。在这个模型中,车辆的运动受到多种力的影响,包括驱动力、制动力、阻力和转弯力等。
RK4(Runge-Kutta 4阶方法)是一种用于解决常微分方程的数值方法,以下是对其的详细解释:
- def rk4(func: Callable, state: np.ndarray, dt: float = 0.01, t: float = 0, **kwargs):
- """
- single-step fourth-order numerical integration (RK4) method
- func: system of first order ODEs
- state: current state vector [y1, y2, y3, ...]
- dt: discrete time step size
- t: current time
- **kwargs: additional parameters for ODE system
- returns: y evaluated at time k+1
- """
-
- # evaluate derivative at several stages within time interval
- f1 = func(t, state, **kwargs)
- f2 = func(t + dt / 2, state + (f1 * (dt / 2)), **kwargs)
- f3 = func(t + dt / 2, state + (f2 * (dt / 2)), **kwargs)
- f4 = func(t + dt, state + (f3 * dt), **kwargs)
- return state + (dt / 6) * (f1 + (2 * f2) + (2 * f3) + f4)
-
-
- class BicycleVehicle(Vehicle):
- """
- A dynamical bicycle model, with tire friction and slipping.
- See Chapter 2 of Lateral Vehicle Dynamics. Vehicle Dynamics and Control. Rajamani, R. (2011)
- """
-
- MASS: float = 1 # [kg]
- LENGTH_A: float = Vehicle.LENGTH / 2 # [m]
- LENGTH_B: float = Vehicle.LENGTH / 2 # [m]
- INERTIA_Z: float = (
- 1 / 12 * MASS * (Vehicle.LENGTH**2 + Vehicle.WIDTH**2)
- ) # [kg.m2]
- FRICTION_FRONT: float = 15.0 * MASS # [N]
- FRICTION_REAR: float = 15.0 * MASS # [N]
-
- MAX_ANGULAR_SPEED: float = 2 * np.pi # [rad/s]
- MAX_SPEED: float = 15 # [m/s]
-
- def __init__(
- self, road: Road, position: Vector, heading: float = 0, speed: float = 0
- ) -> None:
- super().__init__(road, position, heading, speed)
- self.lateral_speed = 0
- self.yaw_rate = 0
- self.theta = None
- self.A_lat, self.B_lat = self.lateral_lpv_dynamics()
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。