# differential drive vehicle in screen coords

differential drive vehicle in world frame

what would change in the kinematic model of the differential drive vehicle if i wanted to simulate it using pygame module in python ( pygame or opencv or any other one )

x_dot = (vl+vr)/2*cos(theta)

y_dot = (vl+vr)/2*sin(theta)

theta_dot = (vr-vl)/w

vr is the velocity of the right wheel

vl is the velocity of the left wheel

theta is the heading angle

it uses a screen coords system which start at the top left corner of the screen insted of the lower left my initial guess is since only the y axis is inverted then i should invert the sign of the y_dot

i hope i explained my question clearly the picture is in the link above

## 1 Answer

The kinematics equation should remain the same. The only problem I see is with the third equation which should be

theta_dot = (vr-vl)/W

What you need to consider on top of those equations since you are working with screen pixels is:

• relationship of x and y with screen pixels (units should be $$\frac{\text{x units}}{pixel}$$, $$\frac{\text{y units}}{pixel}$$ or the inverse).
• you'd need to add variables for monitoring the position (preferably floats). e.g:
x = 0.0
y = 0.0

• you'd need to integrate in time with respect to the position
x = x+ x_dot*dt
y = y+ y_dot*dt
theta = theta+ theta_dot*dt


where dt is the timestep you want to use.

• then you'd just need to redraw the vehicle at the orientation of theta (after you cast x, y to integers).
• thank you very much as for the theta_dot ( my bad i just miss writen it in the post ) , but when i execute the simulation things are bit reversed , when i increase Vr the vehicle turne to the right insted of the left so when i inverse the sign of the y_dot or write theta_dot = (vr-vl )/w insted of (vl-vr) /w things seem to workout well , my only explanation for this is the frame change between the world and screen – zed_eln Nov 16 '20 at 14:36
• the equations are written with x positive to the right, and y upwards. however the screen uses y- downwards as positive. That makes the two be reversed. – NMech Nov 16 '20 at 20:20