I started building my own flywheel inverted pendulum (i'm using a standard PID controller for the balancing).

I came across many articles regarding the differential equation of the pendulum.

Most article develop the motion equation using the Euler–Lagrange, few chose the Newtonian way.

What I cant figure out is the definition of the torque that all Euler–Lagrange articles made:

image 1 -

https://www.dropbox.com/s/2ijg9tu2aj3t12w/1.PNG?dl=0
image 2 -

https://www.dropbox.com/s/n09hxwwf51dbj4f/2.PNG?dl=0
Why is the torque for the wheel different from the rod?

why isn't the torque a single value given by the motor mounted on the wheel?

I would expect it to be the same torque only in the reversed direction like in a Newtonian development:

image 3 -

https://www.dropbox.com/s/eog1da7j4d8tecy/3.PNG?dl=0
Please help