YunxiTang / Simple-Robotic-Trajectory-Optimization

Motion Planning for Dynamical System
2 stars 1 forks source link

Hello, author, how to conduct real-machine testing? #21

Closed wenge123456789 closed 8 months ago

wenge123456789 commented 8 months ago

Hello, author, how to conduct real-machine testing?

YunxiTang commented 8 months ago

Hi, To deploy the planned trajectory on hardware, the general pipeline is to: model your robot as accurately as possible -> run the planner offline/online -> track the planned trajectory with a tracking controller (e.g. LQR). You can refer to this paper: ' Optimization and stabilization of trajectories for constrained dynamical systems'. Free to let me know if you have any question.

wenge123456789 commented 8 months ago

Thanks Reply. Hello , author, I recently read your paper - "Towards Safe Landing of Falling Quadruped Robots Using a 3-DoF Morphable Inertial Tail" and based on the "Falling_Cat" and "Falling_Cat_barrier" projects in the "Simple-Robotic-Trajectory-Optimization" unit , carry out code reproduction and simulation of the original paper. There are still many unresolved problems during the experiment. I hope to get your help.

  1. Did the original paper firstly perform calculations in Matlab, and then input the calculated optimized trajectory into ROS to control the tail?
  2. There are three items on the right side of the feedback tracking controller. The first item is the reference output torque. What are the specific meanings of the second item q and the third item u? Is the angle and angular velocity of the tail swing obtained in the offline stage? Why is the numerical value obtained by multiplying the difference with Kp and Kd, which can be combined with the torque?
  3. Is the feedback tracking controller used to use the calculated torque as feedforward control and the angular velocity and angle output by the joint as feedback control?
  4. In the "Falling_Cat" and "Falling_Cat_barrier" projects, can the counterweight blocks be added for simulation experiments? Looking forward to the author's reply, thank you. 微信图片_20240311231059
YunxiTang commented 8 months ago

Thanks Reply. Hello , author, I recently read your paper - "Towards Safe Landing of Falling Quadruped Robots Using a 3-DoF Morphable Inertial Tail" and based on the "Falling_Cat" and "Falling_Cat_barrier" projects in the "Simple-Robotic-Trajectory-Optimization" unit , carry out code reproduction and simulation of the original paper. There are still many unresolved problems during the experiment. I hope to get your help.

  1. Did the original paper firstly perform calculations in Matlab, and then input the calculated optimized trajectory into ROS to control the tail?
  2. There are three items on the right side of the feedback tracking controller. The first item is the reference output torque. What are the specific meanings of the second item q and the third item u? Is the angle and angular velocity of the tail swing obtained in the offline stage? Why is the numerical value obtained by multiplying the difference with Kp and Kd, which can be combined with the torque?
  3. Is the feedback tracking controller used to use the calculated torque as feedforward control and the angular velocity and angle output by the joint as feedback control?
  4. In the "Falling_Cat" and "Falling_Cat_barrier" projects, can the counterweight blocks be added for simulation experiments? Looking forward to the author's reply, thank you. 微信图片_20240311231059

Yes, this repo is the initial code used in the tailed quadruped paper.

  1. Yes. The planned trajectory was firstly precomputed in MATLAB offline. But we indeed used spatial-v2 for the dynamic modeling instead of deriving them by ourself. The precomputed trajectory was then executed onboard;
  2. The second and third terms are similar to PD controller, where Kp and Kd were obtained from the trajectory optimizer (DDP). q and u are generalized joint position and velocity associated with the tail;
  3. Yes. Feedforward + feedback;
  4. I did not get your point for this sub-question. Can you elaborate it more clearly.
wenge123456789 commented 8 months ago

