#Humor – TCP Data vs UDP Data

Happy coding!

Greetings

El Bruno

#Coding4Fun – How to control your #drone with 20 lines of code! (6/N)

Buy Me A Coffee

Hi!

Today is code time also! And a continuation from my previous sample.

Yesterday I show how to read a static value: the battery. And, when you work with a device like a drone there are other important values to analyze in order to send commands to the drone. Like altitude, position, time of flight etc.

So, based on yesterday sample, I’ll show how to create a simple Python app, that will display the accelerator X value. In the following video you can see the how the value start “static” during the 1st couple of seconds, until I pickup the device and I moved it around.

Important: don’t blame me about the low battery. Playing with the drone drains the battery very fast!

Once again, the code is very straight forward. It runs a loop furing 10 seconds, showing the battery and accelX information.

Just as a reminder, this is the information we get from the drone:

pitch:0;roll:1;yaw:0;vgx:0;vgy:0;vgz:0;templ:79;temph:82;tof:10;h:0;bat:39;baro:50.42;time:0;agx:-8.00;agy:-17.00;agz:-999.00

As you can read, all the information is condensed in a single line and we can split and get:

  • pitch
  • roll
  • yaw
  • vgx
  • vgv
  • vgz
  • templ (temperature low)
  • temph (temperature high)
  • tof (time of flight)
  • h (height)
  • b (battery)
  • baro (barometer)
  • time
  • agx
  • agy
  • agz

Happy coding!

Greetings

El Bruno

References

#Personal – The amazing moment when you realize that you are helping people ! #MVPBuzz

Buy Me A Coffee

Hi!

Being part of communities is awesome, and sometimes you get some feedback that really makes your day. Last week, I saw in the LinkedIn updates, that one of my LinkedIn contacts get a new Job in the VR/AR space.

Note: Do you know that VR/AR is on the most hot job around today. Read the article [AR/VR engineers replace blockchain programmers as hottest commodity] in the references section.

Based on some Scott Hanselman advise, I spend my 15 min a day, giving kudos to people who are rocking our tech world. And I take advantage of the super cool LinkedIn suggested messages. Then this happened:

I meet MrX (keep his name confidential) last year during a Microsoft Mixed Reality event. I was part of the proctors and I had the time of my life helping there.

This event was pivotal into MrX career, she/he decided to go in this way. And 2 years later … boom, MrX is an Applied Research in AR/VR.

I don’t know you, but this types of experiences really make my day.

As always, happy to help!

Happy coding!

Greetings

El Bruno

References

This is a “Thank you” Post and a “How to become an MVP”.

Only 12 days ago I was named Microsoft MVP of Artificial Intelligence and since that time thousands of things happened, that made me think i needed to write this post. I will face the beginning of the questions, with practical answers so that you can understand it, but then I will comment on my point of view on each item.

MVP_Logo_Horizontal_Preferred_Cyan300_RGB_300ppi

How do I become an MVP?

On the Microsoft MVP website you can find the “requirements” to be MVP. ->https://mvp.microsoft.com/en-US/Overview

In order to apply for the MVP Award, a Microsoft Full Time Employee (FTE) or currently active Microsoft MVP must submit a recommendation for award consideration on your behalf.

Once I get nominated, what happens?

If you have been nominated, you will receive an email to upload all the material you contributed to the community, Videos, Blogs, Articles, participation in Forums, Mentorship, Events, etc. When you submit everything you’ve…

View original post 977 more words

#Coding4Fun – How to control your #drone with 20 lines of code! (5/N)

Buy Me A Coffee

Hi!

Today is code time! In my previous post I share some code to send commands to the drone. Today I’ll show how to read the information from the drone. Before I start, someone asked if my kids are having fun with the drone. A image will be enough to answer this.

Reading drone information

So, as far as I understand, the drone is constantly sending information to the connected client. That’s why we have the following function running all the time in a separate thread:

def receiveData():
    global response
    while True:
        try:
            response, _ = clientSocket.recvfrom(1024)
        except:
            break
# ... more code
response = None
recThread = threading.Thread(target=receiveData)
recThread.daemon = True
recThread.start()

The response is stored in a global variable named response. And it’s very easy to understand the information that we the drone sends back. This is a sample received data.

pitch:0;roll:1;yaw:0;vgx:0;vgy:0;vgz:0;templ:79;temph:82;tof:10;h:0;bat:39;baro:50.42;time:0;agx:-8.00;agy:-17.00;agz:-999.00

As you can read, all the information is condensed in a single line and we can split and get:

  • pitch
  • roll
  • yaw
  • vgx
  • vgv
  • vgz
  • templ (temperature low)
  • temph (temperature high)
  • tof (time of flight)
  • h (height)
  • b (battery)
  • baro (barometer)
  • time
  • agx
  • agy
  • agz

