Skip to content
Snippets Groups Projects
Commit 3527377b authored by Stéphane Yang's avatar Stéphane Yang
Browse files

fly_monitor update: bit of code adjustment with updated comment

parent aa9ec068
No related branches found
No related tags found
No related merge requests found
Pipeline #6265 passed
......@@ -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;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment