Merge branch 'new_opentcs' of http://git.picaiba.com/agv/opentcs into new_opentcs
This commit is contained in:
@@ -492,28 +492,6 @@ public class LoopbackCommunicationAdapter
|
||||
getProcessModel().setState(Vehicle.State.EXECUTING);
|
||||
Step step = command.getStep();
|
||||
|
||||
Vehicle newVehicle = vehicleService.fetchObject(Vehicle.class, getProcessModel().getName());
|
||||
List<Set<TCSResourceReference<?>>> allocatedResources = newVehicle.getAllocatedResources();
|
||||
|
||||
//使用副本更新车辆模型,防止异常情况
|
||||
List<Set<TCSResourceReference<?>>> copiedResources = new ArrayList<>(allocatedResources);
|
||||
copiedResources.clear();
|
||||
|
||||
if (step.getSourcePoint() != null) {
|
||||
//下发起点不为空
|
||||
Point point = objectService.fetchObject(Point.class, step.getSourcePoint().getName());
|
||||
Set<TCSResourceReference<?>> resource = new HashSet<>();
|
||||
resource.add(point.getReference());
|
||||
copiedResources.add(resource);
|
||||
}
|
||||
if (step.getPath() != null) {
|
||||
Path path = objectService.fetchObject(Path.class, step.getPath().getName());
|
||||
Set<TCSResourceReference<?>> resource = new HashSet<>();
|
||||
resource.add(path.getReference());
|
||||
copiedResources.add(resource);
|
||||
}
|
||||
newVehicle.withAllocatedResources(copiedResources);
|
||||
|
||||
if (step.getPath() == null) {
|
||||
actionExec(command);
|
||||
} else {
|
||||
@@ -546,7 +524,7 @@ public class LoopbackCommunicationAdapter
|
||||
ACTION_STATUS = true;
|
||||
|
||||
//下发动作
|
||||
ExecuteAction.sendCmd(getProcessModel().getName(), command.getOperation(), getSerialNum());
|
||||
ExecuteAction.sendCmd(command.getTransportOrder().getName(), getProcessModel().getName(), getProcessModel().getPosition(), command.getOperation(), getSerialNum());
|
||||
|
||||
//进入阻塞
|
||||
while (ACTION_STATUS) {
|
||||
@@ -893,13 +871,21 @@ public class LoopbackCommunicationAdapter
|
||||
|
||||
//更新车辆姿态
|
||||
if (params.getPoint() != 0) {
|
||||
LAST_PASSED_POINT = params.getPoint().toString(); //记录最终经过点
|
||||
// LAST_PASSED_POINT = params.getPoint().toString(); //记录最终经过点
|
||||
if (!Objects.equals(getProcessModel().getPosition(), params.getPoint().toString())) {
|
||||
getProcessModel().setPosition(params.getPoint().toString()); //更新最终经过点
|
||||
initVehiclePosition(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());
|
||||
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 {
|
||||
//最后经过点为0,应该是车辆丢失定位或重启过。todo 可能需要自动找点
|
||||
}
|
||||
@@ -909,13 +895,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;
|
||||
@@ -926,8 +918,13 @@ public class LoopbackCommunicationAdapter
|
||||
return serialNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理车辆动作执行状态
|
||||
* @param agvActionStatus 车辆动作执行状态对象
|
||||
*/
|
||||
private void handleActionStatus(AgvActionStatus agvActionStatus) {
|
||||
if (agvActionStatus.getStatus()) {
|
||||
// System.out.println("handleActionStatus: ======");
|
||||
ACTION_STATUS = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user