修正速度和档位
This commit is contained in:
parent
dbd3a49331
commit
83cbd55c00
@ -256,8 +256,8 @@ private:
|
||||
int reliability = 0; // RTK信号质量 1行 0不行
|
||||
|
||||
// 发布消息的参数
|
||||
int publish_speed = 0; // 转速占空比 0-100
|
||||
int publish_angle = 0; // [-66.0,66.0],负数表示左转,正数表示右转
|
||||
int publish_speed = 0; // 转速占空比 0-1500
|
||||
int publish_angle = 0; // [-40.0,40.0],负数表示左转,正数表示右转
|
||||
|
||||
// 车体矩形边界(栅格坐标)
|
||||
int vehicle_min_x_; // 车体最小行坐标(顶部)
|
||||
@ -790,7 +790,9 @@ private:
|
||||
|
||||
// 发布控制指令
|
||||
sweeper_interfaces::msg::McCtrl message;
|
||||
message.sweep = true;
|
||||
message.sweep = false;
|
||||
message.brake = 1; // 0开;1关
|
||||
message.gear = 2; // 0空挡;1后退;2前进
|
||||
|
||||
if (reliability == 1)
|
||||
message.rpm = publish_speed;
|
||||
@ -849,7 +851,7 @@ private:
|
||||
float target_angle = calculate_the_angle(x, y);
|
||||
|
||||
// 初始化控制参数
|
||||
publish_speed = 30;
|
||||
publish_speed = 800;
|
||||
publish_angle = static_cast<int>(target_angle);
|
||||
|
||||
// 安全检查:未检测到车体位置
|
||||
@ -986,7 +988,7 @@ private:
|
||||
else
|
||||
{
|
||||
// 距离足够,可以减速接近
|
||||
publish_speed = std::max(10, publish_speed / 2);
|
||||
publish_speed = std::max(600, publish_speed / 2);
|
||||
RCLCPP_INFO(this->get_logger(), "障碍物较宽,减速接近中,距离=%d格",
|
||||
obstacle_analysis_.obstacle_distance);
|
||||
}
|
||||
@ -1203,7 +1205,7 @@ private:
|
||||
}
|
||||
|
||||
// 速度控制:横向偏移时限速
|
||||
publish_speed = 15;
|
||||
publish_speed = 600;
|
||||
|
||||
// 角度控制:保持较大角度进行横向偏移
|
||||
int shift_angle = calculateLateralShiftAngle();
|
||||
@ -1482,7 +1484,7 @@ private:
|
||||
}
|
||||
|
||||
// 速度控制:平行前进时可以适当提速
|
||||
publish_speed = 20;
|
||||
publish_speed = 700;
|
||||
|
||||
// 角度控制:回正,保持直行
|
||||
publish_angle = 0;
|
||||
@ -1625,7 +1627,7 @@ private:
|
||||
{
|
||||
// 回正完成
|
||||
publish_angle = target_angle_int;
|
||||
publish_speed = speed;
|
||||
publish_speed = 800;
|
||||
avoid_ctx_.reset();
|
||||
|
||||
RCLCPP_INFO(this->get_logger(),
|
||||
@ -1644,7 +1646,7 @@ private:
|
||||
publish_angle -= std::min(RETURN_RATE, -angle_diff);
|
||||
}
|
||||
|
||||
publish_speed = 20; // 回正时保持低速
|
||||
publish_speed = 700; // 回正时保持低速
|
||||
|
||||
if (avoid_ctx_.counter % 10 == 0)
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"serial_port": "/dev/uartPort",
|
||||
"baudrate": 100000,
|
||||
"rmoctl_para": {
|
||||
"mcu_rpm_max": 3000,
|
||||
"mcu_rpm_max": 1500,
|
||||
"eps_angle_max": 40.0
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user