gimbal.cxx
4.9 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
#include <string>
#include <thread>
#include <sys/time.h>
#include "uav_core.h"
#include "uav_logger.h"
#include "uav_upgrade.h"
#include "uav_platform.h"
#include "uav_data_type.h"
#include "uav_sdk_app_info.h"
#include "uav_fc_subscription.h"
#include "uav_low_speed_data_channel.h"
#include "uav_high_speed_data_channel.h"
#include "uav_gimbal.h"
#include "proto/tracerMessage.pb.h"
#include "uav_error.h"
static T_UAVReturnCode GetSystemState(T_UavGimbalSystemState *systemState);
static T_UAVReturnCode GetAttitudeInformation(T_UavGimbalAttitudeInformation *attitudeInformation);
static T_UAVReturnCode GetCalibrationState(T_UavGimbalCalibrationState *calibrationState);
static T_UAVReturnCode GetRotationSpeed(T_UAVAttitude3d *rotationSpeed);
static T_UAVReturnCode GetJointAngle(T_UAVAttitude3d *jointAngle);
static T_UAVReturnCode StartCalibrate(void);
static T_UAVReturnCode SetControllerSmoothFactor(uint8_t smoothingFactor, E_UavGimbalAxis axis);
static T_UAVReturnCode SetPitchRangeExtensionEnabled(bool enabledFlag);
static T_UAVReturnCode SetControllerMaxSpeedPercentage(uint8_t maxSpeedPercentage, E_UavGimbalAxis axis);
static T_UAVReturnCode RestoreFactorySettings(void);
static T_UAVReturnCode SetMode(E_UAVGimbalMode mode);
static T_UAVReturnCode Reset(E_UAVGimbalResetMode mode);
static T_UAVReturnCode FineTuneAngle(T_UAVAttitude3d fineTuneAngle);
void registThreadFunc(void);
int main(int argc, char *argv[])
{
T_AUserInfo usrInfo;
logger_init(std::string(argv[1]));
if(false == uav_sdk_app_info_init(&usrInfo)) {
LOG_ERROR("uav_sdk_app_info_init failed");
return -1;
}
UAV_Core_Init(&usrInfo);
UAV_Core_SetAlias("gimbalV1");
UAV_Uart_Init("/dev/pts/20",115200);
UavGimbal_Init();
LOG_INFO(" gimbal init ");
std::thread registerThread(registThreadFunc);
registerThread.detach();
return UAV_Core_ApplicationStart();
}
void registThreadFunc(void)
{
int ret = 0;
//wait register success
if(false == wait_register_ready(100)){
LOG_ERROR("waitHandShakeRegister failed");
return;
}
//订阅Speaker消息,进行对应的speaker操作
ret =UAV_LowSpeedDataChannel_Init();
LOG_INFO(" channel init ret :{}", ret);
T_UavGimbalCommonHandler *commonHandler =new T_UavGimbalCommonHandler();
commonHandler->GetSystemState = GetSystemState;
commonHandler->GetAttitudeInformation = GetAttitudeInformation;
commonHandler->GetCalibrationState = GetCalibrationState;
commonHandler->GetRotationSpeed = GetRotationSpeed;
commonHandler->GetJointAngle = GetJointAngle;
// s_commonHandler.Rotate = commonHandler->UavTest_GimbalRotate;
commonHandler->StartCalibrate = StartCalibrate;
commonHandler->SetControllerSmoothFactor = SetControllerSmoothFactor;
commonHandler->SetPitchRangeExtensionEnabled = SetPitchRangeExtensionEnabled;
commonHandler->SetControllerMaxSpeedPercentage = SetControllerMaxSpeedPercentage;
commonHandler->RestoreFactorySettings = RestoreFactorySettings;
commonHandler->SetMode = SetMode;
commonHandler->Reset = Reset;
commonHandler->FineTuneAngle = FineTuneAngle;
ret = UavGimbal_RegCommonHandler(commonHandler);
LOG_INFO(" gimbal reg ret :{}", ret);
LOG_INFO("end registThreadFunc");
}
static T_UAVReturnCode GetSystemState(T_UavGimbalSystemState *systemState)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode GetAttitudeInformation(T_UavGimbalAttitudeInformation *attitudeInformation)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode GetCalibrationState(T_UavGimbalCalibrationState *calibrationState)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode GetRotationSpeed(T_UAVAttitude3d *rotationSpeed)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode GetJointAngle(T_UAVAttitude3d *jointAngle)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode StartCalibrate(void)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode SetControllerSmoothFactor(uint8_t smoothingFactor, E_UavGimbalAxis axis)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode SetPitchRangeExtensionEnabled(bool enabledFlag)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode SetControllerMaxSpeedPercentage(uint8_t maxSpeedPercentage, E_UavGimbalAxis axis)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode RestoreFactorySettings(void)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode SetMode(E_UAVGimbalMode mode)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode Reset(E_UAVGimbalResetMode mode)
{
return UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}
static T_UAVReturnCode FineTuneAngle(T_UAVAttitude3d fineTuneAngle)
{
T_UAVReturnCode uavReturnCode = UAV_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
return uavReturnCode;
}