Skip to content

Commit ff5bdcb

Browse files
committed
USB recording now available
1 parent 1069001 commit ff5bdcb

21 files changed

+210
-50
lines changed

bin/vs2005/test.exe

0 Bytes
Binary file not shown.

bin/vs2008/test.exe

-512 Bytes
Binary file not shown.

bin/vs2010/test.exe

-512 Bytes
Binary file not shown.

bin/vs2012/test.exe

-1 KB
Binary file not shown.

src/ardrone/ardrone.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ ARDrone::~ARDrone()
5858
// --------------------------------------------------------------------------
5959
// ARDrone::open(IP address of AR.Drone)
6060
// Description : Initialize the AR.Drone.
61-
// Return value : SUCCESS: 1 FAILED: 0
61+
// Return value : SUCCESS: 1 FAILURE: 0
6262
// --------------------------------------------------------------------------
6363
int ARDrone::open(const char *ardrone_addr)
6464
{
@@ -78,9 +78,6 @@ int ARDrone::open(const char *ardrone_addr)
7878
if (!getVersionInfo()) return 0;
7979
printf("AR.Drone Ver. %d.%d.%d\n", version.major, version.minor, version.revision);
8080

81-
// Initialize Video
82-
if (!initVideo()) return 0;
83-
8481
// Initialize AT Command
8582
if (!initCommand()) return 0;
8683

@@ -90,6 +87,9 @@ int ARDrone::open(const char *ardrone_addr)
9087
// Initialize Navdata
9188
if (!initNavdata()) return 0;
9289

90+
// Initialize Video
91+
if (!initVideo()) return 0;
92+
9393
// Wait for updating state
9494
Sleep(500);
9595

@@ -103,7 +103,7 @@ int ARDrone::open(const char *ardrone_addr)
103103
// --------------------------------------------------------------------------
104104
// ARDrone::update()
105105
// Description : Update the informations.
106-
// Return value : SUCCESS: 1 FAILED: 0
106+
// Return value : SUCCESS: 1 FAILURE: 0
107107
// --------------------------------------------------------------------------
108108
int ARDrone::update(void)
109109
{

src/ardrone/ardrone.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ class ARDrone {
273273
int onGround(void); // Check on ground
274274
void setAnimation(int id, int duration); // Flight animation
275275
void setLED(int id, float freq, int duration); // LED animation
276+
void startVideoRecord(void); // Video recording for AR.Drone 2.0
277+
void stopVideoRecord(void); // You should set a USB key with > 100MB to your drone
276278
void resetEmergency(void); // Reset emergency
277279
void resetWatchDog(void); // Reset hovering
278280

src/ardrone/command.cpp

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@
55
// --------------------------------------------------------------------------
66
// ARDrone::initCommand()
77
// Description : Initialize AT command.
8-
// Return value : SUCCESS: 1 FAILED: 0
8+
// Return value : SUCCESS: 1 FAILURE: 0
99
// --------------------------------------------------------------------------
1010
int ARDrone::initCommand(void)
1111
{
12-
// Open the socket
12+
// Open athe socket
1313
if (!sockCommand.open(ip, ARDRONE_COMMAND_PORT)) {
1414
printf("ERROR: UDPSocket::open(port=%d) failed. (%s, %d)\n", ARDRONE_COMMAND_PORT, __FILE__, __LINE__);
1515
return 0;
@@ -119,6 +119,60 @@ void ARDrone::setLED(int id, float freq, int duration)
119119
//Sleep(100);
120120
}
121121

122+
// --------------------------------------------------------------------------
123+
// ARDrone::startVideoRecord()
124+
// Start recording video.
125+
// This function is only for AR.Drone 2.0
126+
// You should set a USB key with > 100MB to your drone
127+
// Return value NONE
128+
// --------------------------------------------------------------------------
129+
void ARDrone::startVideoRecord(void)
130+
{
131+
if (version.major == ARDRONE_VERSION_2) {
132+
// Finalize video
133+
finalizeVideo();
134+
135+
// Enable video record
136+
sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
137+
sockCommand.sendf("AT*CONFIG=%d,\"video:video_on_usb\",\"TRUE\"\r", seq++);
138+
Sleep(100);
139+
140+
// Output video with MP4_360P_H264_720P_CODEC
141+
sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
142+
sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x82);
143+
Sleep(100);
144+
145+
// Initialize video
146+
initVideo();
147+
}
148+
}
149+
150+
// --------------------------------------------------------------------------
151+
// ARDrone::stopVideoRecord()
152+
// Stop recording video.
153+
// This function is only for AR.Drone 2.0
154+
// Return value NONE
155+
// --------------------------------------------------------------------------
156+
void ARDrone::stopVideoRecord(void)
157+
{
158+
if (version.major == ARDRONE_VERSION_2) {
159+
// Finalize video
160+
finalizeVideo();
161+
162+
sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
163+
sockCommand.sendf("AT*CONFIG=%d,\"video:video_on_usb\",\"FALSE\"\r", seq++);
164+
Sleep(100);
165+
166+
// Output video with 360P
167+
sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
168+
sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x81);
169+
Sleep(100);
170+
171+
// Initialize video
172+
initVideo();
173+
}
174+
}
175+
122176
// --------------------------------------------------------------------------
123177
// ARDrone::resetWatchDog()
124178
// Description : Stop hovering.

src/ardrone/config.cpp

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// --------------------------------------------------------------------------
66
// ARDrone::initConfig()
77
// Description : Initialize the Config.
8-
// Return value : SUCCESS: 1 FAILED: 0
8+
// Return value : SUCCESS: 1 FAILURE: 0
99
// --------------------------------------------------------------------------
1010
int ARDrone::initConfig(void)
1111
{
@@ -45,12 +45,22 @@ int ARDrone::initConfig(void)
4545
sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x81);
4646
Sleep(100);
4747

48+
// Output video with MP4_360P_H264_720P_CODEC
49+
//sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
50+
//sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x82);
51+
//Sleep(100);
52+
4853
// Output video with 720p
4954
//sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
5055
//sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x83);
5156
//Sleep(100);
5257

53-
// Set video channel
58+
// Output video with MP4_360P_H264_360P_CODEC
59+
//sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
60+
//sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x88);
61+
//Sleep(100);
62+
63+
// Set video channel to default
5464
sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
5565
sockCommand.sendf("AT*CONFIG=%d,\"video:video_channel\",\"0\"\r", seq++);
5666
Sleep(100);
@@ -85,7 +95,7 @@ int ARDrone::initConfig(void)
8595
//sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, 0x40);
8696
//Sleep(100);
8797

88-
// Set video channel
98+
// Set video channel to default
8999
sockCommand.sendf("AT*CONFIG=%d,\"video:video_channel\",\"0\"\r", seq++);
90100
Sleep(100);
91101

@@ -100,7 +110,7 @@ int ARDrone::initConfig(void)
100110
// --------------------------------------------------------------------------
101111
// ARDrone::getConfig()
102112
// Description : Get current configurations of AR.Drone.
103-
// Return value : SUCCESS: 1 FAILED: 0
113+
// Return value : SUCCESS: 1 FAILURE: 0
104114
// --------------------------------------------------------------------------
105115
int ARDrone::getConfig(void)
106116
{

src/ardrone/navdata.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// --------------------------------------------------------------------------
66
// ARDrone::initNavdata()
77
// Description : Initialize Navdata.
8-
// Return value : SUCCESS: 1 FAILED: 0
8+
// Return value : SUCCESS: 1 FAILURE: 0
99
// --------------------------------------------------------------------------
1010
int ARDrone::initNavdata(void)
1111
{
@@ -79,7 +79,7 @@ UINT ARDrone::loopNavdata(void)
7979
// --------------------------------------------------------------------------
8080
// ARDrone::getNavdata()
8181
// Description : Get current navigation data of AR.Drone.
82-
// Return value : SUCCESS: 1 FAILED: 0
82+
// Return value : SUCCESS: 1 FAILURE: 0
8383
// --------------------------------------------------------------------------
8484
int ARDrone::getNavdata(void)
8585
{

src/ardrone/udp.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ UDPSocket::~UDPSocket()
2222
// --------------------------------------------------------------------------
2323
// UDPSocket::open(IP address, Port number)
2424
// Description : Initialize specified socket.
25-
// Return value : SUCCESS: 1 FAILED: 0
25+
// Return value : SUCCESS: 1 FAILURE: 0
2626
// --------------------------------------------------------------------------
2727
int UDPSocket::open(const char *addr, int port)
2828
{
@@ -71,7 +71,7 @@ int UDPSocket::open(const char *addr, int port)
7171
// --------------------------------------------------------------------------
7272
// UDPSocket:::send2(Sending data, Size of data)
7373
// Description : Send the specified data.
74-
// Return value : SUCCESS: Number of sent bytes FAILED: 0
74+
// Return value : SUCCESS: Number of sent bytes FAILURE: 0
7575
// --------------------------------------------------------------------------
7676
int UDPSocket::send2(void *data, int size)
7777
{
@@ -88,7 +88,7 @@ int UDPSocket::send2(void *data, int size)
8888
// --------------------------------------------------------------------------
8989
// UDPSocket::sendf(Messages)
9090
// Description : Send the data with format.
91-
// Return value : SUCCESS: Number of sent bytes FAILED: 0
91+
// Return value : SUCCESS: Number of sent bytes FAILURE: 0
9292
// --------------------------------------------------------------------------
9393
int UDPSocket::sendf(char *str, ...)
9494
{
@@ -110,7 +110,7 @@ int UDPSocket::sendf(char *str, ...)
110110
// --------------------------------------------------------------------------
111111
// UDPSocket::receive(Receiving data, Size of data)
112112
// Description : Receive the data.
113-
// Return value : SUCCESS: Number of received bytes FAILED: 0
113+
// Return value : SUCCESS: Number of received bytes FAILURE: 0
114114
// --------------------------------------------------------------------------
115115
int UDPSocket::receive(void *data, int size)
116116
{

0 commit comments

Comments
 (0)