In python this is a simple routine, and after split this into a list, the battery value is on index 21:

ls = 'pitch:0;roll:1;yaw:0;vgx:0;vgy:0;vgz:0;templ:79;temph:82;tof:10;h:0;bat:39;baro:50.42;time:0;agx:-8.00;agy:-17.00;agz:-999.00'
>>> ls1 = ls.replace(';', ':').split(':')
>>> ls1
['pitch', '0', 'roll', '1', 'yaw', '0', 'vgx', '0', 'vgy', '0', 'vgz', '0', 'templ', '79', 'temph', '82', 'tof', '10', 
'h', '0', 'bat', '39', 'baro', '50.42', 'time', '0', 'agx', '-8.00', 'agy', '-17.00', 'agz', '-999.00']
>>> ls1[21]
'39'
>>>

So with this, to get the battery level of the drone will require this code:

The output is not very amazing, but it works!

powershell console displaying the drone battery level.

Happy coding!

Greetings

El Bruno

References

#Coding4Fun – How to control your #drone with 20 lines of code! (4/N)

Buy Me A Coffee

Hi!

The DJI Drone is a great device, you can have a lot of fun and also learn a lot. However, because the main way to interact with the device is via WIFI and UDP, you need to connect to the device WIFI. And, connecting and disconnecting to the is some times not a very happy moment.

So, there are 2 main tips to work in a more agile way with this.

Connect to the Drone WiFi via Command Line

You probably already know the command

netsh wlan connect name=<YOUR WIRELESS NAME> 

This is the quickest way to connect to a wireless. Once you have your DJI Tello name and your home / work / whatever network name in your Windows Terminal, just key up until you find it.

Bonus: If you want to know the names of the network, you may want to use the command

netsh wlan show profiles

As you can see in the following image, in my home computer I got several IoT Devices connections, my phone, the DJI Tello WiFi and my home one

The command to connect to my drone will be

netsh wlan connect name=TELLO-589327 

Once I want to connect to my default network, I simply disconnect from the drone and wait until my machine connect to the default Wireless Network. The command to disconnect is

netsh wlan disconnect

So, as a recap the only 2 commands you need are:

netsh wlan connect name=<TELLO-Your device number>
netsh wlan disconnect

Super easy!

Ping your drone to check when you are connected

Once you connect to your drone WIFI, it may take a couple of seconds or more to establish the connection. If during this time, you launch an app to interact with the device, be prepared to some funny results.

The way that I use to see when the Wireless connection is ready is as simple as to use a ping -t command with

ping 192.168.10.1 -t

This is the default drone IP, and you can run this in a separate window and you will know when the drone is ready.

Happy coding!

Greetings

El Bruno

References

#Coding4Fun – How to control your #drone with 20 lines of code! (3/N)

Buy Me A Coffee

Hi!

Today I’ll write the equivalent of a Hello World in the drone ecosystem. This is a very complex app which:

  • take off the drone
  • wait a couple of seconds
  • lands the drone

I’ve followed the Python code sample from the SDK and the final code is very complex (see below). And it deserves some remarks

  • Line 11. The function recv() run in a separated thread to receive messages from the drone. The thread is started on line 44
  • Line 19. The function sendMessage() sends messages to the drone. Important, the messages must be UTF-8 encoded. This took me some time, until I figure it out. This time implements a timeout with 5 second until the response is processed in a separated thread
  • Lines 31-41. Connection information and sockets to communicate with the drone
  • Line 48. Main code for the app. Start the SDK mode, Wait 5 seconds, send the take off message, and then send the land message. A very simple exception catch is implemented here.

Important: When using the SDK, the 1st command should be “command”, as I did in line 49.

Here is the code:

Here is the app running at 3X speed so you don’t spend all day watching boring drones videos:

Drone Hello World, take off and land

Happy coding!

Greetings

El Bruno

Quantum – Can Microsoft, Google and Amazon help us solve the problems that will forever change our future?

Before starting… let me tell you what I imagined of Quantum Computers.

giphy

And maybe something like that happens inside a QC since basically they are supercomputers equipped with advanced processing powers. The basic idea of this supercomputers, is to smash some barriers that limit the speed of existing computers by harnessing the counterintuitive physics of subatomic scales. Yes… “Subatomic” is the key word. Today, the transistors in computers are as small as hardware companies can make them with existing technology. So, computer innovators began to seek possible solutions at the atomic and subatomic level in a field known as quantum computing. We are talking about something like this.

ezgif.com-video-to-gif

The vision for computers of the future will not use classical bits but “qubits” which are not limited to binary and can have properties of 0 and 1 simultaneously, thus trying every possible number and sequence simultaneously to unlock vast amounts of…

