Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited


Hello everyone!

I've come across ARC in my hopeless search for making my AR.Drone do things. And in my googling I saw this program with some really cool projects made in it (all kinds of robots including R2 <3) so I got it right away and started some projects. I managed to control it with the KB, cool! After that I managed to write a little script that made it fly around, cool (when it worked). Now I'm stuck at trying to make it follow things without crashing into every wall/tree on the planet. So I've made a simple project with a Camera control and a movement panel.

-While derping around playing with the camera tracking options I noticed a huge first problem: the camera processing power is too low for no reason. ARC sits around 30% CPU usage in task manager and yet I'm getting around 12fps with color tracking. In HAAR tracking it sits at 1 fps with ~2s latency, again, with <20% cpu usage in task manager.

-I said okay, I can work with 12 FPS, let's give it a try. So I made this basic object tracking script that runs when the camera tracks something:
Link to script
In theory it should work fine with the grid maxed inside (no middle, just top-left, top-right, bottom-left, bottom-right) and 640x480 resolution, or at least I should see the drone struggle at keeping the red pig (my stupid object) in sight. But here's the second problem: the signals sent from the camera module to the Movement Panel are not processed properly, some, well, the majority of them are skipped entirely(confirmed by wireshark). So the drone ended up beating every wall in the room. I don't know if it's a bug or a feature (for not making the pc catch fire) but I felt like I needed to address the issue. Also, the grid lines reset at a weird position after reopening the project.

So, the question: I know I must be doing something wrong but can someone please help me get around these problems? I've tried all sorts of stuff, from urbi to ros and everything seems to spit errors all over the place so you are my last hope in making something really cool out of a toy :3

Below is a SS with pc specs+haar tracking+task manager and the project file

User-inserted image


AI Support Bot
Related Content
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
HAAR is a high processing algorithm. Do not use it unless you're an experienced professional with HAAR cascade creation abilities and have an understanding of optimizing cascades - specifically for the reason you discovered. This is not an issue with the software and is expected behavior.

Google is your friend for learning about math and algorithms: https://www.google.ca/search?sourceid=chrome-psyapi2&ion=1&espv=2&ie=UTF-8&q=haar%20cascade%20performance&oq=haar%20cascade%20performance&aqs=chrome..69i57j0.3093j1j7

Also, the desired resolution for video processing must be thought-out. Are you viewing the image for your own personal image quality requirements? Or, are you processing video data for tracking? Choose one...

Let me demonstrate some math...
160x120 = 57,600 Bytes
320x240 = 230,400 Bytes
640x480 = 921,600 Bytes

Can you recognize the size difference between each resolution? The resolution plays very little part in object recognition or tracking. The resolution is for your eyes to view the image. Processing 640x480 (921,600 Bytes per frame) at 20fps is 18,420,000 Bytes per second. That's 18 megabytes per second of data you wish to process through your CPU, and that is before you have even considered introducing the analysis of the HAAR cascde and the math required for that...

If you think processing millions of calculations on 18mb/sec is not going to consume 30% cpu...:)

Use the Object Tracking instead - and do not use HAAR.

*note: i removed the requesting assistance flag from this post as it is not applicable.
I completely understand it's a highly demanding algorithm, what I don't get is why isn't it eating up all the resources available instead of only 20% of them.
Also, do you have any idea why the script won't work as intended, more exactly, why doesn't it want to register all the movement commands? I tried adding some sleep times in between the movement actions with no result, also tried increasing the time on forward to Forward(150, 4000) and the drone would still crash into the wall behind it (from variablewatch, the width of the object was 100px, so the IF block should have executed)
1) Use Object Tracking and not HAAR

2) don't loop inside the tracking script. Create a stand-alone script instead...

There is information (blue question marks). The description of the tracking script is for when the object has been detected. In the script you provided, the TakeOff() every time the camera recognizes an object. It's constantly taking off every time the camera recognizes an object.

Do something like this... ardronetrackingtest.EZB
Thank you for the quick responses DJ, you're awesome:D
Okay, I'll stick with custom color tracking from now on, it's a smaller pain in the butt to work with.
As for the sleep time after takeoff(), you said it yourself that ardrones are dumb. That being said, after it took off, if I let it do its thing for 2 seconds or so, it would have gone for the closest wall (not so well lit room, crappy camera under the drone for position tracking) so I needed to make it do things as soon as it left the ground (~2 seconds on the watch).
Anyway, thanks a lot for the separate script tip, it saved me from a lot of future headaches and facepalms, now I can finally improve the code for keeping the object at a safe distance (it keeps it right in the middle on the X axis, can't test the Y axis because it still crashes into the wall behind it, I'm thinking of replacing the if([objectwidth]) with a repeatwhile(tracking, [objectwidth]) block, it will be a beautiful day of testing and crashing <3)
Something else I didn't check - do you have movement tracking enabled in the camera config? If so, the script will conflict with that checkbox setting.
Yes, I had it enabled with no movements enabled, I thought it had to do with the movement panel. Now it's disabled and it will stay that way.
Finally, after some tweaking here and there the drone maintains a safe distance from the object and doesn't slam into the walls like before (almost never hits the wall, I was quite impressed). I have to do some more tweaking in the speed formulas to make it do the movements more gentle when the object is near the center, now it moves like it has spasms or something. It does the job but looks ugly while doing it and drains more battery. It's kinda hard to do with the current Movement Panel tho, a joystick-like Movement Panel would have been so much easier if you could control the XY position of the joystick with a function call.
By the way, is there any way I can manually set the position of the grid lines to something when the script starts? They behave weird when reconnecting the camera (the positions are changed) and I'm not really the fan of manually doing something over and over again if it can be done automatically. :)(not relevant anymore)
Update on the progress made (if it is considered spam I'll stop:) )

So, after some more experimenting with the controls I discovered there is actually a Joystick controller that does just what I posted previously:
-has 2 joysticks - checked
-has XY axis - checked
-XY values are between -1 and 1 - checked
-joysticks can be assigned to drone controls from Movement Panel - checked
-XY values of the controller can be changed via script - nope...

Can you please help me one last time?
I promise I'll try not to bother you again if you can help me work this out :3

The values I want to set for the joysticks are the following


$JoystickX1 = ($CameraObjectCenterX - 320) / 320
$JoystickY2 = ($CameraObjectCenterY - 240) / 240

but the variable watcher doesn't even show the joystick variables until after I declared them in the script. While playing with a usb joystick all I've got for feedback was just the balls moving in the left side of the Joystick control, no variables created and no change in the variables declared in the script (with the "Set EZ-Script variables" checked and unchecked)