|
@@ -7,9 +7,9 @@ import api.common.util.OsUtil;
|
|
|
import api.common.util.StringUtil;
|
|
|
import com.css.simulation.resource.video.configuration.redis.CustomRedisClient;
|
|
|
import com.css.simulation.resource.video.data.entity.VehicleEntity;
|
|
|
-import com.css.simulation.resource.video.mapper.ConfigMapper;
|
|
|
+import com.css.simulation.resource.video.mapper.ModelConfigMapper;
|
|
|
import com.css.simulation.resource.video.mapper.SimulationAutomaticProjectMapper;
|
|
|
-import com.css.simulation.resource.video.mapper.VehicleMapper;
|
|
|
+import com.css.simulation.resource.video.mapper.ModelVehicleMapper;
|
|
|
import com.css.simulation.resource.video.util.MinioUtil;
|
|
|
import io.minio.MinioClient;
|
|
|
import lombok.SneakyThrows;
|
|
@@ -38,9 +38,9 @@ import java.util.Set;
|
|
|
@Slf4j
|
|
|
public class VideoService {
|
|
|
@Resource
|
|
|
- private VehicleMapper vehicleMapper;
|
|
|
+ private ModelVehicleMapper modelVehicleMapper;
|
|
|
@Resource
|
|
|
- private ConfigMapper configMapper;
|
|
|
+ private ModelConfigMapper modelConfigMapper;
|
|
|
@Resource
|
|
|
private SimulationAutomaticProjectMapper simulationAutomaticProjectMapper;
|
|
|
@Resource
|
|
@@ -74,11 +74,11 @@ public class VideoService {
|
|
|
/**
|
|
|
* 生成视频
|
|
|
*/
|
|
|
- public void generateVideo(String nodeName, String projectId, String projectType, String maxSimulationTime, String taskId) {
|
|
|
- final Set<String> cpuNodeParallelismKeys = customRedisClient.keys("esmini-node*");
|
|
|
+ public void generateVideo(String generateVideoKey, String nodeName, String projectId, String projectType, String maxSimulationTime, String taskId) {
|
|
|
+ final Set<String> cpuNodeParallelismKeys = customRedisClient.keys("cpu-node*");
|
|
|
// 获取本地 hostname
|
|
|
final String hostName = OsUtil.getHostName();
|
|
|
- String cpuNodeParallelismKey = "esmini-node:" + nodeName + ":parallelism";
|
|
|
+ String cpuNodeParallelismKey = "cpu-node:" + nodeName + ":parallelism";
|
|
|
for (String tempCpuNodeParallelismKey : cpuNodeParallelismKeys) {
|
|
|
if (tempCpuNodeParallelismKey.contains(hostName)) {
|
|
|
cpuNodeParallelismKey = tempCpuNodeParallelismKey;
|
|
@@ -112,8 +112,8 @@ public class VideoService {
|
|
|
// 获取屏幕号创建新的虚拟屏幕
|
|
|
final long newScreenNum = customRedisClient.increment("screen-number", 1);
|
|
|
log.info("获取新的屏幕号:" + newScreenNum);
|
|
|
- final String xvfbCommand2 = xvfbCommand.replaceAll("screen-num", newScreenNum + "");
|
|
|
- final String esminiCommand2 = esminiCommand.replaceAll("screen-num", newScreenNum + "")
|
|
|
+ final String xvfbCommand2 = xvfbCommand.replaceAll("screen-num", String.valueOf(newScreenNum));
|
|
|
+ final String esminiCommand2 = esminiCommand.replaceAll("screen-num", String.valueOf(newScreenNum))
|
|
|
+ " " + xoscPath + " " + pictureDirectoryPath + "/screenshot " + StringUtil.doubleToString(Double
|
|
|
.parseDouble(maxSimulationTime), 2);
|
|
|
OsUtil.exec(xvfbCommand2);
|
|
@@ -148,6 +148,7 @@ public class VideoService {
|
|
|
} finally {
|
|
|
customRedisClient.increment(cpuNodeParallelismKey, 1);
|
|
|
customRedisClient.unlock(lockName);
|
|
|
+ customRedisClient.set(generateVideoKey, "1");
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -213,9 +214,9 @@ public class VideoService {
|
|
|
Element node4 = iterator4.next();
|
|
|
if ("Performance".equals(node4.getName())) {
|
|
|
Attribute maxSpeed = node4.attribute("maxSpeed");
|
|
|
- maxSpeed.setText(po.getPerformanceMaxSpeed() + "");
|
|
|
+ maxSpeed.setText(String.valueOf(po.getPerformanceMaxSpeed()));
|
|
|
Attribute maxDeceleration = node4.attribute("maxDeceleration");
|
|
|
- maxDeceleration.setText(po.getPerformanceMaxDeceleration() + "");
|
|
|
+ maxDeceleration.setText(String.valueOf(po.getPerformanceMaxDeceleration()));
|
|
|
Attribute maxAcceleration = node4.attribute("maxAcceleration");
|
|
|
maxAcceleration.setText(po.getPerformanceMaxAcceleration());
|
|
|
} else if ("BoundingBox".equals(node4.getName())) {
|
|
@@ -224,19 +225,19 @@ public class VideoService {
|
|
|
Element node5 = iterator5.next();
|
|
|
if ("Center".equals(node5.getName())) {
|
|
|
Attribute x = node5.attribute("x");
|
|
|
- x.setText(po.getCenterX() + "");
|
|
|
+ x.setText(String.valueOf(po.getCenterX()));
|
|
|
Attribute y = node5.attribute("y");
|
|
|
- y.setText(po.getCenterY() + "");
|
|
|
+ y.setText(String.valueOf(po.getCenterY()));
|
|
|
Attribute z = node5.attribute("z");
|
|
|
- z.setText(po.getCenterZ() + "");
|
|
|
+ z.setText(String.valueOf(po.getCenterZ()));
|
|
|
}
|
|
|
if ("Dimensions".equals(node5.getName())) {
|
|
|
Attribute width = node5.attribute("width");
|
|
|
- width.setText(po.getDimensionsWidth() + "");
|
|
|
+ width.setText(String.valueOf(po.getDimensionsWidth()));
|
|
|
Attribute length = node5.attribute("length");
|
|
|
- length.setText(po.getDimensionsHeight() + "");
|
|
|
+ length.setText(String.valueOf(po.getDimensionsHeight()));
|
|
|
Attribute height = node5.attribute("height");
|
|
|
- height.setText(po.getDimensionsHeight() + "");
|
|
|
+ height.setText(String.valueOf(po.getDimensionsHeight()));
|
|
|
}
|
|
|
}
|
|
|
} else if ("Axles".equals(node4.getName())) {
|
|
@@ -245,27 +246,27 @@ public class VideoService {
|
|
|
Element node5 = iterator5.next();
|
|
|
if ("FrontAxle".equals(node5.getName())) {
|
|
|
Attribute maxSteering = node5.attribute("maxSteering");
|
|
|
- maxSteering.setText(po.getFrontAxleMaxSteering() + "");
|
|
|
+ maxSteering.setText(String.valueOf(po.getFrontAxleMaxSteering()));
|
|
|
Attribute wheelDiameter = node5.attribute("wheelDiameter");
|
|
|
- wheelDiameter.setText(po.getFrontAxleWheelDiameter() + "");
|
|
|
+ wheelDiameter.setText(String.valueOf(po.getFrontAxleWheelDiameter()));
|
|
|
Attribute trackWidth = node5.attribute("trackWidth");
|
|
|
- trackWidth.setText(po.getFrontAxleTrackWidth() + "");
|
|
|
+ trackWidth.setText(String.valueOf(po.getFrontAxleTrackWidth()));
|
|
|
Attribute positionX = node5.attribute("positionX");
|
|
|
- positionX.setText(po.getFrontAxlePositionX() + "");
|
|
|
+ positionX.setText(String.valueOf(po.getFrontAxlePositionX()));
|
|
|
Attribute positionZ = node5.attribute("positionZ");
|
|
|
- positionZ.setText(po.getFrontAxlePositionZ() + "");
|
|
|
+ positionZ.setText(String.valueOf(po.getFrontAxlePositionZ()));
|
|
|
}
|
|
|
if ("RearAxle".equals(node5.getName())) {
|
|
|
Attribute maxSteering = node5.attribute("maxSteering");
|
|
|
maxSteering.setText(po.getRearAxleMaxSteering());
|
|
|
Attribute wheelDiameter = node5.attribute("wheelDiameter");
|
|
|
- wheelDiameter.setText(po.getRearAxleWheelDiameter() + "");
|
|
|
+ wheelDiameter.setText(String.valueOf(po.getRearAxleWheelDiameter()));
|
|
|
Attribute trackWidth = node5.attribute("trackWidth");
|
|
|
- trackWidth.setText(po.getRearAxleTrackWidth() + "");
|
|
|
+ trackWidth.setText(String.valueOf(po.getRearAxleTrackWidth()));
|
|
|
Attribute positionX = node5.attribute("positionX");
|
|
|
- positionX.setText(po.getRearAxlePositionX() + "");
|
|
|
+ positionX.setText(String.valueOf(po.getRearAxlePositionX()));
|
|
|
Attribute positionZ = node5.attribute("positionZ");
|
|
|
- positionZ.setText(po.getRearAxlePositionZ() + "");
|
|
|
+ positionZ.setText(String.valueOf(po.getRearAxlePositionZ()));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -324,10 +325,10 @@ public class VideoService {
|
|
|
vehicle = simulationAutomaticProjectMapper.vehicleByZdId(projectId);
|
|
|
}
|
|
|
log.info("车辆配置 Id 为:" + vehicle);
|
|
|
- String vehicleId = configMapper.getVehicleId(vehicle);
|
|
|
+ String vehicleId = modelConfigMapper.getVehicleId(vehicle);
|
|
|
|
|
|
log.info("车辆 Id 为:" + vehicleId);
|
|
|
- VehicleEntity vehicleInfo = vehicleMapper.getVehicleInfo(vehicleId);
|
|
|
+ VehicleEntity vehicleInfo = modelVehicleMapper.getVehicleInfo(vehicleId);
|
|
|
log.info("车辆信息为:" + vehicleInfo);
|
|
|
|
|
|
//自车模型
|
|
@@ -396,9 +397,9 @@ public class VideoService {
|
|
|
|
|
|
po.setPerformanceMaxSpeed(vehicleInfo.getMaxSpeed());
|
|
|
po.setPerformanceMaxDeceleration(vehicleInfo.getMaxDeceleration());
|
|
|
- BigDecimal moπ = new BigDecimal("3.141516");
|
|
|
+ BigDecimal moPI = new BigDecimal("3.141516");
|
|
|
BigDecimal mo180 = new BigDecimal("180");
|
|
|
- po.setFrontAxleMaxSteering(vehicleInfo.getMaxSteeringAngle().multiply(moπ).divide(mo180, 6, RoundingMode.CEILING));
|
|
|
+ po.setFrontAxleMaxSteering(vehicleInfo.getMaxSteeringAngle().multiply(moPI).divide(mo180, 6, RoundingMode.CEILING));
|
|
|
po.setFrontAxleWheelDiameter(vehicleInfo.getWheelDiameter());
|
|
|
BigDecimal mo4 = new BigDecimal("4");
|
|
|
BigDecimal mo5 = new BigDecimal("5");
|