From 3527377bc7c3bdf3d6361c9f722d1dd5d6173f3a Mon Sep 17 00:00:00 2001 From: StaY <stephane.yang@ensea.fr> Date: Thu, 19 Oct 2023 15:32:07 +0200 Subject: [PATCH] fly_monitor update: bit of code adjustment with updated comment --- .../src/Com_SerialWritingThread.cpp | 35 +++++++++---------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp b/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp index 9fd26cf..97e4596 100644 --- a/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp +++ b/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp @@ -156,43 +156,40 @@ int Serial_Port_WritingThread::main_loop(struct timeval *front_msg, struct timev // Position control mode if (drone1.flight_mode == FlightMode::Posctl) { + // See "drone_joyRemote" or "drone" promethe script to check if the order below is correct when you launch them /* - motors: 0 -> vertical (forward to backward) [-1.0 to 1.0] - 1 -> horizontal (left to right) [-1.0 to 1.0] - 2 -> rotation (ccw to cw) [-1.0 to 1.0] - ~~3 -> gas direct (no control) [1.0 to -1.0]~~ (can be used but not advised here) - 4 -> altitude command (controlled throttle) [0.0 to 1.0] + blc_control_motors: + 0 -> vertical (forward to backward) [-1.0 to 1.0] + 1 -> horizontal (left to right) [-1.0 to 1.0] + 2 -> rotation (ccw to cw) [-1.0 to 1.0] + ~~3 -> gas direct (no control) [1.0 to -1.0]~~ (can be used but not advised here) + 4 -> altitude command (controlled throttle) [0.0 to 1.0] x = pitch -> forward(1000), backward(-1000) y = roll -> right(1000), left(-1000) z = thrust -> max gas (1000), no gas (-1000) (0 means enough gas so that there is no thrust but also means you want to land) r = yaw -> CCW(1000), CW(-1000) */ + float xx = -blc_control_motors.floats[0]; + float yy = blc_control_motors.floats[1]; + float zz = blc_control_motors.floats[4]; // command from altitude control + float zz_direct = -0.5f * blc_control_motors.floats[3] + 0.5f; // control gas with throttle axis + float rr = - 2 * blc_control_motors.floats[2]; if(drone1.motors == ARM) { // Control in altitude ///* - drone1.command_directControl(-blc_control_motors.floats[0] - ,blc_control_motors.floats[1] - ,blc_control_motors.floats[4] - ,- 2 * blc_control_motors.floats[2]); + drone1.command_directControl(xx,yy,zz,rr); //*/ // Control directly /* - drone1.command_directControl(-blc_control_motors.floats[0] - ,blc_control_motors.floats[1] - ,-0.5f * blc_control_motors.floats[3] + 0.5f - ,-blc_control_motors.floats[2]); + drone1.command_directControl(xx,yy,zz_direct,rr); //*/ } else { - std::cout << "x = " << - blc_control_motors.floats[0] - << ", y = " << blc_control_motors.floats[1] - << ", z = " << blc_control_motors.floats[4] - << ", r = " << - 2 * blc_control_motors.floats[2] - << std::endl; - std::cout << "Drone is not armed, can't control" << std::endl; + std::cout << "x = " << xx << ", y = " << yy << ", z = " << zz << ", r = " << rr << std::endl; + std::cout << "Drone is not armed, can't control. You can type 'reset' to stop this print." << std::endl; } } -- GitLab