# State Space Modeling nonlinear terms of vehicle’s longitudinal motion

My project is to build a software to help drivers achieve ecodriving thanks to optimal control based advices. Consequently, to feed a linear quadratic regulator, vehicle longitudinal equation of motion should be transformed into a state space form.

Considering a state having :

\begin{align*} & \dot{s} = v\\ & \dot{v} = \mathit{u}_{t} - \mathit{u}_{b} - \frac{1}{m} 0.5 \mathit{\rho}_{air} A \mathit{C}_{d}v^2 - g(sin \theta(s) + \mathit{C}_{rr} cos \theta(s))\\ \\ \end{align*}

where

$$\mathit{u}_{t}$$ is tractive acceleration

$$\mathit{u}_{B}$$ is braking acceleration

$$m$$ is vehicle mass

$$\mathit{\rho}_{air}$$ is air density

$$A$$ is the vehicle frontal area

$$\mathit{C}_{d}$$ is the aerodynamic drag coefficient

$$v$$ is vehicle velocity

$$g$$ is gravity

$$\theta(s)$$ is road grade at position s

$$\mathit{C}_{rr}$$ is coefficient of rolling

How to linearize nonlinear terms $$sin \theta(s)$$, $$cos \theta(s)$$ and $$v^2$$ ?

Consider the nonlinear state space system $$\dot{x} = f(x,u),$$ with state $$x(t) \in \mathbb{R}^n$$ and input $$u(t) \in \mathbb{R}^k$$. The linearized dynamics around the selected operating point $$\left(x_0, u_0\right)$$ are then given by $$\dot{\tilde{x}} = A\tilde{x} + B\tilde{u},$$ with $$\tilde{x}(t) = x(t) - x_0$$ and $$\tilde{u}(t) = u(t) - u_0$$, $$A = \frac{\partial f(x_0,u_0)}{\partial x}$$ and $$B = \frac{\partial f(x_0,u_0)}{\partial u}$$.
In your case, I would use the state vector $$x = \begin{bmatrix}s \\ v\end{bmatrix}$$ and input vector $$u = \begin{bmatrix} u_t \\ u_B \\ \theta \end{bmatrix}$$.