Depth control
description of the file depth_controller.py
Last updated
Was this helpful?
description of the file depth_controller.py
Last updated
Was this helpful?
The class Depth_Control implements a PID controller in order to reach the depth desired.
depth_controller
ROS topics subscribed
Message
Description
/BlueRov2/bar30
bluerov_ros_playground/Bar30
Absolute pressure in hPa
/Settings/set_depth
bluerov_ros_playground/Set_depth
Settings for the controller
/Settings/set_target
bluerov_ros_playground/Set_target
Depth to reach, vertical axis goes up
In this script, the axis Z for the depth goes up. To reach 1m depth the input must be -1
ROS topics published
Message
Description
/Command/depth
Uint16
Pwm send by the controller to the commander
To estimate current depth the controller gets the absolute pressure from the Bar30 sensor and computes it with hydrostatic equation.
Designation
Meaning
Value
depth
current depth
m
p
pressure measured
Pa
p0
surface pressure
99 000Pa
ρ
water density
1000 kg/m³
g
gravitational acceleration
9.81 kg/m²
The PID controller uses the difference between depth calculated and depth desired, but also the derivative and the integrate values to compute a command in the interval [-400,+400]. This command is added to 1500, the pwm neutral of thrusters.
A saturation method is added on pwm output before the publication on the command topic in case of a will to limit thruster power.
The depth target is defined by the publication of a Set_target message on the topic /Settings/set_target. This message is shared with the heading and the velocity controller to set their target
Set_target message :
Units
float64
depth_desired
m
float64
heading_desired
deg
float64
velocity_desired
pwm range[-400,400]
In this script, the axis Z for the depth goes up. To reach 1m depth the input must be -1
PID coefficients and maximum pwm for saturation of the command can be modified in real time by the Set_depth message published on the topic /Settings/set_depth.
These values send are not saved and the controller will get its initial value. To change permanently the values of those parameters you must change it in the code, in the __init__ method.
Set_depth message
bool
enable_depth_ctrl
uint16
pwm_max
uint32
KI
uint32
KP
uint32
KD
See to know how enable_depth_ctrl is used