# In a Kalman filter, what should be included in the state, and what should be included in the control?

Let's say I am controlling a robot using a velocity controller. This involves specifying a target velocity for the motors, which is achieved using a PID controller (the low-level details of this PID controller are hidden from me, since it is built into the robot). I now want to use a Kalman filter to estimate the true position of the robot. In a Kalman filter, you need to define your state vector, and optionally your control input vector. What should I use as my state vector, and what should I use as my control vector?

The reason why I am unsure is due to the fact that I am using a velocity controller. So, the robot's velocity could be part of its state -- but it could also be part of the control vector.

One option is that I could define the state vector as [robot_position, robot_velocity], where robot_position is the estimated position, and robot_velocity is the target velocity from the velocity controller. And I would not use a control vector. The prediction of the next state would be (robot_position + robot_velocity * time).

Another option is that I could define the state vector as [robot_position], and then define the control vector as [robot_velocity]. The prediction of the next state would be similar to above, but that robot_velocity would come from the control vector, rather than the state vector.

A third option would be to define the state vector as [robot_position, robot_velocity], and then define the control vector as [robot_velocity]. So, both the state and control vectors include the robot's velocity. But I'm not sure how the prediction step would then be calculated -- would the robot's velocity in the next step be based on the control velocity, or the previous robot velocity? Or both?

Can somebody please explain which of these is the right approach? I'm just generally quite confused about the difference between the state and the control input, for the case where you have a controller in the loop which directly controls one of the components of the state vector.