feat: 升级双向

main
邱棚 2025-03-20 13:28:29 +08:00
parent ef92c7cc1b
commit 223aa9bc04
6 changed files with 40 additions and 25 deletions

View File

@ -20,7 +20,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Autolabor.Robobase.Component" Version="0.2.1833" />
<PackageReference Include="Autolabor.Robobase.Component" Version="0.2.1851" />
<PackageReference Include="Autolabor.SerialBase" Version="0.1.239" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="9.0.2" />
<PackageReference Include="System.Security.Permissions" Version="9.0.2" />

View File

@ -19,8 +19,10 @@ namespace Autolabor.Benz.ObstacleDetection
private SerialRelayDriver _serialRelay;
// 算法层组件
private LidarRoiFilter _lidarRoiFilter;
private ObstacleDetector _obstacleDetector;
private LidarRoiFilter _lidarFrontRoiFilter;
private LidarRoiFilter _lidarRearRoiFilter;
private ObstacleDetector _frontObstacleDetector;
private ObstacleDetector _rearObstacleDetector;
private BenzObstacleControl _benzObstacleController;
// 模拟器配置
@ -29,13 +31,15 @@ namespace Autolabor.Benz.ObstacleDetection
private IPAddress _serverIp = IPAddress.Loopback;
// 配置过滤区域
private LidarRoi[] _lidarRois;
private LidarRoi[] _lidarFrontRoi;
private LidarRoi[] _lidarRearRoi;
public Detection(RectRoiSettings roiSettings)
{
// 1. 获取感兴趣区域
var rois = roiSettings.RectRois.Select(roi => LidarRoiFactory.Make(roi.LeftUpX, roi.LeftUpY, roi.RightDownX, roi.RightDownY)).ToList();
_lidarRois = rois.ToArray();
_lidarFrontRoi = rois.Take(1).ToArray();
_lidarRearRoi = rois.Skip(1).ToArray();
// 2. 创建各个功能组件
// 驱动组件
@ -43,9 +47,11 @@ namespace Autolabor.Benz.ObstacleDetection
_serialRelay = new SerialRelayDriver();
// 算法组件
_obstacleDetector = new ObstacleDetector();
_frontObstacleDetector = new ObstacleDetector();
_rearObstacleDetector = new ObstacleDetector();
_benzObstacleController = new BenzObstacleControl();
_lidarRoiFilter = new LidarRoiFilter();
_lidarRearRoiFilter = new LidarRoiFilter();
_lidarFrontRoiFilter = new LidarRoiFilter();
// 连接到绘图
// var lidarRender = DataRenderFactory.Make<Pose2D[]>("Benz","lidar",false,true);
@ -53,13 +59,15 @@ namespace Autolabor.Benz.ObstacleDetection
// Add(lidarRender);
// Add(obstacleRender);
// _lidarDriver.OutputLocalLidarPose2D.Connect(lidarRender.Input);
// _obstacleDetector.OutputObstaclePoses.Connect(obstacleRender.Input);
// _frontObstacleDetector.OutputObstaclePoses.Connect(obstacleRender.Input);
// 3. 添加组件到容器
Add(_lidarDriver);
Add(_serialRelay);
Add(_lidarRoiFilter);
Add(_obstacleDetector);
Add(_lidarRearRoiFilter);
Add(_lidarFrontRoiFilter);
Add(_frontObstacleDetector);
Add(_rearObstacleDetector);
Add(_benzObstacleController);
// 4. 配置组件
@ -81,31 +89,38 @@ namespace Autolabor.Benz.ObstacleDetection
_serialRelay.SetProperty("serial.relay.port", "/dev/autolabor_relay");
// 配置过滤器
_lidarRoiFilter.SetProperty("roiArray", _lidarRois);
_lidarFrontRoiFilter.SetProperty("roiArray", _lidarFrontRoi);
_lidarRearRoiFilter.SetProperty("roiArray", _lidarRearRoi);
// 障碍物检测器配置
_obstacleDetector.SetProperty("MinClusterDistance", 0.05);
_obstacleDetector.SetProperty("MinClusterSize", 3);
_obstacleDetector.SetProperty("MaxPrjDistance", 0.05);
_obstacleDetector.SetProperty("GuessDistance", 1.0);
_frontObstacleDetector.SetProperty("MinClusterDistance", 0.05);
_frontObstacleDetector.SetProperty("MinClusterSize", 3);
_frontObstacleDetector.SetProperty("MaxPrjDistance", 0.05);
_frontObstacleDetector.SetProperty("GuessDistance", 1.0);
_rearObstacleDetector.SetProperty("MinClusterDistance", 0.05);
_rearObstacleDetector.SetProperty("MinClusterSize", 3);
_rearObstacleDetector.SetProperty("MaxPrjDistance", 0.05);
_rearObstacleDetector.SetProperty("GuessDistance", 1.0);
// 配置发现和丢失次数
_benzObstacleController.SetProperty("FoundObstacleThreshold", 2);
_benzObstacleController.SetProperty("LostObstacleThreshold", 3);
// 5. 连接组件
// 雷达数据流向避障检测
_lidarDriver.OutputLocalLidarPose2D.Connect(_lidarRoiFilter.InputLidarPoints);
_lidarRoiFilter.OutputFilteredPoints.Connect(_obstacleDetector.InputLidarPoints);
_lidarDriver.OutputLocalLidarPose2D.Connect(_lidarFrontRoiFilter.InputLidarPoints);
_lidarFrontRoiFilter.OutputFilteredPoints.Connect(_frontObstacleDetector.InputLidarPoints);
_lidarDriver.OutputLocalLidarPose2D.Connect(_lidarRearRoiFilter.InputLidarPoints);
_lidarRearRoiFilter.OutputFilteredPoints.Connect(_rearObstacleDetector.InputLidarPoints);
// 雷达诊断信号连接到奔驰障碍物控制器
_lidarDriver.OutputLidarDiagnostic.Connect(_benzObstacleController.InputLidarDiagnostics);
// 避障检测结果流向奔驰避障控制器
_obstacleDetector.OutputObstacles.Connect(_benzObstacleController.InputObstacles);
_frontObstacleDetector.OutputObstacles.Connect(_benzObstacleController.InputFrontObstacles);
_rearObstacleDetector.OutputObstacles.Connect(_benzObstacleController.InputRearObstacles);
// 奔驰避障控制器输出到继电器
_benzObstacleController.OutputRelayControl.Connect(_serialRelay.InputRelayControl);
_benzObstacleController.OutputRelayQuery.Connect(_serialRelay.InputRelayQuery);
_serialRelay.OutputRelayFeedback.Connect(_benzObstacleController.InputRelayStatus);
_serialRelay.OutputSerialConnect.Connect(_benzObstacleController.InputSerialConnect);
}
}
}

