Skip to content

Commit 08a2957

Browse files
committed
fix bug & update
1 parent 9408a72 commit 08a2957

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,18 @@
4545

4646
其他内容: 后续将进行真机测试,根据真机测试情况将继续完善
4747

48+
****************************************************
49+
50+
修改时间: 2022.08.29
51+
52+
修改人: 李博
53+
54+
修改内容:
55+
1. 修复真实高度与经纬度数据获取BUG
56+
2. 修复机体坐标系下XY速度Z高度控制逻辑BUG
57+
3. 优化多次调用位置偏移量问题
58+
测试情况: 仿真测试通过
59+
60+
其他内容: 后续将进行真机测试,根据真机测试情况将继续完善
61+
4862
****************************************************

Modules/uav_control/include/uav_estimator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class UAV_estimator
6464
ros::Subscriber uwb_sub;
6565
ros::Subscriber fake_odom_sub;
6666
ros::Subscriber px4_global_position_sub;
67+
ros::Subscriber px4_rel_alt_sub;
6768
ros::Subscriber gps_status_sub;
6869
ros::Subscriber set_local_pose_offset_sub;
6970
// 发布话题

Modules/uav_control/src/uav_controller.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ void UAV_controller::set_command_des()
524524
uav_command.velocity_ref[1] = d_vel_enu[1];
525525
pos_des[0] = 0.0;
526526
pos_des[1] = 0.0;
527-
pos_des[2] = uav_command.position_ref[2];
527+
pos_des[2] = uav_pos[2] + uav_command.position_ref[2];
528528
vel_des[0] = uav_command.velocity_ref[0];
529529
vel_des[1] = uav_command.velocity_ref[1];
530530
vel_des[2] = 0.0;

Modules/uav_control/src/uav_estimator.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ UAV_estimator::UAV_estimator(ros::NodeHandle &nh)
6363
// 【订阅】无人机当前经纬度,来自飞控
6464
px4_global_position_sub = nh.subscribe<sensor_msgs::NavSatFix>(uav_name + "/mavros/global_position/global", 1, &UAV_estimator::px4_global_pos_cb, this);
6565
// 【订阅】无人机当前真实高度,来自飞控
66-
px4_global_position_sub = nh.subscribe<std_msgs::Float64>(uav_name + "/mavros/global_position/rel_alt", 1, &UAV_estimator::px4_global_rel_alt_cb, this);
66+
px4_rel_alt_sub = nh.subscribe<std_msgs::Float64>(uav_name + "/mavros/global_position/rel_alt", 1, &UAV_estimator::px4_global_rel_alt_cb, this);
6767
// 【订阅】设置ENU坐标系下无人机的位置偏移量 坐标系:ENU系 - 来自地面站/终端窗口
6868
set_local_pose_offset_sub = nh.subscribe<prometheus_msgs::GPSData>(uav_name + "/prometheus/set_local_offset_pose", 1, &UAV_estimator::set_local_pose_offset_cb, this);
6969
// 【发布】ENU坐标系下的位置偏移量
@@ -733,8 +733,9 @@ void UAV_estimator::set_local_pose_offset_cb(const prometheus_msgs::GPSData::Con
733733
// 每个飞机的local_position还是在起飞坐标系
734734
// 所以发布控制指令也要加上偏差
735735
offset_pose.uav_id = uav_id;
736-
offset_pose.x = enu_offset[0] - uav_state.position[0] + msg->x;
737-
offset_pose.y = enu_offset[1] - uav_state.position[1] + msg->y;
736+
//重复调用时,避免偏移量错误计算,需要先减掉偏移量
737+
offset_pose.x += enu_offset[0] - uav_state.position[0] + msg->x;
738+
offset_pose.y += enu_offset[1] - uav_state.position[1] + msg->y;
738739

739740
local_pose_offset_pub.publish(offset_pose);
740741
}

0 commit comments

Comments
 (0)