How to plan the robot to stop perfectly after tracking a reference trajectory or moving for some time with external force applied in mujoco? #1954
Replies: 7 comments
-
Btw, may I ask a question about how long would a joint command last to control a robot, for instance, if there is a sudden joint torque reaching 10000 N.m at one step due to a sudden increase in acceleration, will this joint torque only last for, like 0.002s, the timestep. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Thanks so much for you reply, Balint, really really appreciate your reply with so many details. Thanks very much for your time. Actually, the movement I actually observe is quite large that I can obviously see that the robot keeps moving even though I plan the cartesian velocities and cartesian accelerations to decrease to zero with large damping ratio. The relationship between cartesian acceleration and cartesian velocity is governed by the differential equation below in the second task I mentioned above:
Then, I use to normal way to calculate joint velocities and joint accelerations with Jacobian matrix and it can be observed that the desired joint velocities and joint accelerations will reach 0 very fast which is the result I expect. However, there would always be some errors between the desired joint velocities/accelerations and the current joint velocities and accelerations which result in the unexpected large motion after I remove the external force. I also showed some data I printed in simulation in this issue #1911, which probably is the reason why I cannot get the qvel and qacc reduce to 0 quickly. And yes, I also make sure it's a critically damped case, but the result is still not quite good which I think is veru counter-intuitive because I think all the theory is well implemented. So I suspect there must be something I miss in using mujoco for simulation. Btw, you mentioned "If you set qfrc_applied or ctrl to some value, it will stay that way across steps. Be sure to clear them if you want the force to stop." I am not sure whether I understand it in a right way, does it mean that,
Sorry for asking for so many details in the comment. Thanks very much again for your help, Balint.Wishing you all the best. |
Beta Was this translation helpful? Give feedback.
-
|
Beta Was this translation helpful? Give feedback.
-
Really appreciate your time and patience, thanks very much, Balint. Oh, I see, it is strongly related to the render frames at each time step. Then, how could I ensure that each time I call mj_step() function, it will only apply the ctrl input for one frame? I designed a test that I made the control input at each time step equals the gravity compensation torque. I clipped the codes about timestep settings, rendering and step function as follows,
I found that from the render window that it seems the robot keeps static, however, I printed the qpos, qvel, qacc after I call the mj_function and I found that the qvel and qacc are not zeros, so I guess the control torque actually lasts for more than one frame for each timestep, so how could I make sure the gravity compensation torque could enable the robot to stay at the initial position. May I ask what would be the best way to calculate the torque to help a robot maintain its configuration? What details should I pay attention to. Thanks very much and wishing you all the best. |
Beta Was this translation helpful? Give feedback.
-
It would be very strange to only apply control for a single frame, it is much more common to apply it continuously and adapt its value (and therefore overwrite the previous values, ending their influence). In your torque function you showed, you need to copy the kinematics before you write to them so you can restore them. What values of qvel and qacc do you observe? Also please refrain from starting multiple issues for the same/closely related question, feel free to edit or update an existing thread. # code for get gravity_compensation_torque to perform kinematic changes in one step
def get_grav_compen_torques(self, desired_qvel, desired_qacc):
qvel_copy = self.data.qvel.copy()
qacc_copy = self.data.qacc.copy()
self.data.qvel[0:self.joint_num] = desired_qvel
self.data.qacc[0:self.joint_num] =desired_qacc
mujoco.mj_inverse(self.model, self.data)
frc = self.data.qfrc_inverse.copy()[0:self.joint_num]
self.data.qvel = qvel_copy
self.data.qacc = qacc_copy
return frc |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Hi,
I'm a student and I'm trying to use MuJoCo for robotic research.
I'm looking for some help with motion planning task in mujoco with joint torque control signals.
What I aim to do is to write a admittance controller for a franka panda robot in mujoco and basically to fulfill two different catergories of tasks:
The controller I wrote is a joint torque-based controller, namely, the actuators I defined for the robot is motor-type actuators. The problem I encountered in simulation for both tasks is about how to plan the robot to stop after following a defined trajectory.
First, could you help me check my understandings in this problem. In my opinion, if I want the robot to stay at some configuations finally, suppose this joint configuration is q_end, the joint torque I need to applied to the robot could be calculated in this way:
or calculated in this way,
I guess the crucial part is to make sure the joint velocity and joint acceleration are all zeros at the end configuation, and then the joint torque calculated with qfrc_inverse or qfrc_bias could help the robot stay at end configuation. I tested these two methods in both tasks, for instance, right after the robot reaches the end point of the defined trajectory in task 1) and right after the external force is removed in task 2), I mean, just enforce the qvel and qacc to be all zeros and compute the torque. I found they can enforce the robot to stay static, just as what I applied at the reset state.
However, for instance, in task 2), what I am struggling with is after the external force is removed, the robot has inital joint velocities, joint accelerations and what I aim to do is to reduce the robot joint accelerations and velocities naturally to 0 so that the joint torque computed from the joint impedance controller right matches the joint torque computed from qfrc_inverse or qfrc_bias. In other words, for a joint impedance controller as follows,
I hope the desired joint velocities and accelerations all reaching 0 and the same as the current real joint velocities and accelerations, however, I found that even though I can successfully planned the desired joint velocities to 0, the small torque resulted from the error between the desired joint velocities/accelerations and current joint velocities/accelerations cannot ensure the robot to stay static.
Here I have several questions:
Could you give me some good advice or tips I should definitely consider when doing such a motion plan task in mujoco?
Probably I ask too many details and "rookie" questions, anyway, really appreciate your help and look forward to hearing you.
Wishing you all the best.
Beta Was this translation helpful? Give feedback.
All reactions