diff --git a/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp b/Com_server/fly_monitor/src/Com_SerialWritingThread.cpp index 9fd26cffd42b4cb959115368cf5d25b52856d2a6..97e45962fe16d37de91d5333132dc6818b3040a6 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; } }