From f986c39b9de9a0ec09db6dfa17c2ab33d3b308f0 Mon Sep 17 00:00:00 2001
From: StaY <stephane.yang@ensea.fr>
Date: Tue, 10 Oct 2023 11:29:06 +0200
Subject: [PATCH] update fly_monitor to hava a slower writing thread, but less
 limit on movement control

---
 Com_server/fly_monitor/src/Com_SerialWritingThread.cpp | 4 ++--
 Com_server/fly_monitor/src/Data_Drone.cpp              | 8 ++++----
 Com_server/fly_monitor/src/TestDroneRemoteControl.cpp  | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp b/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp
index cdaf949..9fd26cf 100644
--- a/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp
+++ b/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp
@@ -174,7 +174,7 @@ int Serial_Port_WritingThread::main_loop(struct timeval *front_msg, struct timev
          drone1.command_directControl(-blc_control_motors.floats[0]
                               ,blc_control_motors.floats[1]
                               ,blc_control_motors.floats[4]
-                              ,-blc_control_motors.floats[2]);
+                              ,- 2 * blc_control_motors.floats[2]);
          //*/
          
          // Control directly
@@ -190,7 +190,7 @@ int Serial_Port_WritingThread::main_loop(struct timeval *front_msg, struct timev
          std::cout << "x = " << - blc_control_motors.floats[0]
                  << ", y = " << blc_control_motors.floats[1]
                  << ", z = " << blc_control_motors.floats[4]
-                 << ", r = " << - blc_control_motors.floats[2]
+                 << ", r = " << - 2 * blc_control_motors.floats[2]
                  << std::endl;
          std::cout << "Drone is not armed, can't control" << std::endl;
       }
diff --git a/Com_server/fly_monitor/src/Data_Drone.cpp b/Com_server/fly_monitor/src/Data_Drone.cpp
index e896c0a..2c93207 100644
--- a/Com_server/fly_monitor/src/Data_Drone.cpp
+++ b/Com_server/fly_monitor/src/Data_Drone.cpp
@@ -997,12 +997,12 @@ int Drone::command_directControl(float x, float y, float z, float r)
 
    if (x > upper_limit) x = upper_limit;
    if (x < lower_limit) x = lower_limit;
-   if (y > upper_limit) y = upper_limit;
-   if (y < lower_limit) y = lower_limit;
+   if (y > 1.f) y = 1.f;
+   if (y < -1.f) y = -1.f;
    if (z > 1.f ) z =  1.f;
    if (z < -1.f) z = -1.f;
-   if (r > upper_limit) r = upper_limit;
-   if (r < lower_limit) r = lower_limit;
+   if (r > 1.f) r = 1.f;
+   if (r < -1.f) r = -1.f;
    
    xx=static_cast<int16_t>(x * 1000);
    yy=static_cast<int16_t>(y * 1000);
diff --git a/Com_server/fly_monitor/src/TestDroneRemoteControl.cpp b/Com_server/fly_monitor/src/TestDroneRemoteControl.cpp
index cc0fff6..2c996b3 100644
--- a/Com_server/fly_monitor/src/TestDroneRemoteControl.cpp
+++ b/Com_server/fly_monitor/src/TestDroneRemoteControl.cpp
@@ -862,7 +862,7 @@ int main(int argc, char *argv[])
    compassx.open("compassx.txt");
    compassy.open("compassy.txt");
    
-   writingThread = shared_ptr<Serial_Port_WritingThread>(new Serial_Port_WritingThread(50000, 1000));
+   writingThread = shared_ptr<Serial_Port_WritingThread>(new Serial_Port_WritingThread(70000, 1000));
    readingThread = shared_ptr<Serial_Port_ReadingThread>(new Serial_Port_ReadingThread(1000, 1000));
    
    cout << "Welcome to pixhawk server" << endl;
-- 
GitLab