View File

@ -11,7 +11,7 @@
"dependencies": {
"Autolabor.Robobase": "0.3.631",
"Autolabor.Robobase.CodeGuard": "0.1.24",
"Autolabor.Robobase.Component": "0.2.1833",
"Autolabor.Robobase.Component": "0.2.1851",
"Autolabor.SerialBase": "0.1.239",
"Microsoft.Extensions.Hosting": "9.0.2",
"Microsoft.NETFramework.ReferenceAssemblies": "1.0.3",
@ -165,7 +165,7 @@
}
},
"Autolabor.Robobase.CodeGuard/0.1.24": {},
"Autolabor.Robobase.Component/0.2.1833": {
"Autolabor.Robobase.Component/0.2.1851": {
"dependencies": {
"Autolabor.Robobase": "0.3.631",
"NLog": "5.1.3",
@ -628,12 +628,12 @@
"path": "autolabor.robobase.codeguard/0.1.24",
"hashPath": "autolabor.robobase.codeguard.0.1.24.nupkg.sha512"
},
"Autolabor.Robobase.Component/0.2.1833": {
"Autolabor.Robobase.Component/0.2.1851": {
"type": "package",
"serviceable": true,
"sha512": "sha512-y7LlbK0cQiOjUpW3Z1AWfOcoYuVkKHgMD5ex00WNF2xBOYHv6vL7idDlGc8rhnxf+YNq4Ewp6OnQyHR+03NLTA==",
"path": "autolabor.robobase.component/0.2.1833",
"hashPath": "autolabor.robobase.component.0.2.1833.nupkg.sha512"
"sha512": "sha512-a+bA8OxoK6rprB6CQZ4BL+uWaNIyeAXjN+CdYZZuRLD0bAxLQNyXGRFeSBevCZXOkhzSuoEDJXbUdW+8sTsgfA==",
"path": "autolabor.robobase.component/0.2.1851",
"hashPath": "autolabor.robobase.component.0.2.1851.nupkg.sha512"
},
"Autolabor.SerialBase/0.1.239": {
"type": "package",

Binary file not shown.

Binary file not shown.

Binary file not shown.