Thanks Reply. Hello , author, I recently read your paper - "Towards Safe Landing of Falling Quadruped Robots Using a 3-DoF Morphable Inertial Tail" and based on the "Falling_Cat" and "Falling_Cat_barrier" projects in the "Simple-Robotic-Trajectory-Optimization" unit , carry out code reproduction and simulation of the original paper. There are still many unresolved problems during the experiment. I hope to get your help.

  1. Did the original paper firstly perform calculations in Matlab, and then input the calculated optimized trajectory into ROS to control the tail?
  2. There are three items on the right side of the feedback tracking controller. The first item is the reference output torque. What are the specific meanings of the second item q and the third item u? Is the angle and angular velocity of the tail swing obtained in the offline stage? Why is the numerical value obtained by multiplying the difference with Kp and Kd, which can be combined with the torque?
  3. Is the feedback tracking controller used to use the calculated torque as feedforward control and the angular velocity and angle output by the joint as feedback control?
  4. In the "Falling_Cat" and "Falling_Cat_barrier" projects, can the counterweight blocks be added for simulation experiments? Looking forward to the author's reply, thank you. 微信图片_20240311231059

Yes, this repo is the initial code used in the tailed quadruped paper.

  1. Yes. The planned trajectory was firstly precomputed in MATLAB offline. But we indeed used spatial-v2 for the dynamic modeling instead of deriving them by ourself. The precomputed trajectory was then executed onboard;
  2. The second and third terms are similar to PD controller, where Kp and Kd were obtained from the trajectory optimizer (DDP). q and u are generalized joint position and velocity associated with the tail;
  3. Yes. Feedforward + feedback;
  4. I did not get your point for this sub-question. Can you elaborate it more clearly.

Thanks Reply. Thank you very much for patient answer, but there are still some things I don’t understand, and I hope to get answers:

  1. How was the tail model simplified during the experiment? Is the center of mass in the middle? Why doesn't the tail use moment of inertia?
  2. It is mentioned above that Kp and Kd are obtained through the trajectory optimizer (DDP), but based on the form of the feedback tracking controller in the paper, I feel that these two parameters are parameters of the PD feedback tracking controller in the online tracking stage, and they are not calculated by the DDP algorithm in the offline stage. Am I right to understand it this way? It is still unclear whether Kp and Kd are parameters of the PD feedback tracking controller in the online trajectory tracking stage or obtained by the DDP algorithm in the offline trajectory optimization stage? Can you explain it in detail?
  3. Does using the spatial-v2 package for dynamic modeling mean to calculate the M matrix and C matrix in the dynamic equation?
  4. During the experiment, the tail mass was very light compared to the body. When the body mass increases, is it necessary to add a lead weight to the end of the tail to increase the moment of inertia to adjust the body posture? At this time, does the center of mass of the tail need to be reset? Looking forward to the reply, thank you.
YunxiTang commented 8 months ago

I got your points.

  1. In the experiments, the tail was simplified as a point mass. The CoM was at the end of the tail since the mass was mostly located at the end;
  2. Kp and Kd can theoretically be obtained from DDP or iLQR. You can take a look at "Synthesis and Stabilization of Complex Behaviors through Online Trajectory Optimization" to know more about DDP/iLQR algo. In the hardware experiments, Kp/Kd need some tuning actually due to modelling error;
  3. Yes. spatial-v2 can be utilized to calculate the forward dynamics;
  4. I agree with you. When the body mass increases, you can add more weight to the tail. Or you can also re-plan the motion with the new model parameters. In fact, we didn't make any change on the tail during experiments, more efforts were made to design "good" trajectories.

Hopefully, these can resolve your concerns.

wenge123456789 commented 8 months ago

Thanks Reply. After several days of experimental simulation, I encountered some problems that cannot be solved. I hope to get your guidance: 1、In the experiment, how to keep the tail joint angle unchanged when the body reaches balance and the tail retraction process? Is it necessary to change the motor mode that controls the pitch and yaw motion of the tail from the force control mode to the position control mode? (Fig. 5) ) 2) Does the trajectory generated by offline planning include the tail retraction process? That is, when the tail begins to retract at 0.4s, is the feedback tracking controller still running? 3) In Fig. 5(b), is the change in the attitude angle of the robot after 0.4s due to caused by the tail retraction process? 4) What is the position controller used in the Retract Tail process in the paper? Is it a position control command to retract the tail, or is it a position controller that maintains the current attitude during the retraction of the tail? What is its specific form? Looking forward to the author's reply, thank you. 1

wenge123456789 commented 8 months ago

5) Gravity is not defined in the current Matble code, but I added gravity in Gazebo simulation. Will this affect the generated trajectory in Gazebo simulation results? 6) At this stage, simulation in Matlab can obtain relatively ideal results, but when the generated trajectory is imported into Gazebo for simulation experiments, when the trajectory is input and runs halfway, the body can reach balance, but at this time the tail’s pitch and yaw directions also have large accelerations, which will cause the body to eventually lose balance. Is this due to errors in model establishment or the lack of gravity factors? 7) The cost function in the paper only optimizes the angular error, while the 10-dimensional state quantity optimized in the Matlab code includes angular velocity, so the simulation curve in the paper will have angular velocity when it is balanced, while the angular velocity of the curve simulated in the code is 0 ,Why is this?

YunxiTang commented 8 months ago

Got your points.

  1. Yes. In the stance phase, the tail switched to position control.
  2. The tail retraction is not included in the offline TO and it is decoupled (but you can include it in the offline TO, which is ok). The feedback controller is still running when the tail started to retract (the orientation is not well stabilized based on my observation during this duration, but it is ok for landing).
  3. Yes. The retraction of the tail caused disturbance on the body.
  4. We just use joint position controller to main the tail joint angles and also control the tail length.
  5. No effect. The gravity has no effect on the orientation, so do not include it for re-orientation optimization to reduce the system state dimension.
  6. The ideal case is: before the tail retraction, the body orientation should be already well adjusted. If large accelerations exist, the robot is easier to lose balance. Large accelerations could be caused by model error, tracking error of the planned trajectory and so on.
  7. We penalize the u_f in the cost function in the paper (eq (4)), which includes all the angular velocities. So the angular velocity of the curve simulated in the code is 0 ideally.

(For better stable landing, my suggestion is to add a whole body controller at landing phase. ps, if you have more questions, pls email me instead to keep this repo clean)

wenge123456789 commented 8 months ago

Got your points.

  1. Yes. In the stance phase, the tail switched to position control.
  2. The tail retraction is not included in the offline TO and it is decoupled (but you can include it in the offline TO, which is ok). The feedback controller is still running when the tail started to retract (the orientation is not well stabilized based on my observation during this duration, but it is ok for landing).
  3. Yes. The retraction of the tail caused disturbance on the body.
  4. We just use joint position controller to main the tail joint angles and also control the tail length.
  5. No effect. The gravity has no effect on the orientation, so do not include it for re-orientation optimization to reduce the system state dimension.
  6. The ideal case is: before the tail retraction, the body orientation should be already well adjusted. If large accelerations exist, the robot is easier to lose balance. Large accelerations could be caused by model error, tracking error of the planned trajectory and so on.
  7. We penalize the u_f in the cost function in the paper (eq (4)), which includes all the angular velocities. So the angular velocity of the curve simulated in the code is 0 ideally.

(For better stable landing, my suggestion is to add a whole body controller at landing phase. ps, if you have more questions, pls email me instead to keep this repo clean)

Thanks for your patient reply. Can I ask for your contact email for further communication.

wenge123456789 commented 8 months ago

Thanks Reply. At this stage, there are still some doubts that need your guidance: 1) In the Tail Retraction stage, what is the mode of the motors that controls the pitch and yaw movement of the tail? (According to the description of Stance Controller in the paper, is the stance phase the stage after touching the ground?) 2) When the body reaches balance, after the control mode of the motor that controls the tail swing is switched from the torque control mode to the position control mode, will the motor suddenly produce a reaction force that will make the body posture unbalanced before touching the ground, thus affecting the stability of the body when landing? 3) When the tail begins to retract, the feedback tracking controller is still running, but the tail trajectory during this period is not planned in the offline stage. So while the tail is retracting, does it continue to perform pitch and yaw motions due to inertia? 4) Is the Joint position controller used to control the tail joint angles and the tail length the feedback tracking controller mentioned in the paper? This doesn't seem to be mentioned in the paper. 5) During your experiment, when the robot is balanced, will the angular velocity and acceleration of the tail be 0? If it is not 0, and it does not touch the ground when balancing, and the robot continues to fall, the robot will flip over, is that right? Looking forward to the author's reply, thank you.( PS, Can I ask for your contact email for further communication.)

YunxiTang commented 8 months ago

Hi, You can contact me at: yxtang@mae.cuhk.edu.hk