View original post 891 more words

#RaspberryPi – New Raspbian image for 2020-Feb-05

Buy Me A Coffee

Hi!

I remember last time I download and updated my Raspberry Pi with the latest Raspbian image, because it was the week before the Caribbean Developers Conference, and I deal with a couple of unexpected issues with the new version.

After the Regional Innovation Summit in Seattle, one of the draft posts that I have is related to a new Raspbian version released on 2020 Feb 05. See Release notes in the references section below. There are a couple of very interesting features here:

File Manager

The File Manager has a couple of new and interesting options. It’s still not as good as Double Commander, but I like the new features. This is the old FM

raspbian file manager before the update

And in the new one we can find that the Places, which allow us to directly access to our most frequent locations, is not collapsed by default. And with this new space, we can access more easily to other resources like USB disks and more.

Another big one, is the [New Folder] icon in the toolbar. Yes, this small one feature makes our lives much more happy! And there are new icons and more.

Code the Classics

Remember that I got my amazing [Code the Classics] book? Now all the samples for the book are included as an option to be downloaded from the Recommended Software in the Games section.

raspbian now includes code the classics in the recommended software

Display Options

I mostly use my device via VNC (which was also updated), however sometimes I got some issues when I connect my device to an external monitor. In the previous configuration, we didn’t have any option to manage this:

In the new version we can enable or disable the following options

  • Underscan
  • Pixel Doubling
  • Composite Video
  • Screen Blanking
raspbian raspberry pi configuration after the update.png

Change Log

The full change log is:

  • Version 3.2.6 of Thonny included – significant improvements in speed, particularly when debugging
  • Version 1.0.4 of Scratch 3 included – adds new “display stage” and “display sprite” blocks to SenseHAT extension, and loading of files from command line
  • Version 32.0.0.314 of Flash player included
  • Version 1.0.3 of NodeRED included
  • Version 6.6.0 of RealVNC Server and version 6.19.923 of RealVNC Viewer included – adds support for audio
  • Version 78.0.3904.108 of Chromium included
  • Mesa updated to 19.3.2 for OpenGL ES 3.1 conformance
  • Pixel doubling option added in Raspberry Pi Configuration on platforms using FKMS display driver
  • Orca screen reader added to Recommended Software
  • Code The Classics Python games added to Recommended Software
  • File manager – new “places” pane added at top of sidebar to show mounted drives in simplified view; “new folder” icon added to taskbar; expanders in directory browser now correctly show state of subfolders
  • Multiple monitor support improved – alignment of icons on second desktop corrected, Appearance Settings opens on correct tab when launched from context menu
  • Raspberry Pi Touchscreen correctly aligned with display
  • System clock synchronised before installing new packages in startup wizard and Recommended Software
  • Mixer dialogs added to taskbar volume plugin; separate Audio Preferences application removed
  • Raspberry Pi Configuration – separate tab added for display options; screen blanking control added
  • Volume taskbar plugin and raspi-config modified to support separate ALSA devices for internal audio outputs (analogue and HDMI 1 and 2)
  • Robustness improvements in volume, ejecter and battery taskbar plugins
  • Movement of mouse pointer to menu button on startup now controlled by point_at_menu parameter in Global section of lxpanel configuration file
  • Ctrl-Alt-Del and Ctrl-Alt-End shortcuts added to open shutdown options box
  • Ctrl-Shift-Esc shortcut added to open task manager
  • Enabled NEON routines in OpenSSL
  • Linux kernel 4.19.93
  • Raspberry Pi firmware 67392a7a32bddad7f571047fccafca9eeb65d29c

How to Update

If you want to update your current existing version, you must run the commands

sudo apt update
sudo apt full-upgrade

Happy coding!

Greetings

El Bruno

References

My posts on Raspberry Pi

Dev posts for Raspberry Pi
Tools and Apps for Raspberry Pi
Setup the device
Hardware

Tutorial : Azure Kinect + Face Emotion Detection

Hello everyone!

Last year i uploaded a video in which I developed a small WPF application that consumed Cognitive services to calculate the distance of a person captured by the Azure Kinect Camera. I received a lot of questions about the code and it made me feel good that i could help developers around the world. They requested me to consume the Face API with the device, so this is it!

Untitled

So lets begin.

1 . Create a WPF .NET Application, before adding all Nuget packages there are some things you have to configure for the project to work with our sensor.

image

2. Configure Debug mode x64, if you don´t have available that option available select the configuration manager and add it.

image

3. Right click your project in the solution explorer and select “Properties”

image

Once the Properties panel is available uncheck the “Prefer 32-bit” option and check the “Allow unsafe…

View original post 808 more words