-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpcclient.cpp
60 lines (50 loc) · 1.3 KB
/
rpcclient.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "rpcclient.h"
RPCclient::RPCclient()
{
while(!((uint8_t)client.getConnectionState() == 1))
{
qDebug() << "Connecting to AirSim....." << (uint8_t)client.getConnectionState();;
client.confirmConnection();
}
while(!(client.isApiControlEnabled() == true))
{
qDebug() << "Enabling API control.....";
client.enableApiControl(true);
}
// joystick_manager = new joystick(&client);
}
void RPCclient::arm_disarm(bool arm)
{
if(arm == true)
client.armDisarm(true);
else
client.armDisarm(false);
}
void RPCclient::takeOff(float time_out)
{
client.takeoffAsync(time_out);
}
void RPCclient::moveByRC(RCData& rc_data)
{
// client.moveByVelocityAsync(rc_data.pitch*5, rc_data.roll*5, rc_data.throttle*5, 0.5, DrivetrainType::MaxDegreeOfFreedom, yaw_mode);
// client.rotateByYawRateAsync(rc_data.yaw*50, 0.5);
joystick_manager.move(rc_data, &client);
}
void RPCclient::moveByRCYaw(RCData &rc_data)
{
client.rotateByYawRateAsync(rc_data.yaw*50, 0.5);
}
void RPCclient::land(float time_out)
{
client.landAsync(time_out);
}
void RPCclient::disconnect()
{
client.reset();
}
MultirotorState RPCclient::getMultirotorState()
{
MultirotorState uav_state;
uav_state = client.getMultirotorState();
return uav_state;
}