"Following" How to use 100 US dollars and Tensorflow to create a "robot" that can be "something" again, Lukas is another best.
After the robot recognized by "creation" can be identified, the next step is very clear, I want to "create" a flying thing! I decided to engage a drone that can fly, and want it to know others. And respond to voice instructions.
- Select a finished drone
How is the most difficult part of "Black into" a drone is how to start. My initial choice is to assemble a drone with parts. However, like most DIY projects I have finished, I usually take too much time from zero, it is better to buy a finished product directly. Introduction, I have never flying in my own assembled drones. And buying a finished machine is usually affordable and saves money.
Most drone vendors claim to provide an API interface, but there is no clear and best choice for amateur players. Most of the drones that can provide an API interface that looks likely API have more than $ 1,000. This is too expensive for entry-level players.
But after search, I found that Parrot Arone 2.0 drone version (see Figure 1) is a low-end "black" into the excellent choice. The new price is $ 200, but many people don't play again after I bought it, so I spend $ 130 on eBay or less to buy a nice second-hand goods.
Figure 1: UAV collection in my garage. The leftmost is Parrot Ar.drone 2.0 drone
On flight stability, PARROT ARODRONE type is less than the more expensive Parrot BEBOP 2 ($ 550). However, the Node-ar-drone called Node-ar-drone tested by Parrot Ar-DRONE is very easy to use.
Another advantage of the Parrot Ar type is that it is very raffin and falling. When testing the self-directed flight code, my drone frequently hit the wall, furniture, plants, even the guests of our family, and fall. But it still can still fly normally.
Compared to the robot that "creates" can run on the ground, the "creation" drone is the most uncomfortable thing is that its battery is too short. Basically, it is charged for a few hours, flying for more than ten minutes. So I suggest buy more battery, recurring cycle.
- Give me a drone development program
I have learned that the characteristics of event-driven event driver in JavaScript make it a very good language that controls drone. Please believe me, when drone is flying, there is a lot of asynchronous events. I have written Node.js for a long time, but in the process of this project, I am very impressed. The last time I was written for the robot to write the program for the robot. Treating C language threads and exceptions is a very distressed thing, so I try to avoid using it again. I hope some of people can develop JavaScript interface for other robot platforms, because this will make the robot development program (what happens at all) is more simple and more interesting.
- architecture design
I decided to run control logic on my notebook and run the machine to run the machine in the cloud. This architecture design is lower than that of directly running the neural network directly on the Raspberry Panel. I think this architecture is suitable for amateur projection.
Microsoft, Google, IBM and Amazon offer fast and cheap machine learning APIs. Eventually I chose Microsoft's Cognitive Service API to complete this project because it is the only API that provides customized face recognition.
Figure 2 shows the system architecture of the entire drone project.
Figure 2: System architecture of smart drones. The picture is licensed by Lukas Biewald
- Start hands
By default, Parrot Ar.drone 2.0 can provide a wireless network for clients, but this feature is extremely annoying. Every time you have to experiment, you need to disconnect from the local network, and then go to the wireless network of the drone. The good news is that there is a project called Ardrone-WPA2, very useful, use it you can "black" into the drone, and let the drone join your own wireless network.
Telnet is very interesting on the drone operating system and wandering. Parrot drones use a simplified version of the Linux operating system. What time is your last Telnet to a system? The following command example demonstrates how to open a terminal and log in directly to the UAV operating system.
% Script / Connect "The Optics Lab" -p "particlewardwave" -a 192.168.0.1 -d 192.168.7.43
% telnet 192.168.7.43
- Control flight through the command line
After installing the Node library, the next step is to generate a node.js command line running environment, then you can start to control your drone:
VARARDRONE = Require ('ar-drone');
Var client = ardrone.createclient ({ip: '192.168.7.43'});
Client.createREPL ();
Drone> Takeoff ()
True
Drone> Client.Animate ('Yawdance, 1.0)
If you follow the step by step, you will be here, your drone must have fallen - at least a few times. I haven't given the protective shell of my drone to the machine without countless time until it completely disinsoms, and then I have to buy a new one. I have to say, in fact, Parrot Arone is flying better when they do not protect the shell. But this way will make drones very dangerous. Because there is no protection of the case, once no one is hitting, its propeller will hit the object directly and leave a scratch.
- Control drone flight from the web page
Develop a web-based control page for drones is quite simple and effective. Use the express.js framework as shown below to build a very small web server.
VAR Express = Require ('Express');
App.get ('/', function (req, res) {
Res.sendfile (path.join (__ DIRNAME + '/DEX.HTML'));
});
App.get ('/ Land', Function (Req, Res) {
CLIENT.LAND ();
});
App.get ('/ takeoff', function (req, res) {
Client.takeoff ();
});
App.Listen (3000, Function {
});
I use the following code to send AJAX requests through a button.
Takeoff
Land
- Export video stream from drones
I found that the best way to export the video captured on the drone is: establish a continuous connection and send the PNG picture taken by the camera to the web page of my website. By using the ar.drone drone library (see the code below), the web server will continue to take the PNG screen captured by the drone camera.
Varpngstream = client.getpngstream ();
PNGStream
('Error', Console.log)
('Data', Function) {
Sendpng (pngbuffer);
}
FunctionSendpng (buffer) {
RES.WRITE ('- daboundary \ ncontent-type: image / png \ ncontent-length:' + buff
Er.length + '\ n \ n');
Res.write (buffer);
});
- Face recognition for images obtained from drones
Microsoft's Azure Face API system is easy to get started and powerful. You upload your friend's photo to it, this system can identify who they are. It can also guess the age and gender of the characters. I found that the identification accuracy of these two features is amazing high. The entire identification is probably 200 milliseconds. Identify 1000 requests for $ 1.5. For me, this price is quite reasonable for this application. Below is my code, it implements the function of sending pictures to the API to make face recognition.
VAR OXFORD = Require ('Project-Oxford'),
OXC = new oxford.client (client_key);
LoadFaces = function () {
Chris_url = "https://media.licdn.com/mpr/mpr/shrinknp_400_400/
Aaeaaqaaaaaaaaaaaaaajgmynmiznwm0lta5mtytndu4mi05yjexltgymzvlmtzjyjewyw.jpg ";
Lukas_url = "https://media.licdn.com/mpr/MPR/SHRINKNP_400_400/P/3/000/058/147/34969d0.jpg";
Oxc.face.facelist.create ('myfaces');
Oxc.face.facelist.addface ('myfacs', {url => chris_url, name => 'chris'});
Oxc.face.facelist.addface ('myfacs', {url => Lukas_url, name => 'Lukas'});
}
Oxc.face.detect ({
PATH: 'Camera.png',
Analyzesage: True,
Analyzesgender: True
}). THEN (Function (response) {
IF (Response.Length> 0) {
Drawfaces (Response, FileName)
}
});
I used the imagemagick library to make a label for the PNG picture I collected, and the effect is quite good. There is a lot of extensions for this section. For example, use an emotional API to identify the emotions of your face.
- Use voice to control drones
The difficulty of conducting voice recognition is not identifying itself, but how to convert the voice stream from the web page running on my local server into Microsoft Speech API can use format. The following code is to implement this function. Once you can save your voice into a mono and sampled in the correct sampling frequency, this speech recognition API can easily identify voice content. This API cost is 1000 requests for $ 4. For amateur applications, it is basically equivalent to it.
RecordRTC is a good library that can be used as a tool for newcomers that are collected with a web page. At the client, I joined the code to save the voice file.
App.Post ('/ Audio', Function (Req, Res) {
Var form = new formidable.incomingform ();
/ / Set to allow customers to upload multiple files in a request
Form.Multiples = true;
Form.uploaddir = path.join (__ DIRNAME, '/ UPLOADS');
Form.on ('File', Function (Field, File) {
FileName = "Audio.wav"
fs.rename (file.path, path.join (form.uploaddir, filename);
});
// Record the wrong log
Form.on ('Error', Function (ERR) {
Console.log ('An Error Has Occured: \ n' + Err);
});
/ / Once all files are uploaded, the client is issued
Form.on ('end', function () {
RES.END ('Success');
});
// Restrict the form data included in the request
Form.Parse (REQ)
Speech.Parsewav ('Uploads / Audio.wav', Function (Text) {
Console.log (Text);
ControlDrone (Text);
});
});
I use FFMPEG tool to reduce the sampling rate of the audio and combine multiple channels into mono to use Microsoft API.
Exports.Parsewav = Function (Wavpath, Callback) {
Varcmd = 'ffmpeg -i' + wavpath + '-AR 8000 -ac 1 -y tmp.wav';
Exec (CMD, Function (Error, stdout, stderr) {
Console.log (stderr); // Command Output is in stdout
});
PostTooxford (Callback);
});
Although the function I develop is these, but it can still be extended. For example, using Microsoft's text variable speech APILet's talk!
- Develop independent search path
I used the Ardrone-Autonomy library to develop an autonomous search path for drones. During this process, I have bumped the drone in the living room in numerous times. Finally, my wife is very "polite", I suggest I go to the garage to continue my project, because there is not much thing that can hit it. But the garage is a little small, making the control space.
Search "" Love Board "", pay attention, daily update development board, intelligent hardware, open source hardware, activity and other information can make you fully master. Recommended attention!
[WeChat scanning picture can be directly paid]
Related Reading:
Better black technology: 8 minutes permanent recovery vision "
Our other product: