本文整理汇总了C++中ARDrone::flatTrim方法的典型用法代码示例。如果您正苦于以下问题:C++ ARDrone::flatTrim方法的具体用法?C++ ARDrone::flatTrim怎么用?C++ ARDrone::flatTrim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ARDrone
的用法示例。
在下文中一共展示了ARDrone::flatTrim方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: controls
// --------------------------------------------------------------------------
// controls()
// This function sends commands to the drone using an Xbox Controller.
// --------------------------------------------------------------------------
void controls()
{
// Check for Xbox Controller
if(player1->IsConnected())
{
// 'A' button
if(player1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_A)
{
// Change camera
static int cameraToggle = 0;
ardrone.setCamera(++cameraToggle%4);
}
// 'B' button
if(player1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_B)
{
ardrone.emergency();
}
// 'X' button
if(player1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_X)
{
ardrone.flatTrim();
}
// 'Y' button
/*if(player1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_Y)
{
}*/
// 'Start' button
if(player1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_START)
{
if (ardrone.onGround())
{
ardrone.takeoff();
}
else
{
ardrone.landing();
}
}
// 'Back' button
if(player1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_BACK)
{
// Exit the program.
if (ardrone.onGround())
{
exit(0);
}
}
// Left Thumb-Stick Press
/*if(player1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_LEFT_THUMB)
{
}*/
// Right Thumb-Stick Press
/*if(player1->GetState().Gamepad.wButtons & XINPUT_GAMEPAD_RIGHT_THUMB)
{
}*/
// AR.Drone flight controls
//if (!ardrone.onGround())
{
// Check left thumbStick
double leftThumbY = player1->GetState().Gamepad.sThumbLY / STICK_RANGE;
double leftThumbX = player1->GetState().Gamepad.sThumbLX / STICK_RANGE;
// Check the dead zone
if (leftThumbY < STICK_DEAD_ZONE && leftThumbY > -STICK_DEAD_ZONE)
{
leftThumbY = 0;
}
if (leftThumbX < STICK_DEAD_ZONE && leftThumbX > -STICK_DEAD_ZONE)
{
leftThumbX = 0;
}
// Check left thumbStick
double rightThumbY = player1->GetState().Gamepad.sThumbRY / TRIGGER_RANGE;
double rightThumbX = player1->GetState().Gamepad.sThumbRX / TRIGGER_RANGE;
// Check the dead zone
if (rightThumbY < STICK_DEAD_ZONE && rightThumbY > -STICK_DEAD_ZONE)
{
rightThumbY = 0;
}
if (rightThumbX < STICK_DEAD_ZONE && rightThumbX> -STICK_DEAD_ZONE)
{
rightThumbX = 0;
}
double rightTrigger = player1->GetState().Gamepad.bRightTrigger / TRIGGER_RANGE;
double leftTrigger = player1->GetState().Gamepad.bLeftTrigger / TRIGGER_RANGE;
double gaz = rightTrigger - leftTrigger;
// Move
ardrone.move3D(rightThumbY*10, -rightThumbX*10, gaz*10, -leftThumbX*10);
}
//.........这里部分代码省略.........