abr / abr_control

Robotic arm control in Python
Other
417 stars 99 forks source link

Ball joint controller #89

Closed studywolf closed 2 years ago

studywolf commented 3 years ago

Adds joint space control of ball joints into the Joint controller, so that it properly handles computing distance and difference between quaternions and generating angular forces to apply. Also added some examples to test it in the Mujoco examples folder.

Currently requires users passing in a boolean list identifying which joints are ball joints to the Joint controller, e.g., quaternions=[True, True, False]. Should be able to automate this discovery so the user doesn't have to specify.

Also makes RestingConfig a subclass of Joint controller, and fixes a bug in DynamicsAdaptation where if the user only specified mean or scale neither were applied.

p3jawors commented 3 years ago

Changes LGTM and examples run. Only question is on the use_sim_state parameter for the mujoco_config and whether it should be resetting the state back to the previous value if the user passes in q with use_sim_state=False. Suggested docstring update if we do keep the resetting...

        use_sim_state: Boolean, optional (Default: True)
            If set False, the state information is provided by the user, which
            is then used to calculate the corresponding dynamics values.
            such as: inertia matrix, jacobian, etc. The state is then set back
            to the sim state prior to the user provided state.

            If set true, any q and dq values passed in to the functions are
            ignored, and the current state of the simulator is used to
            calculate all functions. This can speed up the simulation, because
            the step of resetting the state on every call is omitted.

If we remove the resetting

        use_sim_state: Boolean, optional (Default: True)
            If set False, the state information is provided by the user, which
            is then used to calculate the corresponding dynamics values,
            such as: inertia matrix, jacobian, etc. This can be useful for
            simulating sensor noise by adjusting the state prior to calculating
            the control signal.

            If set true, any q and dq values passed in to the functions are
            ignored, and the current state of the simulator is used to
            calculate all functions.

I wasn't sure how to add an uneditted doc in the review, so posting here.

Notes on the install, I had to install the following, not sure if we should add them to the readme since they're mujoco specific: sudo apt-get install libosmesa6-dev sudo apt-get install patchelf

studywolf commented 2 years ago

Looked at removing the resetting of the arm state, caused some issues with examples which would require the user to manually save the state of the arm and then reset it back after calling the config. Might be worth looking into a helper function for that, I think it can be optimized to be better. For now, though, it works with the resetting and doesn't cause any issues so leaving as is. Updated the docs accordingly, and the README to include the install notes (and an additional one I found for getting it running on my new Ubuntu 20.04 install). Will merge as soon as tests pass!