# Altitude control using baro

Dear all,
I have a question about altitude control using baro (without gps or sonar, lidar). I use postition_estimator_inav module and see a line of code as follows:
/* publish local position */
local_pos.xy_valid = can_estimate_xy;
local_pos.v_xy_valid = can_estimate_xy;
local_pos.xy_global = local_pos.xy_valid && use_gps_xy;
local_pos.z_global = local_pos.z_valid && use_gps_z;
local_pos.x = x_est[0];
local_pos.vx = x_est[1];
local_pos.y = y_est[0];
local_pos.vy = y_est[1];
local_pos.z = z_est[0];
local_pos.vz = z_est[1];
local_pos.yaw = att.yaw;
local_pos.dist_bottom_valid = dist_bottom_valid;
local_pos.eph = eph;
local_pos.epv = epv;
I think local_pos.z is the target height value calculated (or corrected) by barometer; however, when I extract this value using flightplot, the unit in the Y axis can be negative, so my question is what is the unit of this value ( I presume it should be in âmetersâ), why it can be negative?
Furthermore, is baro data converted into meters in the firmware?
Thanks.

Z points downward in the Local frame.
Baro altitude is published in meters in the sensor_combined topic.
Beware that baro altitude is AMSL (above mean sea level) so it will be positive unless youâre on the ground in New Orleans

Thanks for the reply. As you have said, I can understand Z could be negative since it represents AMSL, and points downward in the axis. My question then is how the base point, I mean, (0,0,0) is determined? Z value only makes sense when there exists a base point, am I right?

The 0 point is calculated as the average of first several hundreds of barometer values.
If you search âwait_baroâ in the cpp file, you will find more details.
Hope this correct.

1 Like