Repository navigation
Replies: 1 comment
|
You understood it correctly. To drive the hand to a pose, close the loop yourself: compute the wrench again at every step from the pose error. This is a PD controller in task space, which is the same thing the joint drive does for import isaaclab.utils.math as math_utils
def pose_pd_wrench(robot, target_pos_w, target_quat_w, kp=100.0, kd=20.0, kp_rot=50.0, kd_rot=10.0):
d = robot.data
# translation: scale by total mass so the gains are in 1/s^2 and 1/s
mass = d.default_mass.sum(dim=-1, keepdim=True).to(robot.device) # (N, 1)
pos_err = target_pos_w - d.root_pos_w # (N, 3)
force = mass * (kp * pos_err - kd * d.root_lin_vel_w)
# rotation: axis-angle of q_target * q_current^-1, in world frame
rot_err = math_utils.quat_box_minus(target_quat_w, d.root_quat_w) # (N, 3)
torque = kp_rot * rot_err - kd_rot * d.root_ang_vel_w
return force.unsqueeze(1), torque.unsqueeze(1) # (N, 1, 3)
# every physics step (e.g. in _apply_action)
f, t = pose_pd_wrench(robot, target_pos_w, target_quat_w)
robot.set_external_force_and_torque(f, t, body_ids=[0], is_global=True)Notes:
To check it, hold a fixed target with no policy and log |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hi,
I have a question about how
set_external_force_and_torque()is intended to be used for controlling anArticulationin IsaacLab.In my setup, I am controlling a robot hand that is not fixed to the world. Gravity is disabled, so the hand is essentially a floating articulation. When my policy outputs actions, I use part of the action vector as force and torque inputs and apply them to the hand via
set_external_force_and_torque()to translate and rotate it.I understand how joint-level control works with functions like
set_joint_position_target(). In that case, if I provide a joint target value (e.g., 1.2), that value is treated as a PD controller target, and the joint is driven toward that position (1.2).However,
set_external_force_and_torque()seems to behave differently. For example, suppose I want to move the robot from position (1, 0, 0) to (3, 0, 0). If I pass (3, 0, 0) as the force input toset_external_force_and_torque(), it appears that this does not mean “move the robot to position (3, 0, 0)”, but rather “apply a constant force of magnitude (3, 0, 0)”, regardless of the current position.This leads to my main question.
Assume that I know:
Is there a principled way to determine what force and torque values should be passed into
set_external_force_and_torque()so that the robot reaches the target pose?From what I understand,
set_external_force_and_torque()stores force and torque values in a buffer, and later, whenwrite_data_to_sim()is called,self.root_physx_view.apply_forces_and_torques_at_position()is executed. I tried reading the Omni Physics documentation forapply_forces_and_torques_at_position(), but the description was quite high-level and did not clearly explain how these forces are meant to be interpreted or designed for pose control.So, in short:
Given the robot’s current position and rotation, is there a recommended or standard way to compute the inputs to
set_external_force_and_torque()that would drive the robot toward a desired target position and rotation?Thanks in advance, and sorry for the long question.
All reactions