This commit is contained in:
xuzhiheng 2025-06-18 13:31:50 +08:00
parent 7ac42a2b80
commit b870caa0e5
2 changed files with 39 additions and 4 deletions

View File

@ -91,6 +91,14 @@ public class VehicleProcessModel {
* The vehicle's current bounding box. * The vehicle's current bounding box.
*/ */
private BoundingBox boundingBox; private BoundingBox boundingBox;
/**
* 当前车辆级别
*/
private Vehicle.IntegrationLevel integrationLevel;
/**
* 载货状态
*/
private Boolean loadState;
/** /**
* Creates a new instance. * Creates a new instance.
@ -661,6 +669,7 @@ public class VehicleProcessModel {
@Nonnull @Nonnull
Vehicle.IntegrationLevel level Vehicle.IntegrationLevel level
) { ) {
integrationLevel = level;
getPropertyChangeSupport().firePropertyChange( getPropertyChangeSupport().firePropertyChange(
Attribute.INTEGRATION_LEVEL_CHANGE_REQUESTED.name(), Attribute.INTEGRATION_LEVEL_CHANGE_REQUESTED.name(),
null, null,
@ -668,6 +677,14 @@ public class VehicleProcessModel {
); );
} }
/**
* 获取车辆级别
* @return 车辆级别
*/
public Vehicle.IntegrationLevel getIntegrationLevel() {
return integrationLevel;
}
/** /**
* Notifies observers that the vehicle would like to have its current transport order withdrawn. * Notifies observers that the vehicle would like to have its current transport order withdrawn.
* *

View File

@ -823,8 +823,16 @@ public class LoopbackCommunicationAdapter
getProcessModel().setPosition(params.getPoint().toString()); //更新最终经过点 getProcessModel().setPosition(params.getPoint().toString()); //更新最终经过点
} }
Pose oldPose = getProcessModel().getPose();
LAST_POSE = new Pose(new Triple(Math.round(params.getX() * 1000), Math.round(params.getY() * 1000), 0), params.getAngle()); LAST_POSE = new Pose(new Triple(Math.round(params.getX() * 1000), Math.round(params.getY() * 1000), 0), params.getAngle());
getProcessModel().setPose(LAST_POSE);
if (oldPose.getPosition() == null) { //姿态为空,更新
getProcessModel().setPose(LAST_POSE);
} else if (oldPose.getPosition().getX() != Math.round(params.getX() * 1000)
|| oldPose.getPosition().getY() != Math.round(params.getY() * 1000)
|| oldPose.getOrientationAngle() != params.getAngle()) { //姿态有变化,更新
getProcessModel().setPose(LAST_POSE);
}
} else { } else {
//最后经过点为0应该是车辆丢失定位或重启过todo 可能需要自动找点 //最后经过点为0应该是车辆丢失定位或重启过todo 可能需要自动找点
} }
@ -834,13 +842,19 @@ public class LoopbackCommunicationAdapter
} }
//更新电量 //更新电量
getProcessModel().setEnergyLevel(Math.round(params.getPower() * 100)); if (getProcessModel().getEnergyLevel() != Math.round(params.getPower() * 100)) {
getProcessModel().setEnergyLevel(Math.round(params.getPower() * 100));
}
//更新车辆等级 //更新车辆等级
getProcessModel().integrationLevelChangeRequested(integrationLevel); if (!Objects.equals(getProcessModel().getIntegrationLevel(), integrationLevel)) {
getProcessModel().integrationLevelChangeRequested(integrationLevel);
}
//更新车辆状态 //更新车辆状态
getProcessModel().setState(vehicleState); if (!Objects.equals(getProcessModel().getState(), vehicleState)) {
getProcessModel().setState(vehicleState);
}
//更新载货状态 //更新载货状态
loadState = params.getCargo_status() == 1 ? LoadState.FULL : LoadState.EMPTY; loadState = params.getCargo_status() == 1 ? LoadState.FULL : LoadState.EMPTY;
@ -851,6 +865,10 @@ public class LoopbackCommunicationAdapter
return serialNum; return serialNum;
} }
/**
* 处理车辆动作执行状态
* @param agvActionStatus 车辆动作执行状态对象
*/
private void handleActionStatus(AgvActionStatus agvActionStatus) { private void handleActionStatus(AgvActionStatus agvActionStatus) {
if (agvActionStatus.getStatus()) { if (agvActionStatus.getStatus()) {
ACTION_STATUS = false; ACTION_STATUS = false;