add longer waiting on LIDAR

This commit is contained in:
Sem van der Hoeven
2023-06-05 17:09:57 +02:00
parent c967eea3f2
commit 582e65126e
2 changed files with 11 additions and 5 deletions

View File

@@ -13,7 +13,7 @@
<h1 class="header">5G Drone API</h1>
<!-- <div class="video"> -->
<div class="mainvideo">
<p>Camera view:</p>
<p id="cameraview">Camera view:</p>
<canvas id="result-video" style="border: 1px solid blue;" width="800" height="600"></canvas>
<div id="connectedbuttons">
<div id="connectedstatus">
@@ -64,10 +64,12 @@
assign_button_callbacks();
openSocket = () => {
document.getElementById("cameraview").innerHTML = "Camera view: Connecting...";
socket = new WebSocket("ws://10.100.0.40:9002/");
let msg = document.getElementById("result-video");
socket.addEventListener('open', (e) => {
console.log("Connected to video")
document.getElementById("cameraview").innerHTML = "Camera view: Connected";
});
socket.addEventListener('message', (e) => {
let ctx = msg.getContext("2d");
@@ -78,6 +80,10 @@
ctx.drawImage(image, 0, 0, 800, 600);
});
});
socket.addEventListener('close', (e) => {
console.log("Disconnected from video")
document.getElementById("cameraview").innerHTML = "Camera view: Disconnected. Reload the page to reconnect";
});
}
// Helper function to decode base64 image and set it as source of <img> element

View File

@@ -256,14 +256,14 @@ public:
*/
void check_lidar_health()
{
if (!this->received_lidar_message && !this->failsafe_enabled && this->lidar_health_checks > 10)
if (!this->received_lidar_message && !this->failsafe_enabled && this->lidar_health_checks > 20)
{
RCLCPP_WARN(this->get_logger(), "Lidar not sending messages, enabling failsafe");
enable_failsafe(u"No healthy connection to LIDAR!");
enable_failsafe(u"No healthy connection to LIDAR! Check the LIDAR USB cable and restart the drone.");
}
this->received_lidar_message = false;
this->has_received_first_lidar_message = true;
if (this->lidar_health_checks <= 10)
if (this->lidar_health_checks <= 20)
{
this->lidar_health_checks++;
}
@@ -297,7 +297,7 @@ public:
if (!this->failsafe_enabled)
{
if (!this->has_received_first_lidar_message) {
this->enable_failsafe(u"Waiting for LIDAR timed out! Consider restarting the drone.");
this->enable_failsafe(u"Waiting for LIDAR timed out! Check the LIDAR USB connection and consider restarting the drone.");
return;
}
RCLCPP_INFO(this->get_logger(), "Incoming request\nfront_back: %f\nleft_right: %f\nup_down: %f\nangle: %f", request->front_back, request->left_right, request->up_down, request->angle);