赞
踩
花了两天的时间 ,终于在ARDrone SDK 1.8,firmware 1.7.4平台下将SDK自带的Win32 Demo编译完成。
跟随SDK1.8和firmware1.7.4的发布,Linux和IPhone端例子用程序均有更新,Windows平台下的例子程序貌似没有在更新了,而且Windows平台下的SDK编译时也会蹦出来一堆的错误,下面就来一一解决这些错误。
首先编译ARDrone SDK 1.8,出现了以下错误:
1、error C2065: 'tv' : undeclared identifier
error C2224: left of '.tv_sec' must have struct/union type
error C2065: 'tv' : undeclared identifier
error C2224: left of '.tv_usec' must have struct/union type
win32平台同样需要结构体tv。在ardrone_control.c文件中,修改为:
#ifdef _WIN32
int timeout_windows=1000;/*milliseconds*/
#endif
struct timeval tv;
即可。
2、error C2275: 'video_macroblock_t' : illegal use of this type as an expression
error C2065: 'macroblock_root' : undeclared identifier
error C2065: 'macroblock_root' : undeclared identifier
error C2065: 'macroblock_root' : undeclared identifier
error C2275: 'uint32_t' : illegal use of this type as an expression
error C2146: syntax error : missing ';' before identifier 'UI32_i'
error C2065: 'UI32_i' : undeclared identifier
error C2143: syntax error : missing ';' before 'type'
error C2275: 'uint32_t' : illegal use of this type as an expression
error C2146: syntax error : missing ';' before identifier 'y_size'
error C2065: 'y_size' : undeclared identifier
error C2065: 'c_size' : undeclared identifier
按照C语言严格的语法定义,函数内部所使用的变量,必须在函数的前部进行定义。
所以,按照这个标准来修改即可。
3、arpa/inet.h,ifaddrs.h文件无法找到。
Windows平台当然不需要这些Linux平台下的文件。连同wifi_config.c文件中使用到ifaddr结构体的地方直接注释掉即可。
4、无法找到文件<SDL/SDL.h>
新版SDL库的头文件中SDL.h文件直接放在include目录下,没有单独的目录。
修改为<SDL.h>即可。
5、无法找到<ardrone_at.c>文件。
很诡异的错误,SDK1.8的源代码包中并没有这个文件,但它的工程项目中却又包含了这个文件。
通过查看ARDroneLib\Soft\Lib\ardrone_tool\AT目录,发现其中包含了ardrone_at_mutex.c文件,是ardrone_at.c实现了线程同步的版本。
从SDK的工程项目中移除ardrone_at.c文件,将ardrone_at_mutex.c文件添加到工程项目中。
编译出现下面这个错误:AT_CODEC_FUNCTIONS_PTRS的使用方式非法。
将函数内部的代码修改为:
if( funcs != NULL)
{
memcpy(&func_ptrs, funcs, sizeof(*funcs));
}
else
{
#if defined (_MSC_VER)
AT_CODEC_FUNCTIONS_PTRS ptrs =
{
/*init*/host_init,
/*shutdown*/host_shutdown,
/*enable*/host_enable,
/*open*/host_open,
/*close*/host_close,
/*write*/host_write,
/*read*/host_read
};
#else
AT_CODEC_FUNCTIONS_PTRS ptrs =
{
.init = host_init,
.shutdown = host_shutdown,
.enable = host_enable,
.open = host_open,
.close = host_close,
.read = host_read,
.write = host_write,
};
#endif
vp_os_mutex_init(&at_mutex);
ATcodec_Init_Library( &ptrs );
}即可。
6、Error 2 error LNK2001: unresolved external symbol _ardrone_general_navdata_release navdata.obj Win32Client
Error 3 error LNK2001: unresolved external symbol _ardrone_general_navdata_process navdata.obj Win32Client
Error 4 error LNK2001: unresolved external symbol _ardrone_general_navdata_init navdata.obj Win32Client
函数有声明却没有实现,当然就链接出错了。
在ardrone_navdata_control.c文件的末尾添加以下几段代码即可:
C_RESULT ardrone_general_navdata_init( void* data ) {
return C_OK;
}
C_RESULT ardrone_general_navdata_process( const navdata_unpacked_t* const navdata ) {
return C_OK;
}
C_RESULT ardrone_general_navdata_release( void ) {
return C_OK;
}
7、Error 4 error LNK2001: unresolved external symbol _custom_configuration_headers
Error 5 error LNK2001: unresolved external symbol _available_configurations
//extern void p264_codec_alloc( video_controller_t* controller );
//extern void p264_codec_free( video_controller_t* controller );
// case P264_CODEC:
// p264_codec_alloc( controller );
// break;
// case P264_CODEC:
// p264_codec_free( controller );
// break;
Input device DirectX Keyboard added
Input device DirectX Gamepad init failed
Starting thread directx_renderer_thread
Starting thread video_stage
Starting thread navdata_update
Video stage thread initialisation
Thread navdata_update in progress...
Starting thread ardrone_control
Sending flat trim - make sure the drone is horizontal at client startup.
[Pitch 0.000000] [Roll 0.000000] [Yaw 0.000000] [Gaz 0.000000] port 5554
[Pitch 0.000000] [Roll 0.000000] [Yaw 0.000000] [Gaz 0.000000]
Connection timed out
ARDrone SDk 1.8,固件 1.7.4,最新的平台,windows平台下新的demo程序,都可以跑起来了。
下面可以进行其他方面的实验了。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。