I am currently working on a balancing robot project, which features fairly low-cost sensors such as an 9-Dof IMU with the measurement states
$\textbf{x}_\text{IMU} = \left[a_x, a_y, a_z, g_x, g_y, g_z, m_x,m_y,m_z \right]^\text{T}$.
Currently I use the accelerometer and gyroscope readings, fused by a complimentary filter to get the angular deviation of the robot's upright (stable) position. The magnetometer values are tilt-compensated and yield the robots orientation with respect to the earth-magnetic field (awful when close to magnetic distortion). Furthermore I have pretty decent rotational encoders mounted on the wheels which deliver information on a wheel's velocity.
$\textbf{x}_\text{ENC} = \left[v_l,v_r\right]^\text{T}$.
Given these measurements i want to try to get the robots pose (position + heading).
$\textbf{x}_\text{ROB} = \left[x,y,\theta\right]^\text{T}$
I do have minor theoretical knowledge on EKF or KF, but it is not sufficient for me to actually derive a practical implementation. Note that my computational resources are fairly limited (Raspberry Pi B+ with RTOS) and that I want to avoid using ROS or any other non-std libs. Can anybody help me on how to actually approach this kind of problem?