Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Directly manipulate forces/torques of joints #213

Closed
mrernst opened this issue Jul 4, 2021 · 8 comments · Fixed by #220
Closed

Feature Request: Directly manipulate forces/torques of joints #213

mrernst opened this issue Jul 4, 2021 · 8 comments · Fixed by #220
Assignees

Comments

@mrernst
Copy link

mrernst commented Jul 4, 2021

Hi there,
thank you for starting such an ambitious and cool project!
We'd love to use tdw in our lab, but since we are working on autonomously learning low-level robotics tasks it is necessary for us to directly control forces and torques of robot joints.

Unless I've missed it, the robotics API only allows for target-setting of joints. Are you willing to implement a set_joint_torque method at some point, or should we apply for access to the C# backend?

Best regards,

@alters-mit alters-mit self-assigned this Jul 6, 2021
@alters-mit
Copy link
Member

@mrernst Thanks for your interest in simulating robotics in TDW!

I've tested Unity's articulation body API for joint torques and forces. They seem to act as if the force is being applied from outside the robot--in other words, a force will be as if something hit the robot. The force won't account for joint limits and the joint will rotate/slide back to its target. I don't think that's what you actually want, but perhaps I'm wrong?

I could add a command to set target velocities instead of angles/positions. What if you combined that with the force limit (which you can control via set_robot_joint_drive? Would that give you sufficient control over the forces and torques applied to the joint? If so, I could easily write the new commands.

@mrernst
Copy link
Author

mrernst commented Jul 8, 2021

@alters-mit Thanks for your quick reply. Let's see whether I understood you correctly.

To me it seems that the methods already implemented (set_revolute_target) allows for position control: you set a target joint position and some controller (possibly PID-type) applies torques to get the joint there. This guarantees smooth transitions, but does not allow for fine-grained control.

Another way to do the same thing is velocity control: you set a target joint velocity and some controller tries to get the joint to rotate at this angular velocity. And these are the methods that you could easily implement, right?

The third common control style would be torque control, where you set the torque directly and the physics engine handles the rest. This is what we are interested in. Of course this approach should still respect joint limits and there should be no target set that it slides back to.

Maybe this clears things up a bit:
https://robotics.stackexchange.com/questions/10052/position-control-vs-velocity-control-vs-torque-control

For the sticky-mitten avatar you actually have commands to set joint forces, but the documentation says they will be deprecated, is there a specific reason for that? https://github.com/threedworld-mit/tdw/blob/master/Documentation/api/command_api.md#set_joint_force

@alters-mit
Copy link
Member

I've added force and torque commands. See this PR: #220

Please run the test in the PR and let me know on the PR thread if it works as expected (if GitHub doesn't let you post on the PR thread, just post the result here instead).

For the sticky-mitten avatar you actually have commands to set joint forces, but the documentation says they will be deprecated, is there a specific reason for that?

The sticky mitten avatar is obsolete. It uses the older Unity3D HingeJoint component, which is very glitchy. The Magnebot and all other robots in TDW use ArticulationBody components. The Magnebot has been designed to supersede the Sticky Mitten Avatar: for a full comparison, read this.

@instbldrjems
Copy link
Contributor

@mrernst Hi, thanks for engaging with us on this! What institution is your lab in?

@mrernst
Copy link
Author

mrernst commented Jul 13, 2021

@alters-mit Thank you so much. We're extremely happy that you are acting so quickly on this. I'll try to get around testing this as fast as possible.
@instbldrjems I am working for the Triesch Lab at Frankfurt Institute for Advanced Studies, it's an external institute affiliated with the Goethe-University Frankfurt, Germany (https://www.fias.science/en/neuroscience/research-groups/jochen-triesch/)

@alters-mit
Copy link
Member

Hi @mrernst, just checking in re: this PR. Have you had a chance to test it yet?

@jemsMIT
Copy link
Collaborator

jemsMIT commented Aug 23, 2021

Hi @mrernst , it would be great if you could test this. We would like to close the PR and merge these changes. Much appreciated!

@mrernst
Copy link
Author

mrernst commented Aug 23, 2021

I'm extremely sorry for the delayed response. I didn't have access to our infrastructure and haven't tested it myself, but one of my co-workers told me it works fine, so thank you very much and keep up the good work. We'll come back to you if we discover any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants