Field-Robotics-Lab / glider_hybrid_whoi

(Hybrid-) AUG Simulator
8 stars 9 forks source link

Dynamics vehicle control #58

Open woensug-choi opened 3 years ago

woensug-choi commented 3 years ago

Rewrote dynamics code and it's working in 6-DOF

> Status of the previous branch and PR : Unstable, only work for 3-DOF (pitch-X-Z)

Last time, the 6-DOF dynamics calculation was coded based on Isa, 2014 Paper modified to EPIC-DAUG Glider dynamics Overleaf. HOWEVER, it only was stable for 3-DOF (only moving forward; only pitch-X-Z calculation). The background equations are verified at MATLAB, and 3-DOF hard input comparisons look promising. But not in Gazebo (in Gazebo, the force turms are applied as force input to the model with this->link->AddRelativeForce(hydForce))

How it's been resolved

Quickstart UwGliderCommand

- In this branch, `<use_dynamics>` handle is on by default.
- Default transient current CSV file linked with relative path is at the dave repo. (newly updated)
roslaunch glider_hybrid_whoi_gazebo start_demo_kinematics_stratified_current.launch
# At another terminal window
rostopic pub /glider_hybrid_whoi/kinematics/UwGliderCommand frl_vehicle_msgs/UwGliderCommand "pitch_cmd_type: 1
target_pitch_value: -0.0001
motor_cmd_type: 2
target_motor_cmd: 0.1
rudder_control_mode: 2
rudder_angle: 4
target_rudder_angle: 0.5
target_pumped_volume: -220.0"

image Here, you see the glider ascending and yawing at a constant angle. As it rotates, the roll is also affected as seen in the bottom left camera feed. You can also see that the rotation of the propeller graphically according to the thruster power command input.

Limitations and To-dos

ashishraste commented 2 years ago

Hi @woensug-choi,

Thanks to you and this repo's authors for opensourcing this work on underwater glider dynamics and simulation.

Following our e-mail conversation, I wanted to ask the below questions. I'm commenting here since I believe this PR is yet to be merged to the main branch.

Do you know which dynamics equations might be introducing/using ENU convention in the script?

woensug-choi commented 2 years ago

Before all, what would be the problem of calculating in ENU frame? The PR calculates vehicle motion and injects the position of the vehicle with setModelPose. Without gazebo's internal physics engine.

woensug-choi commented 2 years ago

I believe I tried to follow conventions in the development note at https://www.overleaf.com/read/pqstymzccttj. @ashishraste Not sure whether you have access to the document.

ashishraste commented 2 years ago

Before all, what would be the problem of calculating in ENU frame? The PR calculates vehicle motion and injects the position of the vehicle with setModelPose. Without gazebo's internal physics engine.

There wouldn't be any problem if all equations of motion were in ENU frame. But this is not the case with the dynamics simulation script I believe - this is so because (kinematics, dynamics) terms like \eta, \G(\eta), etc. are in NED frame, as described in the Latex document, and the translation and rotation state variables of pitch in \eta are output in ENU frame. Would you be able to confirm/validate this if you have time?

The immediate effect I'd think would be on designing a controller which will have to keep in mind (and hence some hardcoding of signs) the negated-sign of variables like body-velocities in heave-axis v_z or w. So variables like angle-of-attack which would in theory be positive when a glider is diving would be negative if ENU values are produced.

Side notes/thoughts -

What do you think?

woensug-choi commented 2 years ago

@ashishraste I did find some mismatch with the latex on the Matlab script. And made an update and clean-up. Checking the original 3-DOF Matlab code (private) by Brian Claus who provided the CBSoct.mat also plotted the m_pitch with a negative sign. I am guessing that the recordings were made so. Also, the depth recording is opposite to NED since it may be recorded with the altimeter sensor. It made sense to me comparing the value of m_ballast_pumped and m_battpos. What do you think?

woensug-choi commented 2 years ago