ARDrone2Windows / SDK

Pilot your AR.Drone 2.0 from a Windows Store or Windows Phone app
59 stars 56 forks source link

Unable to change the video input #7

Closed MikeyMCZ closed 10 years ago

MikeyMCZ commented 11 years ago

Hello,

I am trying to get video in 720p, however I am still getting 360p. I have tried to call configuration: drone.SetConfiguration(drone.Configuration.Video.Codec.Set((int)ARDRONE_VIDEO_CODEC.ARDRONE_VIDEO_CODEC_H264_720P).ToCommand()); No luck. Still getting 360p. Is there any way how to change the video stream resolution?

Ruslan-B commented 11 years ago

The same story as with issue #6. This setting could be changed only in multi-configuration mode, which is not implemented, but you can try to send something like this:

drone.Client.PostCommand("AT*CONFIG=[SEQUENCE],""custom:session_id"",""66443ff6""");
drone.Client.PostCommand("AT*CTRL=[SEQUENCE],5,0");
Thread.Sleep(500);
drone.Client.PostCommand("AT*CONFIG=[SEQUENCE],""custom:application_id"",""dc8a5834""");
drone.Client.PostCommand("AT*CTRL=[SEQUENCE],5,0");
Thread.Sleep(500);
drone.Client.PostCommand("AT*CONFIG_IDS=[SEQUENCE],""66443ff6"",""a07a12ac"",""dc8a5834""");
drone.Client.PostCommand("AT*CONFIG=[SEQUENCE],""custom:profile_id"",""a07a12ac""");
drone.Client.PostCommand("AT*CTRL=[SEQUENCE],5,0");
Thread.Sleep(500);

You can try to read configuration back and it should reflect new ids for application, session and profile. After than your can send you command like this:

drone.Client.PostCommand("AT*CONFIG_IDS=[SEQUENCE],""66443ff6"",""a07a12ac"",""dc8a5834""");
drone.SetConfiguration(drone.Configuration.Video.Codec.Set((int)ARDRONE_VIDEO_CODEC.ARDRONE_VIDEO_CODEC_H264_720P).ToCommand());
MikeyMCZ commented 11 years ago

I have tried that and no luck. I have tried to send these config commands as soon as possible. The session id command was sent with sequence number 3. No luck. After the configuration was retrieved - the session is was still default - all zeros. In the issue #6 you have stated that you are able to send the commands and configs that are being ignored by this SDK. Do you have any special flow of commands? Is it possible that you post the flow of AT Commands that are used by your code? Maybe there is something missing or we need to remove something. Thank you.

Ruslan-B commented 11 years ago

Pity and weird, however delay is essential. I extracted these commands from mine library and adopted them to this SDK, thus this is almost a bare sequence as this sdk supports string commands and will replace [SEQUENCE] automatically. It is a special command flow - multi-configuration mode. The main idea that you should change application id, session id and profile id in drone configuration to be able change video codec. Then you should send AT*CONFIG_IDS="sessiosion-id","profile-id","appication-id" before any configuration command. The Thread.Sleep(500) should emulate something that I call AckControlAndWaitForConfirmation. I tested on bare commands in mine library and it used to work well by doing delay only. Also I must say that I never tried these trick on this SDK, but a lot of stuff still looks like one of the earliest versions of mine library. Btw what is firmware version on your drone?

MikeyMCZ commented 11 years ago

Version of the drone: general:num_version_soft = 2.4.1.

custom:application_id = a1b2c3d4 custom:profile_id = b2c3d4e5 custom:session_id = c3d4e5f6

Commands that I am sending to the drone: 00:00:14.6233819 - COMMAND: AT_CONFIG_IDS=3,"c3d4e5f6","b2c3d4e5","a1b2c3d4" 00:00:14.7146115 - COMMAND: AT_CONFIG=4,"video:video_codec","131" 00:00:14.7644812 - COMMAND: AT_CTRL=5,5,0 00:00:15.2631275 - COMMAND: AT_CTRL=6,4,0

