|
@@ -18,9 +18,9 @@
|
|
|
#include "tool/pathcreator.h"
|
|
|
#include "lidar/lidarsJsonConfig.h"
|
|
|
#include "defines.hpp"
|
|
|
+#include "grpc/service.h"
|
|
|
|
|
|
#if __VIEW__PCL
|
|
|
-pcl::visualization::PCLVisualizer g_viewer;
|
|
|
#endif
|
|
|
|
|
|
void shut_down_logging(const char *data, size_t size) {
|
|
@@ -97,6 +97,7 @@ bool run(Wanji_716N_lidar_device *device, clamp_safety_detect *pdetector, Safety
|
|
|
}
|
|
|
|
|
|
void thread_func(Clamp *clamp) {
|
|
|
+ clamp->last_cloud = static_cast<boost::shared_ptr<pcl::PointCloud<pcl::PointXYZ>>>(new pcl::PointCloud<pcl::PointXYZ>());
|
|
|
while (true) {
|
|
|
clamp->mutex.lock();
|
|
|
|
|
@@ -104,15 +105,12 @@ void thread_func(Clamp *clamp) {
|
|
|
clamp->lidar.get_last_cloud(clamp->last_cloud, std::chrono::system_clock::now());
|
|
|
|
|
|
if (clamp->last_cloud->size() < 150) {
|
|
|
- continue;
|
|
|
+ // continue;
|
|
|
+ } else {
|
|
|
+ clamp->safety_statu.time_point = std::chrono::steady_clock::now();
|
|
|
+ clamp->detector.detect(clamp->last_cloud, clamp->safety_statu);
|
|
|
}
|
|
|
|
|
|
- clamp->detector.detect(clamp->last_cloud, clamp->safety_statu);
|
|
|
-
|
|
|
-// Safety_status safety_t;
|
|
|
-// if (run(&(clamp->lidar), &(clamp->detector), &safety_t)) {
|
|
|
-// clamp->safety_statu = safety_t;
|
|
|
-// }
|
|
|
clamp->mutex.unlock();
|
|
|
|
|
|
usleep(100 * 1000);
|
|
@@ -120,16 +118,22 @@ void thread_func(Clamp *clamp) {
|
|
|
}
|
|
|
|
|
|
int main() {
|
|
|
+#if __VIEW__PCL
|
|
|
+// return 1;
|
|
|
+pcl::visualization::PCLVisualizer g_viewer;
|
|
|
+#endif
|
|
|
//初始化日志
|
|
|
init_glog();
|
|
|
-
|
|
|
+ StreamRpcServer *m_grpc_server = new StreamRpcServer;
|
|
|
+ m_grpc_server->Listenning("0.0.0.0", 9876);
|
|
|
// 雷达数量
|
|
|
const int CLAMP_SIZE = 4;
|
|
|
//调试模式下,先打开调试窗口
|
|
|
#if __VIEW__PCL
|
|
|
+return 1;
|
|
|
int v1,v2,v3,v4;
|
|
|
//窗口参数分别对应 x_min, y_min, x_max, y_max, viewport
|
|
|
- g_viewer.createViewPort(0.0, 0.5, 0.5, 1, v1);
|
|
|
+ /*g_viewer.createViewPort(0.0, 0.5, 0.5, 1, v1);
|
|
|
g_viewer.createViewPort(0.5, 0.5, 1.0, 1, v2);
|
|
|
g_viewer.createViewPort(0.0, 0, 0.5, 0.5, v3);
|
|
|
g_viewer.createViewPort(0.5, 0, 1.0, 0.5, v4);
|
|
@@ -141,13 +145,13 @@ int main() {
|
|
|
g_viewer.addCoordinateSystem(0.2,"v1_axis",v1);
|
|
|
g_viewer.addCoordinateSystem(0.2,"v2_axis",v2);
|
|
|
g_viewer.addCoordinateSystem(0.2,"v3_axis",v3);
|
|
|
- g_viewer.addCoordinateSystem(0.2,"v4_axis",v4);
|
|
|
+ g_viewer.addCoordinateSystem(0.2,"v4_axis",v4);*/
|
|
|
#endif
|
|
|
//雷达
|
|
|
Clamp clamps[CLAMP_SIZE];
|
|
|
|
|
|
- LOG(INFO) << "load etc file from " << ETC_PATH"ClampSafety/clamp_safety_lidars.json";
|
|
|
- lidarsJsonConfig config(ETC_PATH"ClampSafety/clamp_safety_lidars.json");
|
|
|
+ LOG(INFO) << "load etc file from " << ETC_PATH"/etc/clamp_safety_lidars.json";
|
|
|
+ lidarsJsonConfig config(ETC_PATH"/etc/clamp_safety_lidars.json");
|
|
|
for (int i = 0; i < CLAMP_SIZE; ++i) {
|
|
|
lidarsJsonConfig::LidarConfig lidar;
|
|
|
config.getLidarConfig(i, lidar);
|
|
@@ -220,26 +224,29 @@ int main() {
|
|
|
while (true) {
|
|
|
usleep(100 * 1000);
|
|
|
heart = (heart + 1) % 255;
|
|
|
-// snap7_client->plcData.pingpong = heart;
|
|
|
+ snap7_client->plcData.pingpong = heart;
|
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
std::unique_lock<std::mutex> t_lock(clamps[i].mutex);
|
|
|
-// std::unique_lock<std::mutex> t_lock1(snap7_client->m_data_lock);
|
|
|
+ std::unique_lock<std::mutex> t_lock1(snap7_client->m_data_lock);
|
|
|
if (!clamps[i].safety_statu.is_timeout()) {
|
|
|
-// LOG(WARNING) << "id: " << i << ", we: " << clamps[i].safety_statu.wheel_exist << ", cx: " << clamps[i].safety_statu.cx * 1000;
|
|
|
+ // LOG(WARNING) << "id: " << i << ", we: " << clamps[i].safety_statu.wheel_exist << ", cx: " << clamps[i].safety_statu.cx * 1000;
|
|
|
// LOG(INFO) << "orid " << i;
|
|
|
// LOG(INFO) << "wheel_exist " << clamps[i].safety_statu.wheel_exist;
|
|
|
// LOG(INFO) << "cx " << clamps[i].safety_statu.cx * 1000;
|
|
|
// LOG(INFO) << "gap " << clamps[i].safety_statu.gap * 1000;
|
|
|
// LOG(INFO) << "clamp_completed " << clamps[i].safety_statu.clamp_completed;
|
|
|
- snap7_client->plcData.wheels[i].wheel_exist = clamps[i].safety_statu.wheel_exist;
|
|
|
- snap7_client->plcData.wheels[i].offset = clamps[i].safety_statu.cx * 1000;
|
|
|
- snap7_client->plcData.wheels[i].gap = clamps[i].safety_statu.gap * 1000;
|
|
|
- snap7_client->plcData.wheels[i].clamp_completed = clamps[i].safety_statu.clamp_completed;
|
|
|
- snap7_client->setCloudData(1 << i, clamps[i].last_cloud);
|
|
|
+ snap7_client->plcData.wheels[i].wheel_exist = clamps[i].safety_statu.wheel_exist;
|
|
|
+// snap7_client->plcData.wheels[i].offset = heart;
|
|
|
+// snap7_client->plcData.wheels[i].gap = 255 - heart;
|
|
|
+ snap7_client->plcData.wheels[i].offset = clamps[i].safety_statu.cx * 1000;
|
|
|
+ snap7_client->plcData.wheels[i].gap = clamps[i].safety_statu.gap * 1000;
|
|
|
+ snap7_client->plcData.wheels[i].clamp_completed = clamps[i].safety_statu.clamp_completed;
|
|
|
} else {
|
|
|
// snap7_client->plcData.clear();
|
|
|
}
|
|
|
+ snap7_client->setCloudData(1 << i, clamps[i].last_cloud);
|
|
|
+ TransitData::get_instance_pointer()->setCloud(i, clamps[i].last_cloud);
|
|
|
}
|
|
|
}
|
|
|
|