dojo-sim / Dojo.jl

A differentiable physics engine for robotics
MIT License
294 stars 25 forks source link

Understanding Controller and applying general force on mechanism #64

Closed danielewis579 closed 1 year ago

danielewis579 commented 1 year ago

When going over the API I found a section Defining a Controller, at this section there is an example of single pendulum swing-up. This example gives the general idea of how to work with the controller but it’s too simple. what I don’t understand is this:

If you could provide clearer documentation and some additional example it'll be great.

Thank in ahead and great gob on this package.

janbruedigam commented 1 year ago

I've updated the defining a controller example to use a cartpole (https://dojo-sim.github.io/Dojo.jl/dev/creating_simulation/define_controller.html) The updated explanation should explain how to set inputs for individual joints and apply external forces to individual bodies. In general, you are applying force/torques, unless you specify a different input_scaling in the Mechanism constructor, e.g., to apply impulses. For the cartpole, the minimal state is [x,v,theta,omega], where x, v are the positon and velocity of the cart, and theta, omega are the angle and velocity of the pole. Possible inputs are a force (in y-direction) on the cart, or a torque (around the x-axis) on the pole. If you set an input [f,t], the first input is the force on the cart, the second the torque on the pole.