And the video is still 360p.

Ruslan-B commented 11 years ago

I see from your sequence numbers that something went wrong as only to change of application_id, profile_id and session_id you should send 7 commands (I'm not taking in account drone initialization sequence). As for ids: custom:application_id = a1b2c3d4 custom:profile_id = b2c3d4e5 custom:session_id = c3d4e5f6 Did you get them back by reading configuration back or these values just afters sending?

MikeyMCZ commented 11 years ago

I wasn't changing these IDs. These are Ids that were returned from the drone configuration after the start. This is the whole communication (the configuration was shorted): 00:00:00.2120615 - Buffer: AT*CTRL=1,5,0

Starting media. 00:00:00.3238865 - Buffer: AT*CTRL=2,4,0

Config:Buffer (31) Configuration Brute: general:num_version_config = 1

Config:Buffer (4723) Configuration Brute: general:num_version_mb = 34 general:num_version_soft = 2.4.1 ................... custom:application_id = a1b2c3d4 custom:profile_id = b2c3d4e5 custom:session_id = c3d4e5f6 ......................

00:00:14.6233819 - Buffer: AT_CONFIG_IDS=3,"c3d4e5f6","b2c3d4e5","a1b2c3d4" 00:00:14.7146115 - Buffer: AT_CONFIG=4,"video:video_codec","131"

00:00:14.7644812 - Buffer: AT_CTRL=5,5,0 00:00:15.2631275 - Buffer: AT_CTRL=6,4,0

Ruslan-B commented 11 years ago

That's looks strange, however every time when you connect to drone you need restore previous session by setting session id in configuration. Thus if you managed to set app id,profile id and session id in advance you can restore whole configuration by sending this sequence: AT_CTRL=[SEQUENCE],5,0 Thread.Sleep(500) AT_CONFIG=[SEQUENCE],""custom:session_id"",""c3d4e5f6"" AT*CTRL=[SEQUENCE],5,0 Thread.Sleep(500)

MikeyMCZ commented 11 years ago

OK, we have solved it. Problem was with the end signs of the Commands. When I have added the "\r" at the end of the commands string - I was able to change the video stream to 720p. My C# code:

_droneClient.PostCommand("AT*CONFIG=[SEQUENCE],\"custom:session_id\",\"66443ff6\"\r");
_droneClient.PostCommand("AT*CTRL=[SEQUENCE],5,0\r");
await Task.Delay(500);

_droneClient.PostCommand("AT*CONFIG=[SEQUENCE],\"custom:application_id\",\"dc8a5834\"\r");
_droneClient.PostCommand("AT*CTRL=[SEQUENCE],5,0\r");
await Task.Delay(500);

_droneClient.PostCommand("AT*CONFIG_IDS=[SEQUENCE],\"66443ff6\",\"a07a12ac\",\"dc8a5834\"\r");
_droneClient.PostCommand("AT*CONFIG=[SEQUENCE],\"custom:profile_id\",\"a07a12ac\"\r");
_droneClient.PostCommand("AT*CTRL=[SEQUENCE],5,0\r");
await Task.Delay(500);

_droneClient.PostCommand("AT*CONFIG_IDS=[SEQUENCE],\"66443ff6\",\"a07a12ac\",\"dc8a5834\"\r");
_droneClient.PostCommand(_droneClient.Configuration.Video.Codec.Set((int)ARDRONE_VIDEO_CODEC.ARDRONE_VIDEO_CODEC_H264_720P).ToCommand());
_droneClient.PostCommand("AT*CTRL=[SEQUENCE],5,0\r");
await Task.Delay(500);
_droneClient.PostCommand("AT*CTRL=[SEQUENCE],4,0\r");

Thank you for the support.

Ruslan-B commented 11 years ago

Awesome! You're welcome.