Asked — Edited

How To Track Red Color With Ar Drone In Sdk C #

Hi!

I want to make my own program to track red color with my ar drone, there are two tutorials that could help (tutorial 11 and tutorial 31) , I just want to know the code that the ar drone control panel and the camera device is using in C#

Greetings From Mexico

Jose


ARC Pro

Upgrade to ARC Pro

Take control of your robot's destiny by subscribing to Synthiam ARC Pro, and watch it evolve into a versatile and responsive machine.

PRO
Synthiam
#1  

Hello :)

Use the Tutorial 31 to determine how to connect and initialize the drone.

You'll need to do set the Movement Panel to be an AR Parrot Drone


_ezb.Movement.MovementType = Movement.MovementTypeEnum.ARDrone;

Then add a timer that will check for the location and set the direction. Good idea to set the timer for 100ms works well. Here's an example of the timer code.


private void timer1_Tick(object sender, EventArgs e) {

  ObjectLocation objectLocation = _camera.CameraBasicColorDetection.GetObjectLocationByColor(ColorDetection.ColorEnum.Red, 10, 100);

 _camera.UpdatePreview();

  if (!objectLocation.isFound)
    return;

  if (objectLocation.horizontalLocation == ObjectLocation.HorizontalLocationEnum.Left)
    _ezb.Movement.GoLeft();
  else if (objectLocation.horizontalLocation == ObjectLocation.HorizontalLocationEnum.Right)
    _ezb.Movement.GoRight();
  else if (objectLocation.horizontalLocation == ObjectLocation.HorizontalLocationEnum.Middle)
    _ezb.Movement.GoForward();
}

#2  

Hi DJ,

Can the built in ARC C# script read the $CameraCenterX $CameraCenterY $CameraIsTracking camera data? Or preferably is there a way Ez Script can use the equivalent of 3 ands in an if statement yet?

I've spent about 20 hours now reading everything post and using trial and error to get the camera wireless camera object location to work in the ARC C# scripting language because it can handle weighting algorythms with multiple ands in if statements to make some really smart robots with ping sensors.

if ((LeftDistance>Far) && (CenterDistance>Far) && (RightDistance>Far)){ ezb0.Movement.GoForward(50); System.Threading.Thread.Sleep(50); };

Below is a video of a ARC C# script using 3 ping sensors to autonomously navigate using distance weighting.

Click To Watch Video

BTW I really like the new interface layout.

A yes, no or wait answer could save me lots of time.

Thanks, Bill

PRO
Synthiam
#3  

In C#/VB Control there is no way currently to read EZ-Script variables, but I can do something about that in the future.

PS, this question does not pertain to the original thread. In the future, please create a new thread. :)

#4  

Thanks much DJ.

I'll be more mindful about thread contexts too.