Quantcast
Channel: 未分类 –懒得折腾
Viewing all 759 articles
Browse latest View live

Maple Mini

$
0
0

Maple Mini

This page is a general resource for information specific to the Maple Mini. The Maple Mini is a smaller version of the Maple that fits on a breadboard.

Technical Specifications

Powering the Maple Mini

You can power the Maple Mini via the USB plug or by powering Vin directly.

Warning

The silkscreen on the Maple Mini suggests it will accept an input voltage up to 16 V. We recommend applying no greater than 12 V, and potentially even lower depending upon the current draw requirements of the application. Please seePower Regulation on the Maple Mini for more information.

Power Regulation on the Maple Mini

Power regulation on the Maple is provided by two low dropout linear voltage regulators. (The part is the MCP1703 from Microchip, in the SOT-23A package. You can download the datasheet here ). One of the regulators supplies power to the digital voltage plane; the other supplies power to the analog voltage plane.

These voltage regulators nominally take an input of up to 16V. In addition, while the maximum continuous output current for the board is 250mA, if you are powering the board off higher voltages the amount off current it can supply goes down, due to the regulators needing to dissipate the extra power. So if you are powering the board off 12V, the max current is about 40mA at room temperature. In general (again, at room temperature) the max power dissipation (PD) for the chip is about .37W, and output current = PD/(Vin-Vout). For exact max current calculations, please refer to the datasheet linked above.

If you are planning to draw a lot of current from the Maple board, it is necessary to provide input power as close to 3.3V as possible. Powering the microcontroller circuitry and LEDs on the board alone takes approximately 30mA, so if you are powering the board with 12V that leaves only 10mA (at best) available for powering any user circuitry. Attempting to draw more than 10mA runs the risk of shorting out the power regulators and bricking your board.

GPIO Information

The Maple Mini features 34 total input/output pins, numbered D0 through D33. These numbers correspond to the numeric values next to each header on the Maple Mini’s silkscreen. However, some of them have special uses by default [1].

Pin D23 is the USB D+ line, and D24 is the USB D- line. To use them as GPIOs, your program will need to disable SerialUSB first. Be aware, however, that disabling SerialUSB means that the bootloader won’t work properly, and you’ll need to usePerpetual Bootloader Mode to make your next upload.

Pin D32 is the Mini’s button pin. It is thus mainly useful as an input. The pin will read HIGH when the button is pressed.

Pin D33 is the Mini’s LED pin. It is thus mainly useful as an output. The LED will glow when HIGH is written to it. (It also supports PWM, for finer-grained brightness control).

Master Pin Map

This table shows a summary the available functionality on every GPIO pin, by peripheral type. The “5 V?” column documents whether or not the pin is 5 volt tolerant.

Note that this table is not exhaustive; on some pins, more peripherals are available than are listed here.

Pin GPIO ADC Timer I2C UART SPI 5 V?
D0 PB11 2_SDA 3_RX Yes
D1 PB10 2_SCL 3_TX Yes
D2 PB2 Yes
D3 PB0 CH8 3_CH3
D4 PA7 CH7 3_CH2 1_MOSI
D5 PA6 CH6 3_CH1 1_MISO
D6 PA5 CH5 1_SCK
D7 PA4 CH4 2_CK 1_NSS
D8 PA3 CH3 2_CH4 2_RX
D9 PA2 CH2 2_CH3 2_TX
D10 PA1 CH1 2_CH2 2_RTS
D11 PA0 CH0 2_CH1_ETR 2_CTS
D12 PC15
D13 PC14
D14 PC13
D15 PB7 4_CH2 1_SDA Yes
D16 PB6 4_CH1 2_SCL Yes
D17 PB5 1_SMBA
D18 PB4 Yes
D19 PB3 Yes
D20 PA15 Yes
D21 PA14 Yes
D22 PA13 Yes
D23 PA12 1_ETR 1_RTS Yes
D24 PA11 1_CH4 1_CTS Yes
D25 PA10 1_CH3 1_RX Yes
D26 PA9 1_CH2 1_TX Yes
D27 PA8 1_CH1 1_CK Yes
D28 PB15 2_MOSI Yes
D29 PB14 3_RTS 2_MISO Yes
D30 PB13 3_CTS 2_SCK Yes
D31 PB12 1_BKIN 2_SMBA 3_CK 2_NSS Yes
D32 PB8 4_CH3 Yes
D33 PB1 CH9 3_CH4

GPIO Port Pin Map

The following table shows what pins are associated with each GPIO port.

GPIOA GPIOB GPIOC
PA0: D11 PB0: D3 PC0: –
PA1: D10 PB1: D33 PC1: –
PA2: D9 PB2: D2 PC2: –
PA3: D8 PB3: D19 PC3: –
PA4: D7 PB4: D18 PC4: –
PA5: D6 PB5: D17 PC5: –
PA6: D5 PB6: D16 PC6: –
PA7: D4 PB7: D15 PC7: –
PA8: D27 PB8: D32 PC8: –
PA9: D26 PB9: – PC9: –
PA10: D25 PB10: D1 PC10: –
PA11: D24 PB11: D0 PC11: –
PA12: D23 PB12: D31 PC12: –
PA13: D22 PB13: D30 PC13: D14
PA14: D21 PB14: D29 PC14: D13
PA15: D20 PB15: D28 PC15: D12

Timer Pin Map

The following table shows what pins are associated with a particular timer’s capture/compare channels.

Timer Ch. 1 Ch. 2 Ch. 3 Ch. 4
1 D27 D26 D25 D24
2 D11 D10 D9 D8
3 D5 D4 D3 D33
4 D16 D15 D32

EXTI Line Pin Map

The following table shows which pins connect to which EXTI lines.

EXTI Line Pins
EXTI0 D3, D11
EXTI1 D10, D33
EXTI2 D2, D9
EXTI3 D8, D19
EXTI4 D7, D18
EXTI5 D6, D17
EXTI6 D5, D16
EXTI7 D4, D15
EXTI8 D27, D32
EXTI9 D26
EXTI10 D1, D25
EXTI11 D0, D24
EXTI12 D23, D31
EXTI13 D14, D22, D30
EXTI14 D13, D21, D29
EXTI15 D12, D20, D28

USART Pin Map

The Maple Mini has three serial ports (also known as USARTs). They communicate using the pins given in the following table.

Serial Port TX RX CK CTS RTS
Serial1 D26 D25 D27 D24 D23
Serial2 D9 D8 D7 D11 D10
Serial3 D1 D0 D31 D30 D29

Low-Noise ADC Pins

Maple Mini has an electrically isolated analog power plane with its own regulator, and a geometrically isolated ground plane, connected to the digital plane by an inductor. Its analog input pins, D3 — D11, are laid out to correspond with these analog planes, and our measurements indicate that they generally offer low noise ADC performance. However, analog performance may vary depending upon the activity of the other GPIOs. Consult the Maple Mini hardware design files for more details.

Board-Specific Values

This section lists the Maple Mini’s board-specific values.

  • CYCLES_PER_MICROSECOND: 72
  • BOARD_BUTTON_PIN: 32
  • BOARD_LED_PIN: 33
  • BOARD_NR_GPIO_PINS: 34
  • BOARD_NR_PWM_PINS: 12
  • boardPWMPins: 3, 4, 5, 8, 9, 10, 11, 15, 16, 25, 26, 27
  • BOARD_NR_ADC_PINS: 9
  • boardADCPins: 3, 4, 5, 6, 7, 8, 9, 10, 11
  • BOARD_NR_USED_PINS: 4
  • boardUsedPinsBOARD_LED_PINBOARD_BUTTON_PIN, 23, 24 (23 and 24 are used by USB)
  • BOARD_NR_USARTS: 3
  • BOARD_USART1_TX_PIN: 26
  • BOARD_USART1_RX_PIN: 25
  • BOARD_USART2_TX_PIN: 9
  • BOARD_USART2_RX_PIN: 8
  • BOARD_USART3_TX_PIN: 1
  • BOARD_USART3_RX_PIN: 0
  • BOARD_NR_SPI: 2
  • BOARD_SPI1_NSS_PIN: 7
  • BOARD_SPI1_MOSI_PIN: 4
  • BOARD_SPI1_MISO_PIN: 5
  • BOARD_SPI1_SCK_PIN: 6
  • BOARD_SPI2_NSS_PIN: 31
  • BOARD_SPI2_MOSI_PIN: 28
  • BOARD_SPI2_MISO_PIN: 29
  • BOARD_SPI2_SCK_PIN: 30
  • BOARD_JTMS_SWDIO_PIN: 22
  • BOARD_JTCK_SWCLK_PIN: 21
  • BOARD_JTDI_PIN: 20
  • BOARD_JTDO_PIN: 19
  • BOARD_NJTRST_PIN: 18

Hardware Design Files

The hardware schematics and board layout files are available in the Maple Mini GitHub repository.

From the GitHub repository main page, you can download the entire repository by clicking the “Download” button. If you are familiar with Git, you can also clone the repository at the command line with

$ git clone git://github.com/leaflabs/maplemini.git

Failure Modes

The following known failure modes apply to all Maple boards. The failure modes aren’t design errors, but are easy ways to break or damage your board permanently.

  • High voltage on non-tolerant pins: not all header pins are 5 V compatible; so e.g. connecting certain serial devices in the wrong way could over-voltage the pins. The pin-mapping master table details which pins are 5 V-tolerant.

Errata

This section lists known issues and warnings for the Maple Mini Rev 2 (the first Rev sold to the public).

  • Silkscreen Vin voltage mistake: The silkscreen on the Maple Mini falsely indicates that Vin may be supplied with up to 16V. We recommend an input voltage no greater than 12V, and potentially even lower depending upon the current draw requirements of the application. Please see Power Regulation on the Maple Mini for more information.


CZ miniSTM32F103V -EK

$
0
0

CZ miniSTM32F103V -EK

CZ miniSTM32F103V_-EK

Name

CZ miniSTM32F103V_-EK

Specs

512kb Flash, 64kB RAM, 2 × 12-bit D/A converters 112 fast I/O ports 2 × I2C 5 USARTs 3 SPIs (18 Mbit/s), 2 with I2S interface multiplexed 32 kHz oscillator for RTC with calibration Supports Compact Flash, SRAM, PSRAM, NOR and NAND memories

Board features

all pin holders / rows already soldered Boot0 and Boot1 jumper jumpers (RX,TX) for the USB-Serial converter 2x USB one with CH340 RS232-USB-converter chip (“Serial1”) 32.768kHz and 8Mhz oscillators on board CR1220 battery holder reset button Two user buttons: PD12, PC0 Two controllable LED; PE5, PE6 power indicator LED; JTAG / SWD 20 -pin standard interface ; 32 foot FSMC TFT LCD screen interface Board size : 101.5 mm x 76.68 mm

additional chips (already soldered) SPI flash W25q16 (on SPI1: CS: PA4, MISO: PA6, MOSI: PA7, SCK: PA5) EEPROM 24C02 (on I2C1: SCL: PB6, SDA: PB7 both with 4.7K pullup) IC Adress: 0x00 ( A0=A1=A2=GND) space holder for 485 IC (PA3, PA0, PA2) and DS18B20 (Data: PB14)

Known issues

  • None

Schematic

Media:Cz_ministm32f103v-ek_schematic.pdf

Forum link

http://www.stm32duino.com/viewtopic.php?f=28&t=490


Review of Wio Tracker with GPS, Bluetooth 3.0 and GSM Connectivity

$
0
0

Wio GPS – also called Wio Tracker – is an Arduino compatible board based on Microchip Atmel SAMD21 MCU with GPS, Bluetooth, GSM/GPRS connectivity, as well as several Grove connectors to connect sensors and modules for your IoT project. SeeedStudio sent me a sample for evaluation, so I’ve tested it, and reported my experience below by testing some of the Arduino sketches.

Wio Tracker Unboxing

All I got in the package was Wio GPS tracker v1.1 board. The top includes the Atmel MCU, an RGB LED, a microphone and 3.5mm AUX jack to make phone calls, a user and power button, a micro USB port for power and programming, a small 2-pin connector for a battery, and 6 Grove connectors for digital, serial, I2C and analog modules.

The other side of the board comes with Quectel MC20 module that handles Bluetooth, GPS and GSM, a dual use micro SD card and nano SIM slot, and the GPS, 2G, and Bluetooth antennas. We can also see -/+ footprints close to connect speakers close to the OSHW logo.

Getting Started with Wio GPS Tracker with Arduino IDE

I’ve been following Wio GPS Board Wiki for this part of the review, and as we’ll soon discovered I’ve had a rather mixed experience.

First, you’ll need a micro USB to USB cable to connect the board to Windows/Linux/Mac computer. This is the kernel output I got from Ubuntu 16.04:

After installing Arduino IDE for your operating system, we can add Seeduino boards to the IDE, by going to File->Preferences and pasting the link https://raw.githubusercontent.com/Seeed-Studio/Seeed_Platform/master/package_seeeduino_boards_index.json into Additional Boards Manager URL field, and clicking OK.Now go to Tools->Boards->Boards Manager search for wio, and install Seeduino SAMD by Seeed Studio.

You can also install Adafruit Neopixel by going to to Sketch->Manage Libraries->Include Library, or importing the zip file. After that point, I decided to check whether I could find “Wio Tracker” in the list of boards as indicated in the Wiki, but there was no such board so I selected Wio GPS Board, and selected port /dev/ttyACM0 (Wio GPS Board) port.

Then I went to check for sample sketches, and found some in Examples->Seeed_Wio_GPS_Board for the all key features of the board. So I tried a bunch of them including RGB_LED, Bluetooth, GNSS (GPS), and GSM (Send SMS), and only the Bluetooth sample would work.

By I went back to the Wiki, and found out I add to import Wio Tracker library too, which I did, and I had another very similar sets of samples for MC20_GPS_Traker-master.

I’m not exactly sure we have two separate sets of nearly identical samples, but let’s see if I have more like with samples in MC20_GPS_Tracker-master folder.

Blink.ino is supposed to blink the RGB using blue color:

I could upload the program to the board with the following warning messages:

The RGB LED did not work. So I tried to remove Adafruit Neopixel library, same results. Finally I checked schematics to confirm the RGB LED is indeed connected to D10, and inserted some println debug code to make sure the program is running properly. Everything seems right, but the RGB LED would not blink. I’ve contacted the company, but unsurprinsgly they don’t work during the week-end.

Let’s move on with BT_CLientHandle.ino sketch that should allow us to pair the board with your phone. The code is relatively simple for this task:

I could see QUECTEL-BT with my Android phone, and had no problem to pair the board.

The serial output with pairing, and disconnecting events shows some of the AT commands used:

I also tried to connect a speaker to the AUX port of the board to see if I could use it as Bluetooth speaker, but it did not work, so some more code and a different Bluetooth audio profile (not HF_PROFILE) are likely required. All I could hear was dial-up modem sounds from the speakers. But still, we can tick this Bluetooth test as success.

Time for a GPS test. GNSS_Show_Coordinate.ino sketch is supposed to  output latitude and longitude to the serial console, and again the code to achieve this is still fairly simple:

But all I got in the serial output was the following:

With +CREG: 0,0 shown over and over. We can find the different AT Command sets (and EAGLE schematics) in the resources directory in Github. One of the document reports that AT+CREG? is a read command to retrieve network registration status, and the two numbers referred as <n> and <stat> are set to 0,0 meaning that:

  1. Disable network registration unsolicited result code
  2. Not registered, ME is not currently searching a new network to register on

I firstly did the test indoors, and although previously I could get a signal indoors with NavSpark mini board, I still went outside in case it was a signal problem, but the result was just the same. So maybe the program is stuck somewhere because I had not inserted a SIM card yet. Since I was not sure whether my operator still supported 2G, I forced my Android phone to use 2G, and the phone did get a signal using “E” instead of the usual 3G, and I could send an SMS and make a phone call over 2G network (I think).

So I took out the SIM card from my phone, and …. I could not insert right away simply because my SIM card was cut out as a micro SIM, but the board requires a nano SIM. Luckily, I purchased nano/micro SIM card adapters a while ago as I knew sooner or later I would have this little first world problem. You can find those for less than $1 on eBay, so even if you don’t need them right now, it might be a good idea to get some.

Once I cut out my SIM card so that it fits into the micro SIM to nano SIM adapter that I will need to use when I put back the SIM card into my smartphone, I inserted  the nano SIM and a micro SD card at the same time, as the picture below shows with the white band right above the 4GB micro SD card being the nano SIM card. I did not know they made those, as I’ve only seen shared slots in the past.

I reran the GPS sample program, and the serial output changes a bit, but still no longitude and latitude info:

+QGNSSC:1 means the GNSS module is powered on so that’s good news I guess.

+CREG: 0,2 means the SIM card is registered, and in home network, but then it will switch to +CREG:0,5 meaning the SIM card is registered and roaming. Not really re-assuring.

They also have a more complex sample called GNSS_Google_KML.ino, that will get coordinate display them in OLED display attached to the board, and save data into a gps.txt into the SD card with raw longitude and latitude data that can be inserted into a Google KML file. A GoogleMapDemo.ino sketch will upload your coordinates to ziladuo.com website. That’s provided it works of course… and considering the simplest sample GNSS would not work. I gave up on GPS/GNSS tests.

Last try was with the GSM function with the send SMS sample (MC20_SMSSend.ino) that will send “Hello MC20!!” message to the phone number of your choice”. Again it’s very easy to program:

But sadly I could not send an SMS, as the function waitForNetworkRegister failed:

I had to end my testing there. I could not remove the nano SIM card with my hands, and I had to use a pair  tweezers to get it out by pushing those the small holes on top of the slot mechanism.

So overall my experience with the board was quite catastrophic with only Bluetooth working,  and GPS, 2G GSM, and even the RGB LED sample all failing. I also often had trouble uploading the code to the board with messages like:

or (even after having close to the serial terminal for a while):

So I often had to re-try and re-try to successfully upload the code to the board. I’m sure there must be an explanation for all the issues I had. I can see they tested it in Windows, but I’m using Ubuntu 16.04, so maybe that could be one reason?

Having said that, if the board actually worked, I really like what SeeedStudio has done, as it looks really easy to program the board with GPS, Bluetooth, or 2G data, SMS, calls, and you can add Grove Sensors to make pretty more advanced IoT projects. The company also provides a more practical sample with their “Wild Adventure Tracker” demo reporting sending GPS coordinates over SMS when a shock occurs. The source code on Github with a video showing the results below.

The company is also working on a 4G version, and I’ll probably have a chance to give it another try once it is released. If you are interested in Wio GPS Tracker board, you can pre-order it for $24.95 including all three antennas.


Swift Top 10 Articles For the Past Month (v.Sep 2017)

$
0
0

Swift Top 10 Articles For the Past Month (v.Sep 2017)

For the past month, we’ve ranked nearly 1,000 Swift articles to pick the Top 10 stories that can help advance your iOS career (1% chance to be picked in the list)

  • Topics in this list: iPhone X, Table Views, Neural Networks, Snapshot Testing, Debugging, Animation, Core Data, Architecture
  • Swift Open Source of the Month is included at the bottom.

Mybridge AI ranks articles based on the quality of content measured by our machine and a variety of human factors including engagement and popularity. This is a competitive list and you’ll find the experience and techniques shared by iOS leaders particularly useful.

Rank 1

Dealing with Complex Table Views in iOS and Keeping Your Sanity [Trending in September]. Courtesy of Marin Benčević


Rank 2

iPhone X: Dealing with Home Indicator. Courtesy of Jordan Morgan, iOS Developer at Buffer


Rank 3

Managing different environments in your Swift project with ease. Courtesy of Yuri Chukhlib


Rank 4

Deep Neural Networks in Swift, lessons learned. Courtesy of Jeremi Kaczmarczyk and Tooploox


Rank 5

Debugging Swift code with LLDB. Courtesy of Ahmed Sulaiman


Rank 6

Snapshot Testing in Swift. Courtesy of Stephen Celis


Rank 7

iOS: Animate TableView Updates. Courtesy of Stan Ostrovskiy


Rank 8

Cracking the Tests for Core Data. Courtesy of S.T.Huang Brewery


Rank 9

Generics in Swift 4. Courtesy of Candost Dağdeviren



Guide to installing Arduino on Ubuntu Virtualbox Guest under Windows Host

$
0
0

Guide to installing Arduino on Ubuntu Virtualbox Guest under Windows Host

If you are the proud owner of an Arduino Uno board but prefer to work in an Ubuntu VM instead of dual-booting, this article is for you. I’ll guide you through configuring VirtualBox under your Windows host to get Arduino working properly.

Installing required programs

Before we worry about USB ports/serials/whatever, let’s just install the stuff we’ll need on our Ubuntu guest.

Installing Python 2.7 and pip

This installation requires Python 2.7 and pip. Read through my tutorial on installing both.

Installing the Arduino IDE distribution

Assuming the Ubuntu version on your VM is never than Ubuntu 10.10 (Maverick), simply

$ sudo apt-get install arduino

Otherwise, consult the official documentation

Installing picocom

picocom is a “minimal dumb-terminal emulation program”, and we’ll be using it for serial communication. Installation is done through apt-get.

$ sudo apt-get install picocom

Installing ino

Instead of using the Arduino GUI, we’re going to use ino. ino allows us to compile and upload arduino projects from the command line, enabling us to use our favorite text editors such as VIM or emacs.

To install ino,

$ sudo pip install ino

Installing the drivers

Follow the instructions on getting the Arduino Development Environment for your Windows host.

NOTE: On step 4, “Install the Drivers”, it says

Finally, navigate to and select the Uno’s driver file, named “ArduinoUNO.inf”, located in the “Drivers” folder of the Arduino

What I had to do was just select the folder C:\path\where\I\extracted\arduino\drivers, I did not select an individual file.

Verifying the Windows Installation

Verify the Windows installation worked by getting the Blink program to work on your Arduino board. First, make sure your Arduino board is plugged in. Now Open up the arduino executable on your Windows machine. This will bring up a tiny, blue-green text editor. In the editor, navigate to File ⇒ Examples ⇒ 01.Basics ⇒ Blink. Click the Upload button (to the right of the Check mark), press the reset button on your Arduino board, and see if the LED on your board blinks in a rhythmic fashion.

If everything looks good, it’s time to proceed to the next step. Otherwise, it’s time to start Googling 😦

Configuring VirtualBox

We now need to help facilitate communication between our Ubuntu VM and our Windows Host. You might be wondering why we don’t just attach the USB device from VirtualBoxes Devices ⇒ USB Devices menu. The reason is because the extra USB virtualization introduces enough latency to make uploading fail sporadically on our VM. The solution is to forward serial ports for more direct communication with the host.

Getting the port number

First, we need to get the port number associated with our Arduino bored. To do so, we need to open the Device Manager within Windows. We can accomplish this by opening the Start Menu, and typing “Device Manager” in the “Search programs and files” box that will probably already have a blinking text cursor in it. Click the top result, which should just read “Device Manager”

Look for the “Ports (COM & LPT)” section. Click the + sign to expand it, and you should see “Arduino Uno (COM#)” where # is some number. In my case, it was 3.

This number is very important, so I’ll refer to this particular number as # for the upcoming section.

Configuring ports in VirtualBox

Shutdown your VM if you still have it open. Don’t save the state – completely shut it down.

Now navigate to VirtualBox, select the VM you plan on working with, and then click settings. Select the “Serial Ports” option on the left hand side.

Click the “Port 1” tab, and then select “Enable Serial Port”. Regardless of what # from earlier was, the Port Number should be set to COM1. This tells VirtualBox to have the Arduino board mounted at /dev/ttyS0. For the Port Mode, select “Host Device”. For “Port/File Path:”, Enter in COM#:. The colon needs to be there.

That’s it for configuring VirtualBox. Start your VM back up, and we’ll wrap up this installation with testing and configuring ino.

Testing, Using, and Configuring ino

A majority of this information is taken straight from the ino quickstart quide.

Make a directory you would like to store your arduino projects in, and cd to it.

$ mkdir ~/arduino
$ cd ~/arduino

Now make a testproject directory and cd to it.

$ mkdir testproject
$ cd testproject

Now we initialize an arduino project.

$ ino init

If you look at the contents of your testproject directory, you should see a lib and a src directory. Within src, there will be a file called sketch.ino. Clear out the file and paste in the following, which will make the LED on the arduino blink very rapidly.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#define LED_PIN 13

void setup()
{
    pinMode(LED_PIN, OUTPUT);
}

void loop()
{
    digitalWrite(LED_PIN, HIGH);
    delay(100);
    digitalWrite(LED_PIN, LOW);
    delay(100);
}

raw source

Now make sure you are in the project’s root directory, and then run the build process. This will compile your program.

$ cd ~/arduino/testproject
$ ino build

If the build succeeds, we can now upload to our Arduino!

$ ino upload -p /dev/ttyS0

Upon successful upload, we should see the following

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f
avrdude: reading input file ".build/uno/firmware.hex"
avrdude: writing flash (1034 bytes):

Writing | ################################################## | 100% 0.67s

avrdude: 1034 bytes of flash written
avrdude: verifying flash memory against .build/uno/firmware.hex:
avrdude: load data flash data from input file .build/uno/firmware.hex:
avrdude: input file .build/uno/firmware.hex contains 1034 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.20s

avrdude: verifying ...
avrdude: 1034 bytes of flash verified

avrdude: safemode: Fuses OK

avrdude done.  Thank you.

Permissions Issues

Remember that /dev/ttyS0 represents our Arduino, and we specified that specific location by selecting the Port Number as COM1 in the VirtualBox settings. There’s a pretty high chance you receive the following error upon your first upload attempt:

~/arduino/testproject$ ino upload -p /dev/ttyS0
/bin/stty: /dev/ttyS0: Permission denied
stty failed

If that’s the case, follow these instructions. Otherwise, skip to the .inorc section.

First, we need to figure out what group is associated with this port.

$ ls -al /dev/ttyS0

The output I received from the command was

crw------- 1 root dialout 4, 64 May  7 04:34 /dev/ttyS0

Thus the dialout group owns the port, but it’s not even group writable. So we need to add ourselves to the dialout group and then make the port group writable.

$ sudo usermod -a -G dialout YOUR_USER_NAME
$ sudo chmod 660 /dev/ttyS0

NOTE: You will need to log out and log back in before you become a part of the group.

Now go back to the project directory and attempt the upload again

$ cd ~/arduino/testproject
$ ino upload -p /dev/ttyS0

.inorc

Congratulations! You now have your Arduino environment working on your Virtual Machine. There’s only one last detail to take care of. In order to avoid having to pass the port to the $ ino upload command every time, we can create a configuration file that stores our desired port for us. Execute the following:

$ echo -e "serial-port = /dev/ttyS0\n" > ~/.inorc

Examine the contents of ~/.inorc for yourself to make sure the command worked. Now, you should be able to go back to your project and simply run

$ ino upload

without a need to specify the port.


shadowsocks实现原理

$
0
0

shadowsocks实现原理

shadowsocks是目前最好的科学上网方式,它的流量经过加密,所以没有流量特征不会被GFW阻断;关键是,它的实现原理也通俗易懂。

笔者是ss的重度用户,电脑和手机都在使用。本文不会介绍怎么安装使用shadowsocks,因为很多文章都有详细介绍。在文中简称shadowsocks为ss。

前言

shadowsocks已经出现很多年了,作者是clowwindy,大家可以去github查看他的主页。github上ss仓库https://github.com/shadowsocks/shadowsocks/tree/master的代码已经比较难维护了,状态机和epoll很好,提高了程序的性能效率,但是很多东西也影响了我们去看核心的东西是什么。所以本文解析的是一个轻量级的ss,clowwindy写的比较早的版本,那个时候使用select而不是epoll,网络通信的逻辑也很清晰,容易了解ss的原理,代码的仓库为https://github.com/YvesChan/shadowsocks

概述

ss要求本机运行local.py,海外服务器运行server.py。local.py默认监听localhost的1080端口,该端口代理浏览器的请求。browser要访问google时,会和localhost:1080进行一次基于sock5协议的通信,如上图的红色虚线框,sock5协议可以去了解下,维基百科有不错的介绍。

代理的流程如下:

  1. localhost:1080经过sock5协议后,就知道要访问google了
  2. local程序会把流量加密,然后把普通的TCP流量发往海外服务器;
  3. 海外服务器收到请求后,解密得到要访问google
  4. 海外服务器请求google后把得到的数据加密返回给local
  5. local解密返回给browser。

ss的解密和加密基于用户设置的密码,所以local和server之间可以做到加密和解密的一致。

网络编程

python网络编程相比C语言要少很多代码,由于有很多封装得很好的类可以使用,网络编程更加符合思维走向。作者clowwindy使用了SocketServer.TCPServer和SocketServer.StreamRequestHandler两个类完成TCP的处理。在python的官方文档可以查看到两者的详细介绍。从名字中也可以知道两者的作用:TCPServer负责处理连接accept或close等,此类的构造函数要求传入Handler类;Handler类负责连接的数据处理,包括recv和send,此类要求实现handle方法。StreamRequestHandler更进一步把recv和send封装为rfile读端的read和wfile.write,把socket操作转化为了文件的读写,更加便捷。

local程序的handle方法:

图截自github,本人已经标注handle函数每个部分的作用,最后的handle_tcp等待sock和remote的事件,sock可读则读取然后发往remote,remote可读就读取然后发往sock,代码如下图:

注意encrypt和decrypt,加密和解密的算法感兴趣可以去看看代码,使用到了python自带的加密解密方法。

server端的handle方法就不再截图了,因为和local.py很类似,只是一些细节流程不一致而已。大家感兴趣可以下载代码阅读。

运行效果
服务端先运行server.py后,本地运行loca.py,并且设置浏览器代理为本地1080就OK了

总结

ss除了python版本之外还有c和go的版本,后两者的口碑比python版本的好一点。

感谢clowwindy大牛,正是有能力的人的辛勤且无悔的付出,开源领域才越来越繁荣。

最后,我们应该为生活在有github的时代而感到幸福。


BeagleBone Blue and robots that can fly

$
0
0

BeagleBone Blue and robots that can fly

You’ve now built robots that can move around on a wheeled structure, robots that can have legs, and robots that can sail. You can also build robots that can fly, relying on the BeagleBone blue to control their flight. There are several possible ways to incorporate the BeagleBone into a flying robotic project, but perhaps the most straightforward is to add it to a quadcopter project.

Quadcopters are a unique subset of flying platforms that have become very popular in the last few years. They utilize the same vertical lift concept as helicopters; however, they employ not one but four motor or propeller combinations to provide an enhanced level of stability. Here is a picture of just such a platform:

The quadcopter has two sets of counter-rotating propellers, which simply means that two of the propellers rotate one way and the other two rotate the other to provide thrust in the same direction. This provides a platform that is inherently stable. Controlling the thrust on all the four motors allows you to change pitch, roll, and yaw of the device.

Here is a diagram that may be helpful:

As you can see, controlling the relative speeds of the four motors allows you to control the various ways the device can change position. To move forward, or really in any direction, we combine a change in roll or pitch with a change in thrust, so that instead of going up, the device moves forward, as shown in this diagram:

In a perfect world, you might, knowing the components you used to build your quadcopter, know exactly how much control signal to apply to get a certain change in the roll/pitch/yaw or altitude of your quadcopter. But there are simply too many aspects of your device that can vary to know this well enough to rely on a fixed set of signals. Instead, this platform uses a series of measurements of its position, pitch/roll/yaw, and altitude, and then adjusts the control signals to the motors to achieve the desired result. We call this feedback control. Here is a diagram of a feedback system:

As you can see, if your quadcopter is too low, the difference between the Desired Altitude and the Actual Altitude will be positive, and the motor control will be increased, increasing the altitude. If the quadcopter is too high, the difference between the Desired Altitude and the Actual Altitude will be negative, and the Motor Control will be decreased, decreasing the altitude. If the Desired Altitude and the Actual Altitude are equal, then the difference between the two will be zero, and the Motor Control will be held at its current value. Thus, the system stabilizes even if the components aren’t perfect, or if wind comes along and blows the quadcopter up or down.

One application of the BeagleBone Blue in this type of robotic project is to actually coordinate the measurement and control of the quadcopter’s pitch, roll, yaw, and altitude. This can be done but it is a very complex task and the detail of its implementation is beyond the scope of this book. There are some individuals in the open source software and hardware space working on this problem. See https://diydrones.com/profiles/blogs/beaglebone-blue-released-linux-enabled-autopilot-for-80?xg_source=activity for details.

The BeagleBone Blue can still be utilized in this type of robotic projects, without focusing on the low-level control, by introducing another embedded processor to do the low-level control, and using the BeagleBone blue to manage the high level tasks, such as using the vision system of the BeagleBone Blue to identify a colored ball and then guiding the platform toward it. Or, as in the sail boat example, using the BeagleBone to coordinate GPS tracking and long-range communications via ZigBee. This is the type of example that I’ll cover in this section.

The first thing you’ll need is a quadcopter. There are three approaches to this: one, purchase an already assembled quadcopter; two, purchase a kit and construct it yourself; or three, buy the parts and construct the quadcopter. In either case, to complete this section, you’ll need to choose one that uses the ArduPilot as its flight control system. This flight system uses a flight version of the Arduino to do the low level feedback control we talked about earlier. The advantage to this system is that you can talk to the flight control system via USB.

There are a number of assembled quadcopters available that use this flight controller. One place to start is at ardupilot.com. This will give you some information on the flight controller, and the store has several already assembled quadcopters. If you think assembling a kit is the right approach, try www.unmannedtechshop.co.uk/multi-rotor.htmlor www.buildyourowndrone.co.uk/ArduCopter-Kits-s/33.htm, as each of these not only sells assembled quadcopters but kits as well.

If you’d like to assemble your own kit, there are several good tutorials about choosing all the right parts and assembling your quadcopter. Try blog.tkjelectronics.dk/2012/03/quadcopters-how-to-get-startedblog.oscarliang.net/build-a-quadcopter-beginners-tutorial-1/, or http://www.arducopter.co.uk/what-do-i-need.html for excellent instructions.

You might be tempted to purchase one of the very inexpensive quadcopters that are being offered on the market. For this project, you will need two key characteristics of the quadcopter. First, the quadcopter flight control will need a USB port so you can connect the BeagleBone Blue to it. Second, it will need to be large enough with enough thrust to carry the extra weight of the BeagleBone Blue, a battery, and perhaps a web cam or other sensing device.

No matter which path you choose, another excellent source for information is code.google.com/p/arducopter. This gives you some information on how the ArduPilot works, and also talks about Mission Planner, the open-source control SW that will be used to control the ArduPilot on your quadcopter. This SW runs on the PC and communicates to the quadcopter in one of two ways: either directly through a USB connection or through a radio connection. It is the USB connection that you will communicate between the BeagleBone Blue and the ArduPilot.

The first step, when working in this space, is to build your quadcopter and get it working with an RC radio. When you allow the BeagleBone Blue to control it later, you may still want to have the RC radio handy, just in case things don’t go quite as planned.

When the quadcopter is flying well, based on your ability to control it using the RC radio, then you should begin to use the ArduPilot in autopilot mode. To do this, download the SW from ardupilot.com/downloads. You can then run the SW and you should see something like this:

You can then connect your ArduPilot to the SW and press the connect button in the upper right corner. I will not walk you through how to use the SW to plan an automated flight plan as there is plenty of documentation for that on the ardupilot.com website. What you want to do is to hook up your BeagleBone Blue to the ArduPilot on your quadcopter so that it can control the flight of your quadcopter much as the Mission Planner does, but at a much lower and more specific level. You will use the USB interface, just as the Mission Planner does.

To connect the two devices, you’ll need to modify the Arduino code and create some BeagleBone Blue code, then simply connect the USB interface of the BeagleBone Blue to the Ardupilot and you can issue yaw, pitch, and roll commands to the Arduino to guide your quadcopter to wherever you want it to go. The Arduino will take care of keeping the quadcopter stable. An excellent tutorial on how to accomplish, albeit using the Raspberry Pi as the controller, is available at http://oweng.myweb.port.ac.uk/build-your-own-quadcopter-autopilot/.

Now that you can fly your quadcopter using the BeagleBone Blue, you can use the same GPS and ZigBee capabilities, mentioned in other areas of the book, to make your quadcopter semi-autonomous.

Your quadcopter can also act completely autonomously as well. Adding a 3G modem to the project allows you to track your quadcopter, no matter where it goes, as long as it can receive a cell signal. Here is a picture of such a modem:

This can be purchased on amazon.com, but also at your cellular service provider. Once you have purchased your modem, simply google instructions on how to configure it in Linux. An example project is given at http://www.adafruit.com/blog/2013/08/23/sky-drone-fpv-uses-3g4g-cell-network-to-provide-long-range-rc/.


LoRaWAN Part 1: How to Get 15 km Wireless and 10-Year Battery Life for IoT

$
0
0

LoRaWAN Part 1: How to Get 15 km Wireless and 10-Year Battery Life for IoT

Contributed By Digi-Key’s North American Editors

Editor’s note: In Part 1 of this two-part series, we will discuss the issue of long-range, low-power communication for IoT and how to achieve it, securely. In Part 2, LoRaWAN Part 2: How to Use Microchip’s Modules to Speed IoT Design, we will discuss an implementation using off-the-shelf LoRaWAN hardware and software.

Low-power wireless networks are a key enabler for the Internet of Things (IoT), but familiar options such as Bluetooth, ZigBee, Wi-Fi, or cellular, lack an acceptable combination of extended range and battery life. To address this, new sub-GHz specifications are being offered, one of which is LoRaWAN.

LoRaWAN can achieve a 15 km range at power consumption levels low enough to enable 10-year battery life. Further, the availability of an off-the-shelf development kit lets designers quickly bring up a complete LoRaWAN network application with minimal effort.

This article will look at the advantages of sub-GHz communication, examine the important role of modulation schemes, and introduce LoRaWAN with a description of its physical and media access control layers, as well as its security features. It will conclude with a brief introduction to the RN2903 LoRaWAN module from Microchip Technology.

Sub-GHz advantages

High-frequency connectivity options provide high data rates but have limited range at acceptable power levels. For power-constrained designs that need extended range, low-frequency operation is a preferred approach. The lower the frequency, the less power is required to maintain a particular link budget at a specified range, as shown by the Friis transmission equation:

Equation 1

Where:

Pt = transmitted power

Pr = received power

Gt = transmitter antenna gain

Gr = receiver antenna gain

λ = wavelength

d = distance between transmitter and receiver

Lower frequency transmissions typically translate to lower data rates, but IoT applications rarely present significant throughput requirements. Additionally, lower data rates bring another advantage in the form of reduced error rates, thereby decreasing the sensitivity requirements of the receiver.

The downside is that with slow links the duty-cycle increases, thereby increasing the chance of error due to interference from noise and other signals. Further, the longer the time required to transmit a message means increased power consumption at both the transmitter and receiver ends.

That said, sub-GHz communications can help meet the requirements for range, power, and data rate required by most IoT applications. Still, the choice of modulation method used for data encoding adds a further layer affecting these three key parameters.

Modulation methods

Communications specialists have for years relied on spread spectrum modulation techniques to enhance immunity to noise or interfering signals. Channel coding methods used in spread spectrum techniques, such as direct-sequence spread spectrum (DSSS), are able to reduce transmitter power requirements by building redundancy into the spreading algorithm.

Although this approach can support very high data rates, it requires a high bandwidth carrier and sophisticated modulation/demodulation signal chains able to ensure efficient transmission and reception of the wideband signal. IoT applications rarely need the kind of maximum data rates possible with modulation techniques such as DSSS. Further, the design complexity and power requirements associated with traditional spread spectrum techniques can make them less effective for low-cost, battery-operated IoT designs.

This is where LoRa comes in. Developed by Semtech, LoRa is a unique spread spectrum modulation method that brings some of the benefits of spread spectrum noise immunity, while simplifying design requirements. LoRa modulation is based on a frequency modulated “chirp” signal that can be generated with a relatively simple fractional-N phase-locked loop (PLL).

When initiating a LoRa transmission, a LoRa modem issues a preamble comprised of a series of chirps (Figure 1, left). The transmission continues with a series of chirps that encode data essentially as frequency jumps in the chirp signal, similar to the use of multiple frequency tones to encode data in M-ary FSK (Figure 1, right).

Image of waterfall view showing the repeated chirps

Figure 1: This waterfall view (newest data at the top) shows the repeated chirps used in the LoRa transmission preamble (left) and the chirps encoding the payload of a transmission (right). (Image source: Link Labs)

On the receiver side, a PLL can lock onto the preamble to initiate reception of a message stream. Because of the distinct pattern of the chirps, a LoRa modem can detect signals as low as 20 dB below the noise floor. LoRa technology enables -148 dBm sensitivity, enabling robust connectivity over very long ranges. Further, a LoRa modem can receive several different transmissions simultaneously, each differing only in chirp rates. As a result, it can support very large numbers of IoT devices operating simultaneously.

LoRa networking

LoRa technology’s unique modulation method lies at the heart of performance characteristics that make it well suited to IoT applications: It can operate successfully at ranges exceeding 15 km in suburban settings and more than 2 km in dense urban environments. It can achieve over 10-year battery life and it can operate in networks comprising up to 1 million nodes. Further, its support for different chirp rates, or “spreading factors,” gives designers the flexibility to trade data rate for range or power as needed to optimize network performance (Figure 2).

Diagram of LoRa technology for IoT developers

Figure 2: With LoRa technology, IoT developers can trade data range for bit rate by using different spreading factors. (Image source: Microchip Technology)

For all its benefits, LoRa is still a physical layer (PHY) mechanism. In an actual IoT application, developers’ ability to apply it as a connectivity solution depends on the availability of a network protocol stack able to build on the LoRa PHY. The LoRaWAN standard does just that with its definition of the media access control (MAC) layer designed to operate with the LoRa PHY. Created and maintained by the LoRa Alliance, the LoRaWAN specification was developed specifically for long-range IoT applications and provides access and control protocols geared for secure, low-power wireless communications.

LoRaWAN defines a familiar IoT hierarchy comprising end devices, local controllers, and cloud-based servers (Figure 3). In LoRaWAN terminology, end devices are connected wirelessly in a star topology to a gateway, and gateways connect through IP networks to a central network server. The network server can double as an IoT application server or connect to one or more separate application servers.

Image of LoRaWAN network topology

Figure 3: The LoRaWAN network topology presents a familiar IoT hierarchy comprising end devices connected wirelessly (dotted lines) to gateways that connect through IP networks (solid lines) to an upstream network server and application servers. (Diagram drawn using Digi-Key Scheme-it)

https://www.digikey.com/schemeit/embed/lorawan-application-PLVM35O2011G/

The LoRaWAN stack provides applications with a standard interface to LoRa-based communications (Figure 4). At the bottom of the stack, the LoRa PHY works with regional sub-GHz ISM bandwidth allocations. Above the LoRa PHY, the LoRaWAN MAC provides familiar MAC-layer services including channel access and addressing. As described below, the LoRaWAN standard defines specific message formats and timing for uplink and downlink transactions.

Image of LoRaWAN media access control (MAC)

Figure 4: Built on the LoRa PHY, the LoRaWAN media access control (MAC) defines the message formats for different device classes. (Image source: LoRa Alliance)

Communications options

The LoRaWAN MAC protocol is designed to support IoT applications with different requirements for downlink communications from a LoRaWAN gateway to an end device. As defined by the LoRa Alliance, the LoRaWAN MAC includes three different classes of devices, all of which support bidirectional communications but differ in their downlink availability:

  • Class A operation supports low-power devices such as wireless sensor nodes that require minimal downlink communication from the server after uplink transmission. A Class A device can transmit data to a gateway any time, but can only receive within two windows, each occurring at a specified delay after the transmission (Figure 5).

Diagram of default Class A transaction

Figure 5: In the default Class A transaction, a device transmits a LoRa-compatible message to a gateway and then listens after preset delays for a response in two receive windows. (Image source: LoRa Alliance)

  • Class B operation extends Class A with additional downlink receive windows. Besides the usual two short receive windows following transmission, a Class B IoT device listens for additional downlink messages at other scheduled windows. The downlink windows occur at specific times following a beacon that is transmitted by a recognized LoRaWAN gateway. Class B downlink scheduling provides a mechanism for applications to contact the IoT device at specific times rather than depending on the non-deterministic downlink windows available in default Class A operation.
  • Class C operations supports devices that need near-continuous availability of downlink receive windows. A Class C device constantly listens for downlink messages except when it is transmitting data or opening the two default receive windows.

LoRaWAN is designed with multiple security features, using a combination of device, session and application crypto keys to encrypt data and to authenticate device access to the network. For a LoRaWAN application, end devices can be programmed at the factory with the authentication information required to join a specific LoRaWAN network, which LoRaWAN calls “activation by personalization”. LoRaWAN also offers “over-the-air activation”, which specifies a procedure for authentication and authorization required for a device to join any available LoRaWAN network.

For network-join operations and secure data communications, only IoT devices and the application server hold crypto secrets (Figure 6). Encrypted messages are simply conveyed, not processed, by the intermediate gateway and network, eliminating their use as an effective attack surface for bad actors.

Image of crypto keys are maintained only in end devices and application servers

Figure 6: In a typical LoRaWAN application, crypto keys are maintained only in end devices and application servers (green highlight). The end-device MCU and upstream IoT application software (red highlight) operate on plain text, while the LoRaWAN gateway and network server (blue highlight) see only encrypted data. (Image source: Microchip Technology)

Simplified communications

Designed to simplify development of LoRaWAN communications, Microchip Technology offers a discrete module that implements LoRa modulation and provides LoRaWAN compatibility. The Microchip RN2903 supports LoRaWAN-compatible communications at the ITU Region 1 ISM standard frequency band of 915 MHz. Along with LoRa modulation, the onboard transceiver also supports FSK and GFSK modulation for proprietary network-protocol design. Similarly, Microchip’s RN2483 provides identical features, supporting the ITU Region 2 ISM bands at 433 or 868 MHz.

Diagram of Microchip LoRa module

Figure 7: The Microchip LoRa module provides a drop-in solution for LoRaWAN connectivity with its onboard command processor, LoRaWAN protocol stack, radio transceiver, and serial connectivity. (Image source: Microchip Technology)

Fully certified, the Microchip module includes all the components required to implement LoRaWAN connectivity (Figure 7). The module’s command processor uses the onboard LoRaWAN firmware to fully support the LoRaWAN Class A protocol. The onboard EEPROM provides storage for LoRaWAN configuration parameters, enhancing performance and increasing security by reducing data transfers between the host and module.

Conclusion

In creating IoT devices intended for long-range communications, developers face a challenge in finding a wireless connectivity able to meet requirements for extended range, long battery life, and sufficient data rate. LoRaWAN can satisfy these demands with unique modulation technology that can achieve a 15 km wireless range and a 10-year battery life. Still, meeting LoRaWAN’s underlying PHY and MAC requirements can stretch development resources and project schedules. Microchip Technology’s RN2903 LoRa module provides a near drop-in solution for implementing LoRaWAN in IoT device designs. As we will discuss in part two, end-device connectivity is only part of a complete LoRaWAN-based IoT application.

In Part 2 of this two-part series, we will discuss how to implement the Microchip RN2903 module using relevant code examples. We will also examine its role in a Microchip LoRaWAN evaluation kit that offers a complete off-the-shelf LoRaWAN-compatible solution including hardware and software for end devices, gateways, and network servers.

LoRaWAN Part 2: How to Use Microchip’s Modules to Speed IoT Design

Contributed By Digi-Key’s North American Editors

Editors Note: In Part 1 of this two-part series, LoRaWAN Part 1: How to Get 15 km Wireless and 10-Year Battery Life for IoT, we looked at the ability of LoRaWAN to meet the need for long-range, low-power IoT communications. Here in Part 2, we will show how developers can use an off-the-shelf kit based on the Microchip Technology RN2903 to implement a LoRaWAN IoT application.

LoRaWAN offers performance characteristics well matched to the needs of the IoT. Besides its extended operating range and low power requirements, LoRaWAN provides secure, flexible communications options. Yet, the hardware and software required to implement a LoRaWAN solution can prove a major obstacle to development teams focused on the IoT application itself.

This article will elaborate on Microchip Technology’s RN2903 LoRa module introduced in Part 1, and show how to use it with some additional hardware and software to realize a long-range, low-power IoT design.

Quick-start kits

Microchip Technology’s RN2903 LoRa module is a near drop-in LoRaWAN hardware solution for an IoT design. Even so, it remains only the cornerstone of a complete LoRaWAN network, and developers must still account for support hardware and software systems. Microchip addresses this need with a comprehensive evaluation kit that provides the additional elements needed to implement LoRaWAN for the IoT.

As mentioned in Part 1, Microchip Technology’s RN2903 supports LoRaWAN-compatible communications at 915 MHz and is designed to simplify development of IoT applications. Fully certified, the Microchip module includes all of the components required to implement LoRaWAN connectivity (Figure 1). The module’s command processor uses the onboard LoRaWAN firmware to fully support the LoRaWAN Class A protocol. The onboard EEPROM provides storage for LoRaWAN configuration parameters, enhancing performance and increasing security by reducing data transfers between the host and module.

Diagram of Microchip’s LoRa module for LoRaWAN connectivity

Figure 1: Microchip’s LoRa module provides a drop-in solution for LoRaWAN connectivity with its onboard command processor, LoRaWAN protocol stack, radio transceiver, and serial connectivity. (Image source: Microchip Technology)

The Microchip RN2903 module provides a dedicated UART interface for communications with an external MCU host. In addition, the module includes 14 GPIO pins that developers can program using module firmware to monitor or control external devices such as switches and LEDs. Finally, the module provides an RF signal pin for easy connection to a simple sleeve dipole antenna.

The module’s command processor performs LoRaWAN transactions according to commands received through its UART interface from an external host MCU. As with any network communications method, LoRaWAN messages are sent and received in specific formats. For LoRaWAN, the LoRa Alliance standard specifies these formats in exacting detail at the byte level. The RN2903 module provides an intuitive text-based approach that abstracts LoRaWAN standard byte-level formats to a set of keyword commands with optional parameters.

Microchip defines three types of keywords:

  1. mac commands for LoRaWAN MAC configuration and control
  2. radio commands targeting the PHY radio layer
  3. sys commands for additional module functions such as providing module firmware version information or accessing the module’s EEPROM store

For example:

mac tx uncnf 30 23A5

sends a message on port 30 with data value “23A5”. The “uncnf” option indicates that the device is not requesting confirmation from the network server. Alternatively, use of the “cnf” option indicates that the device expects the network server to acknowledge receipt. The LoRa module is responsible for encrypting this message before transmitting it to its gateway for delivery to the network server.

radio tx 6d657373616765

transmits a package containing the values [0x6d][0x65][0x73][0x73][0x61][0x67][0x65] (the sample text string “message” in hexadecimal)

sys set nvm 100 FF

stores the value 0xFF at address 0x100 of the user partition in the EEPROM

IoT device design

With its serial interface, the RN2903 requires few additional components to implement a LoRaWAN-compliant IoT hardware design. Microchip further speeds  development with its RN2903 LoRa Mote. Intended to demonstrate its LoRa module capabilities, the Microchip LoRa Mote provides a complete set of hardware and software needed to implement a LoRaWAN-compatible wireless sensor.

The Microchip RN2903 LoRa Mote and RN2483 LoRa Mote each combine the respective LoRa module with a Microchip PIC18LF45K50 8-bit MCU, which serves as host processor for sensor operation and LoRaWAN protocol execution. In addition, the Mote includes light and temperature sensors for the acquisition of sample data, as well as an LCD display for user feedback. The Mote connects to a host computer through a standard USB interface, which provides access to the LoRa module’s UART interface.

During development engineers can execute LoRaWAN operations by sending the macradio, and sys command strings to the module using the Mote’s USB connection. During runtime, code running on the IoT device host would issue commands and process responses as needed for the IoT application. For LoRaWAN applications, Microchip provides an extensive C software library with the Mote hardware. For example, an application-level routine, MOTEapp.c, collects sensor data and transmits the data through the LoRaWAN connection, handling the low-level mac commands expected by the RN2903 (Listing 1).

            . . .

            moteApp_clearBuffers();

            // Make Sure Port is in allowed Range

            // Prepare DataBuffer for Tx

            light = 0;

            temperature = 0;

            NOP();          

            // Measure Sensors

            moteApp_setSensorsInput();

            uint8_t sizeOfUpdate = 0;

            light = moteApp_convertSensorValue(moteApp_getLightValue());

            oled_putString(moteApp_getLightString(), 6, 1);

            sizeOfUpdate = moteApp_addToDataBuffer(moteApp_getLightString(), 4);

           

            temperature = moteApp_convertSensorValue(moteApp_getTempValue());

            temperature = ADC_TempConversion(temperature);

            moteApp_add8bToDataBuffer(temperature, 4 + moteApp_lightStringSize() + 1);

 

            // Do Normal Operation

            . . .

            // Getting Random Channel

            randomPortNum = TMR2_ReadTimer();

            . . .

            // Prepare DataBuffer for Tx

            moteApp_add8bToDataBuffer(randomPortNum, 0);

            dataBuffer[3] = 0x20;

            NOP();

            sendDataCommand("mac tx uncnf ", dataBuffer, 12);

            . . .

Listing 1: Microchip provides C software demonstrating a sample IoT application that collects data from the Mote’s light and temperature sensors, builds a message with the data (add8bToDataBuffer) and transmits the message (sendDataCommand) using the mac tx command. (Code source: Microchip Technology)

Application-level development

Along with the simplified keyword-based command approach, the Microchip LoRa modules and associated Mote development boards significantly simplify development of LoRaWAN end devices. Yet, even the system-level Mote board and its associated software address only the lowest, end-device level of the LoRaWAN hierarchy. A complete LoRaWAN-compatible network requires additional hardware components including compatible gateway(s) and a network server.

Further, in implementing an IoT application, developers must deal with the fact that the LoRa Alliance standard addresses only the lowest levels of the standard OSI stack. As a result, developers need to complete additional networking layers, starting with the OSI network layer that lies above the data link layer addressed by the LoRaWAN MAC standard.

Microchip addresses this need with a hardware and software development kit that implements a complete LoRaWAN-compatible network, including end devices, gateway, and network server. The Microchip RN2903 LoRa Network Evaluation Kit and the RN2483 LoRa Network Evaluation Kit bundle a pair of Motes with Microchip’s LoRaWAN gateway board. The board is comprised of a LoRaWAN gateway core board and an associated radio daughter card complete with antennas and cables.

On the software side, the kit uses the Microchip LoRa Technology Evaluation Suite which provides all of the software components required to fully evaluate an example LoRa system (Figure 2).

Diagram of Microchip's LoRa Network Evaluation Kit and software suite

Figure 2: Microchip’s LoRa Network Evaluation Kit and software suite implement a complete LoRaWAN network application, including end devices (Mote boards), gateway (core board), and network server (mchplora). (Image source: Microchip Technology)

The Suite provides a network server (mchplora) as a docker container designed to run on virtual machine in a development system. The gateway board connects to the development system through USB and communicates wirelessly with the Mote boards. The Mote boards connect through the development system’s USB to the java-based development utilities.

Designed to work with the Evaluation Suite, the Microchip LoRa Development Suite provides a comprehensive java suite that provides a more extensive set of services than available with the Mote C library. For example, to send a MAC transmission, the Development Suite abstracts the underlying transactions to a simple execute method of a macTX class (Listing 2).

  void macTXSendAction()

  {

    if (this.application.device.updateValueFlag)

      this.application.device.wanPojo.setData(this.data.getText());

    if (this.application.device.updateValueFlag) {

      this.application.device.wanPojo.setPortNumber(this.portNumber.getText());

    }

    ICommand macTX = CommandFactory.getCommand(CommandFactory.mactx);

    DeviceModel currDev = this.application.device;

    macTX.setDataModel(currDev);

 

    List task = new ArrayList();

    task.add(macTX);

 

    if (currDev != null)

      this.application.mvcController.execute(task);

    else

      System.err.println("Current Device not set");

  }

Listing 2: The Microchip LoRa Development Suite provides a complete LoRaWAN environment including an extensive set of java packages (jar files) that abstract LoRaWAN transactions such as mac tx to a set of simple software calls such as macTXSendAction(). (Code source: Microchip Technology)

In Listing 2, CommandFactory is a class defined in LoRaDevUtility.jar that defines

  public static String mactx = "mac tx";

and then creates an instance of the appropriate class, in this case, a macTx class object, when the factory is called as CommandFactory.mactx:

    if (command.compareTo(mactx) == 0)

      return new macTX();

The macTX.class in LoRaDevUtility.jar provides runtime configuration values and various service functions such as packet validation as well as the class’ primary utility method, execute. The execute method creates the required mac tx command string in the required format, transmits the message (WriteI2cData), and then acquires the response:

       . . .

          command = new StringBuilder().append("mac tx ").append(((DeviceModel)this.server).wanPojo.getIsConformed()).append(" ").append(((DeviceModel)this.server).wanPojo.getPortNumber()).append(" ").append(((DeviceModel)this.server).wanPojo.getData().replace("0x", "")).toString();

       . . .

        byte[] data = command.getBytes();

        ((DeviceModel)this.server).getController().transport.WriteI2cData(this.processPacket.pack(data), null, this.timeout);

 

        byte[] read = null;

        read = super.readResponseData();

Conclusion

Efficient connectivity is a fundamental requirement for IoT networks comprised of massive numbers of low-power IoT devices. LoRaWAN offers an effective IoT connectivity solution that offers long-range operation with minimal power requirements. As with any connectivity option, implementation can prove a major undertaking in itself, distracting developers from their primary focus on the IoT application itself.

Based on Microchip Technology’s RN2903 LoRa module, Microchip Technology’s LoRa Network Evaluation Kit and accompanying LoRa Development Suite provide a complete LoRaWAN application. Using this combination of pre-certified hardware and software, developers can quickly bring up an IoT connectivity solution able to achieve a 15 km wireless range and 10-year battery life.



How I Got My Dragonboard 410C Airborne

$
0
0

How I Got My Dragonboard 410C Airborne

I was recently a guest on 96Boards OpenHours to demonstrate how the Aerocore 2 for Dragonboard 410C can be used to quickly and easily build a working quadcopter.   I even powered it up and tested it out indoors live.

If you want to see what happened, check out the YouTube video. The test flight happens at around the 40-minute mark.

Drones are awesome and not that hard to set up.  You can follow along with me if you’re building your own.  Once you’ve got your rig put together, then you can start adding software to the Dragonboard — or Any 96Boards CE SBC — to turn it into a self-piloting, obstacle-avoiding, object-following marvel of automation… or whatever it is you plan to do with it.

To find out more about the Aerocore 2 for Dragonboard 410C, you can read my previous post or watch this promo video.

The Parts

The first step in building your quadcopter is to make sure you have all of the hardware you’ll need.  Here’s what I had on-hand:

You know you work somewhere cool when you can assemble a drone from hardware lying around the office.

The Prep

To keep this post brief, I’m going to glaze over the following steps.  They’re fairly straightforward and unrelated and ubiquitous in MAV deployment so there are plenty of instructions available on the web.

  1. Assemble your drone kit.
    • Do not attach the rotor blades yet. You really don’t want your drone unexpectedly taking flight in the middle of your office/house/garage.
  2. The 12V battery connector and regulator on the Aerocore can handle the main battery’s output but there is no built-in connector on the drone or the battery.  
    • You can solder some jumper wires onto one of the motor power terminals on the base plate of your drone (circled in green here)
  3. Make sure you’ve flashed your Dragonboard with Linux. Linaro’s Debian 16.09 was used for this demo.
  4. Build QGroundControl.
  5. On your dragonboard 410C install the necessary packages
    • $ sudo aptget update && sudo aptget install pythonwxgtk3.0 pythonpip pythonnumpy pythondev libxml2dev libxsltdev gstreamer1.0-tools
    • $ sudo pip install pymalink
    • $ sudo pip install mavproxy
  6. Bind your satelite DSM receiver with your radio

(UPDATE:  Since the original project was completed, something about the pymavlink pip package has changed and will no longer install dependencies correctly.  therefore, add python-lxml to your apt-get command before installing pymavlink and mavproxy)

Put It All Together

Now the fun stuff can begin!  It’s time to get everything hooked up and ready to fly.

Step 1: Attach your boards

With this thing going up in the air, you won’t want your hardware sliding around at all so it’s good to put some thought into how your boards are mounted.  The chassis I’m using doesn’t have what I’d call a universal mounting system, so I made my own.  The box for an Intel Edison turned out to be just the right size and very sturdy.  I’ve already been using one on the rover in my RTK project to house a Beaglebone Black.

Some zip ties, screws and risers quickly transformed the cardboard box into a mounting bracket for my Dragonboard.  A touch of shameless self-promotion and it’s ready.

Board goes on brackets, Aerocore on board.  I used a bit of electrical tape to hold the receiver in place and was ready to wire it up.

Pro-Tip:

MAVs tend to have alarm buzzers, used to indicate low battery and signal loss.  This is very important when in flight, but when you’re setting everything up it can be really annoying.  Thankfully, the buzzer on the Aerocore 2 has a bypass circuit. After soldering a 2-pin header on the underside of the Aerocore, directly underneath the buzzer, you can use a jumper to deactivate the alarm.  For obvious reasons, I don’t recommend hard-wiring the alarm bypass.  The picture to the right should help you find the two vias to connect.

  Step 2: Connect Wiring

One benefit of using a box as a mounting bracket is that it has proved to be the ideal place to hide excess wiring.  I cut a small opening in the bottom of the box and fed all of my wires in and through.  I got my hands on a webcam and managed to squeeze its base and cable in there too.  I labeled the following image so you can see where the various connections are.

Not having previous experience with MAVs, I had no idea what order to hook the electronic speed control PWMs in.  It took me a while, but I figured it out.  I put together an infographic for the rest of the amateur MAVers so that you don’t have to struggle like I did.

Step 3: Software

The final pre-flight step is to configure your software.  There are three steps:

  1. Flash PX4 firmware to the MCU
  2. Start data pipeline on the Dragonboard
  3. Calibrate on-board sensors

QGroundControl makes programming and configuring your drone a snap.  Open up the program and go to the setup tab ().  Along the left-hand side will be a button labeled “Firmware”. When you click on this button and then connect the Areocore 2 MCU’s “stm console” via USB, QGC will guide you through the flash process.

The rest of the pre-flight work can be done over WiFi on the Dragonboard. Going wire-free will also make calibration a little easier.

Disconnect the USB cable from your Aerocore and connect the battery. Once the MCU and Dragonboard boot, SSH into the Dragonboard and enter the following command:

mavproxy.py master=/dev/ttyMSM1 baudrate 115200 out xxx.xxx.xxx.xxx:14550 aircraftMyCopter

Where xxx.xxx.xxx.xxx is the IP address of your PC.

Once the MAVlink command interface comes up on the Dragonboard, QGC should be able to connect to your drone. If it does not connect correctly, you may have to add a UDP connection to QGC’s settings.  The setup screen should look simmilar to the following screenshot:

If this is the first time your Aerocore has been configured, the cicles that appear green in this shot will be red and you will not be able to deploy your drone until they all appear green.

Configuring your drone and calibrating the sensors is very straightforward thanks to the self-explanatory interface in QGC.  Click on each item along the left-hand side in turn — apart from “Firmware”, which you have already done — and follow the on-screen instructions.  Once all the lights are green, you’re ready to fly.

The final, and completely optional steps are getting the camera feed from the Dragonboard to QGC, and attaching a Pre-GO GPS module.  

Adding a GPS module is very easy.  Once it’s connected, it will work right away.  Connect it to the 5-pin molex connector next to the DSM satellite receiver connector.  Power down your drone and plug the module in using the included cable, and it’s ready.  I added mine last thing right before the live test flight and it worked with no set-up required.

The video streamer, like the MAVlink proxy, is a single command on the Dragonboard:

gstlaunch1.0 uvch264src initialbitrate=1000000 averagebitrate=1000000 iframeperiod=1000 \

   device=/dev/video0 name=src autostart=true src.vidsrc ! video/xh264,width=1920,height=1080, \

   framerate=24/1 ! h264parse ! rtph264pay ! udpsink host=xxx.xxx.xxx.xxx port=5600

With both the proxy and the video feed running on the Dragonboard, your flight screen will look something like this:

If you have added a Pre-GO GPS module, your drone’s location will appear in the navigation map seen here in the inset. You can switch the primary view between the video stream and the navigation map by clicking on the inset in the bottom left-hand corner.

 

And There You Have It…

You now have yourself a working drone.

Posted by Keith the Gumstix Guru at 4:01 PM


Portable Cell Network

$
0
0

Portable Cell Network

This project is deployable on Raspberry Pi using BladeRF and allows for the creation and operation of a custom local GSM cell tower.

Project Documentation

Project By: Matthew May & Brendan Harlow for Champlain College SEC-440

Introduction

The goal of this project is to create a private secure portable cell network utilizing basic technologies for mobile phones that can be easily deployable in any situation. In the event of an emergency, commodity cell networks can easily become severely congested and overwhelmed. Having the ability to set up secure and reliable communications for civilians or law enforcement can save lives, facilitate responses, and provide confidence in decision making.

The radio system that we are using for the cell phones to communicate with is the GSM protocol (Global System for Mobiles) more commonly used by cellular provider such as AT&T and T-Mobile. To broadcast the radio system, we are going to be using a Software Defined Radio (SDR) device called the BladeRF (external). This hardware is controlled by the Raspberry PI (small single-board computer) (external) using YateBTS (external) which is software that implements functions and protocols of both the radio access network and the core GSM network to allow cell phones to communicate using voice, text, and data. The Raspberry PI is instrumental to reach our goals of portability due to its size, low power usability, and cost over alternatives.

Prerequisites

To deploy the portable cell network using our instructions you’ll need the following:

  • Raspberry Pi (We used a 3rd Generation Model B Pi)
  • MicroSD Card (32GB Recommended)
  • Nuand BladeRF (We used the BladeRF x40, the smaller card offered by Nuand)
  • SSH enabled on the Pi (For ease of use, Terminal works fine too)
  • GSM and SIM card compatible phones
  • SIM cards (sysmoSIM-GR2)
  • Ethernet Cable (If you desire the phone’s to have local internet connectivity)

Raspberry Pi Setup

Click here for a photo-rich version of these instructions.

  • Plug-in the Ethernet, Power Supply, and Keyboard to the Pi and then plug the power adapter into the wall. When you reach the login screen login with the default credentials
    • Username: pi
    • Password: raspberry
  • Run
sudo raspi-config

Change Keyboard Layout

  • Scroll down to ‘Localisation Options’ and press ‘Enter’
  • Scroll down to ‘Change Keyboard Layout’ and press ‘Enter’
  • Scroll down to ‘Other’ and press ‘Enter’
  • Scroll down to ‘English (US)’ and press ‘Enter’
  • Scroll to the very top to ‘English (US)’ and press ‘Enter’
  • Hit ‘Enter’ to accept the defaults on the next two screens, since they don’t apply.
  • When you get past the last two steps you will be returned back to the main menu.

Enable SSH

  • Scroll down to ‘Interfacing Options’ and press ‘Enter’
  • Scroll down to ‘SSH’ and press ‘Enter’
  • Scroll to ‘Yes’ and press ‘Enter.’
  • On the next screen, press ‘Enter’ to go back to the main menu.
  • When you’ve reached the main menu, scroll to the right and select ‘Finish,’ then press ‘Enter’
  • When back at the terminal, run the command below to enable the configured settings.
sudo reboot now

Network Deployment

To make your life easier, SSH to your Raspberry Pi. Note your Pi’s IPv4 address from the command below:

ifconfig eth0

On another computer, utilize a terminal application and run:

ssh pi@[INSERT PI IPV4 ADDRESS HERE]
  • Once prompted for credentials, again, enter:
    • Username: pi
    • Password: raspberry

Now we are interacting with the Pi remotely.

Let’s start gathering what we need for deployment.

# Download the script from GitHub
wget https://raw.githubusercontent.com/MBRO95/PortableCellNetwork/master/PortableCellNetwork.sh

# Make the downloaded script executable 
chmod +x ./PortableCellNetwork.sh

The script will check to make sure you’re running as root, so make sure you don’t leave out the ‘sudo’ portion of the commands below.

To run the script without logging its output, issue:

sudo ./PortableCellNetwork.sh

To run the script while logging its output, issue:

sudo ./PortableCellNetwork.sh | tee install.log
  • The script will query you for a network name
    • Provide one and confirm it
    • OR
    • press ‘Enter’ to accept the default name of ‘DuaneDunstonRF’
  • Confirm your network name
  • The script will now initiate the installation and configuration process. This will take close to an hour so you can go find something to do in the meantime.
  • When the script is nearing completion it will query for a new user password for the ‘pi’ user.
    • Enter and re-enter this password to change from the default for added security.

When the script completes it will report how much time it took to run and wait for a keypress to reboot.

  • Press any key to reboot the pi.
    • You will be rebooted into a desktop environment, simply select the ‘Default Configuration’ option at the pop-up that launches at first boot.
  • A startup script titled ‘StartYateBTS.sh’ will await you in ‘/home/pi’ and will start the cell network processes.
    • To boot the startup script it is imperative that it is run in interactive mode by passing the ‘-i’ flag after the script name, like below:
sudo ./StartYateBTS.sh -i

Once started, this script will:

  • Open a terminal window reporting the Yate (cell network) status
  • Open a Firefox browser window that will navigate to YateBTS (web-based cell network configuration)
    • Here you can view/modify network configuration settings and manage/write SIM cards for devices.

Phone Deployment

To join a compatible phone to the cell network, SIM cards need to be deployed to work with the correct settings. YateBTS uses a utility called PySIM, a python tool for programming SIM cards. In the installation script PySIM is already set up as the correct version that supports the SysmoSIM-GR2 card type. To start, make sure that the compatible SIM card writer is inserted into the Raspberry Pi with the SIM card to program already in it.

Open the tab called Manage SIMs as shown below and make sure that the Generate random IMSI setting is checked and the Insert subscribers is unchecked. The insert subscribers setting will break the functionality of the cell network and is recommended to avoid unless there is a fix for it. Image of SIMprogramming1

The next step is to check that the correct settings have been set in the Advanced drop down bar. Make sure the Operator name reflects the correct setting that was chosen for the cell network. Otherwise use the default settings and hit save. Image of SIMprogramming2

The screenshot below shows an example output that the SIM programming was successful. And lastly that the deployed SIM card shows in the Manage SIMs list.Image of SIMprogramming3

After inserting the SIM card into the GSM phone and powering on, YateBTS will send a welcome message with the assigned number for the phone as shown in the screenshot below. To troubleshoot if the Android phone is not connecting to the cell network properly, open the dialer application and type *#*#4636#*#*. A menu will appear and in the phone information tab, select the preferred network type to be GSM only and restart the phone. Image of SIMprogramming4

Security Overview

A security model was implemented in our installation script based on the Center for Internet Security (CIS), which is a highly reputable source for best practice information security. The script incorporates a benchmark model designed for Debian 8 operating system. The Debian 8 operating system is the closest relating Linux distribution to the Raspberry Pi image, therefore we decided that this model was the best choice to use for reference. Originally, we did run into a set back with the security functionality of the Raspberry Pi because it does not support custom partitions that can implement security controls, such as full disk encryption and partition modifiers that deny arbitrary executions and protect against attacks that fill up disk space. The goal of the security script was to implement as many controls as we could while keeping the functionality of the Raspberry Pi operating system and the Yate software.

The model follows the practice of disabling anything that is unnecessary to the functionality of the system to reduce the potential attack surface. Performing periodically updates and patches to fix security flaws can be a challenge for a system that is designed to be mobile and in areas where there may not even be access to the Internet.

Update the operating system

Rationale: Periodically patches contain security enhancements, bug fixes, and additional features for functionality.

sudo apt-get -y dist-upgrade

Enable sticky bit on all world writable directories

Rationale: Prevent unauthorized users from modifying or renaming files that belong to a different owner. echo “Setting sticky bit on world writable directories”

df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -type d -perm -0002 2>/dev/null | xargs chmod o-t

Remove unnecessary filesystems

Rationale: Removing support for unneeded filesystem types reduces the local attack surface on the Pi.

echo "install cramfs /bin/true" >> /etc/modprobe.d/CIS.conf
echo "install freevxfs /bin/true" >> /etc/modprobe.d/CIS.conf
echo "install jffs2 /bin/true" >> /etc/modprobe.d/CIS.conf
echo "install hfs /bin/true" >> /etc/modprobe.d/CIS.conf
echo "install hfsplus /bin/true" >> /etc/modprobe.d/CIS.conf
echo "install squashfs /bin/true" >> /etc/modprobe.d/CIS.conf
echo "install udf /bin/true" >> /etc/modprobe.d/CIS.conf

Remove unnecessary network protocols

Rationale: The linux kernel supports uncommon network protocols that are unneeded for what our goals are for this project. Therefore they should be disabled.

echo "install dccp /bin/true" >> /etc/modprobe.d/CIS.conf
echo "install sctp /bin/true" >> /etc/modprobe.d/CIS.conf
echo "install rds /bin/true" >> /etc/modprobe.d/CIS.conf
echo "install tipc /bin/true" >> /etc/modprobe.d/CIS.conf

Disable core dumps incase an application crashes

Rationale: A core dump is the memory of an executable program. It is generally used to determine why a program aborted. It can also be used to glean confidential information from a core file.

echo "* hard core 0" >> /etc/security/limits.conf
echo 'fs.suid_dumpable = 0' >> /etc/sysctl.conf
sysctl -p
echo 'ulimit -S -c 0 > /dev/null 2>&1' >> /etc/profile

Disable unnecessary services

Rationale: It is best practice for security to disable unnecessary services that are not required for operation to prevent exploitation.

systemctl disable avahi-daemon
systemctl disable triggerhappy.service
systemctl disable bluetooth.service

Change the pi user password

Rationale: The default password needs to be changed from raspberry. Strong passwords protect systems from being hacked through brute force methods. Password set cannot be a dictionary word, meet certain length, and contain a mix of characters.

passwd pi

General Remarks & Useful Notes

Real-world range testing:


Pixhawk + Ardupilot + 交叉编译工具链 + QGC(AP)

$
0
0

Pixhawk + Ardupilot + 交叉编译工具链 + QGC(AP)

参考资料:
老吴学长教程:http://www.nephen.com/arrange/archive.html
Ardupilot:http://ardupilot.org/copter/index.html
Pixhawk开发者:http://dev.px4.io/


Pixhawk

首先稍微介绍一下Pixhawk,它很贵,是的.国外原装的估计的是700多,国内某宝上有很多公司自己仿照它做的板子也得588.目前据我所知道的某宝上卖的最便宜的Pixhawk是梦创团队做的,由于是手工焊制因此还有待提高其工业水平.不扯淡了,想玩无人机的朋友应该都知道大疆这个公司,目前它的无人机市场占有率很高,详情可以搜一搜相关新闻.大疆也很贵(其实要想玩无人机还是得掏钱啊),上次我们学校一老师让我们观看一下大疆的一款飞机,好像是”悟”系列的,说是从美国带回来的,20000RMB.~__~.所以对于我们一般的爱好者怎么办的?国外开源之王–Pixhawk是首选.硬件开源(为啥能够轻易仿制),固件开源(降低二次开发难度),上位机也开源(扩展高级功能).基本上能够满足无人机平台各个专业的需求.以前它叫做PX4FMU+PX4IO,其实对应到真正的板子上就是一个是stm32f4的芯片,另一个是stm32f1的芯片,主要是它俩加起来搞在一块板子上就是Pixhawk.PX4FMU负责进行高级的浮点运算等,PX4IO负责低级的定时器输出PWM等,两者共同运行了一个叫做Nuttx的嵌入式实时操作系统.如果是买回来的套件,板子肯定已经上载好了bootloader,如果是自己制作,必须在焊接好之后用Jlink等工具首先将bootloader上载进去,而后再通过交叉编译工具链或者上位机用USB接口连接电脑和板子下固件到板子.基础的板子一般只能飞基础的功能,比如自稳模式,定高模式啦.如果要飞高级模式,比如悬停,留待,自动模式啥的得需要GPS或者光流计等可选的硬件设备.所以,还是得舍得花钱…其实说到开源飞控平台有很多,比如国内做得还可以的匿名团队,有兴趣的小伙伴可以去了解一下.下图是梦创的板子.
梦创的板子

Ardupilot

这个是一个固件或者说是软件,相对于一般的用户来说就是固件,因为不去更改它.作为开发者来说就是一个软件平台,必须要进行二次更改或者移植去定制自己的功能.首先要说到APM团队,也是一个无人机开发团队,其实最早是PX4团队在Pixhawk上开发出了固件,然后APM也借助了他们的劳动成果在Pixhawk上加入了自己的一个应用程序ArduCopter,这个程序作为一个进程在Nuttx里面被nsh脚本启动.而后再进行各种运算和控制…可能玩过航模的童鞋知道ArduCopter,这玩意儿支持很多架构,不只多旋翼,还包括固定翼和小车等.因为APM团队早期是在基于Avr芯片的arduino板子上跑的软件APM2.x,后来发现低端的资源配置已经不能满足大量的运算了,正巧来了Pixhawk,因此APM团队仍然在完成移植和新功能的开发工作上面.我们为什么不用PX4的固件转而来学习APM的固件呢?答案是简单一些,功能上它们俩差不多,但是在功能的源码实现上不太一样.我们可以分别从各自的github仓库里面fork并clone代码到本地用编辑工具(如sublime等)打开查看就知道了.至于怎么分析代码架构,请先学好单片机等相关知识以及飞行器的基本原理,最好有很好的高数基础和信号滤波的概念.而后,学好C++,就可以开始你的DIY之旅了.如果英文够好的话直接去官网看开发者教程就可以了.下图可以看到ArduCopter也是支持很多硬件平台的,我们编译的时候键入make px4-v2即可.键入make px4-v2-upload即可上载代码.我的开发平台是ubuntu 16.04 amd64.
targets

交叉编译工具链

熟悉嵌入式开发的筒子们肯定都知道,我们在写好代码编译后是需要借助第三方电路结构(例如Jlink,串口有时候也支持)将程序从PC下载到板子上去.这是主要是由于指令集不一样所以要进行交叉编译,除非板子上已经装好了系统了…具体到开发Pixhawk所用到的编译器就是arm-none-eabi-gcc家族,详情安装方式参考官网APM或者PX4都可以,也可以看我学长的教程,只要搭建好这个环境编译APM或者PX4原生固件都是可以的.建议开发平台为Linux,win上面可能会出很多问题,也不建议在win上装Linux虚拟机,因为我当时就出了问题一直木有解决…最好装个双系统啥的.再说,Linux足够安全(相对概念,具体看设计),不是吗?下图是我的arm-none-eabi-gcc版本号.
arm-none-eabi-gcc

上位机

一款好的飞控开发出来,如果没有易于调参的上位机很是麻烦.Ardupilot里面大大小小的参数百多个,最经典的几个PID参数必须要调的.当然运气好机架和参数恰好对应了就不必这么麻烦了.还有些可选的硬件,在上位机里面修改比取修改源码方便多了.Linux上推荐使用QGC和APMPlanner,QGC和APMPlanner都是基于Qt写出来的上位机,直接支持Linux,Win,Mac.APM Planner而且还可以分析飞控上SD卡的飞行记录数据.而Mission Planner是用.net写出来的,在Linux上的话需要安装mono环境才能跑.对于校准加速度计和磁力计的话MP特别麻烦,转很久可能都转不到某些点.而且这里面的上位机几款都是开源的.有兴趣的都可以研究一下mavlink协议以及图形渲染相关编程技术.下图是APMPlanner的截图.
APMPlanner


总结

去年加入的实验室,学stm32f1基础知识,从定时器输出PWM控制电调和定时器输入捕获PWM获取遥控器量,到SPI总线协议收发射频信号,I2C协议获取IMU传感器数据,到基础互补滤波和姿态融合算法,串级PID算法控制PWM输出量.一路走来对飞行器有了基本的认识,今年寒假开始的Pixhawk学习,到近期的电赛结束,算是画上了一个简单的分号吧.感谢各位帮助过我的筒子们,加油吧,学弟学妹们,明年电赛好好干.


LPC810 Code

$
0
0

//—————————————————————————-
// Name: LPC810_Blink.c
// Purpose: LED Flasher
// pin #8 set for LED
//—————————————————————————-
#include <stdint.h>

//registers used for gpio & systick setup
#define GPIO_NOT (*((volatile unsigned int *)(0xA0002300)))
#define GPIO_DIR (*((volatile unsigned int *)(0xA0002000)))
#define SYSCON_PRESETCTRL (*((volatile unsigned int *)(0x40048004)))
#define SYSCON_SYSAHBCLKCTRL (*((volatile unsigned int *)(0x40048080)))
#define NVIC_ST_CTRL (*((volatile unsigned int *)(0xE000E010)))
#define NVIC_ST_RELOAD (*((volatile unsigned int *)(0xE000E014)))
#define NVIC_ST_CURRENT (*((volatile unsigned int *)(0xE000E018)))
#define SCB_SHP1 (*((volatile unsigned int *)(0xE000ED20)))

//our systick interrupt handler
void SysTick_Handler(void) {
GPIO_NOT = (1<<0); //toggle led pin
}

https://github.com/taisukef/wakeupeverymin/blob/master/main.c
int main(void) {
//enable AHB clock to the GPIO domain
SYSCON_SYSAHBCLKCTRL |= (1<<6);
//reset gpio peripheral control
SYSCON_PRESETCTRL &= ~(1<<10);
SYSCON_PRESETCTRL |= (1<<10);
//make gpio #0 pin an output (physical pin #8)
GPIO_DIR |= (1<<0);

//set systick clock interrupt reload count
NVIC_ST_RELOAD = (1200000UL & 0xFFFFFFUL) – 1;
//set SysTick IRQ to lowest priority
SCB_SHP1 = 0xC0000000;
//reset the counter
NVIC_ST_CURRENT = 0;
//enable the IRQ and go
NVIC_ST_CTRL = 0x07;

//loop forever
while(1)
asm(“wfi”); //wait for interrupt
}

#include <stdio.h>
#include “LPC8xx.h”
#include “mrt.h”

#define LED_LOCATION 2
#define GND_LOCATION 3
#define ISP_LOCATION 1

#define LED_ON() (LPC_GPIO_PORT->SET0 = 1 << LED_LOCATION)
#define LED_OFF() (LPC_GPIO_PORT->CLR0 = 1 << LED_LOCATION)

#define ISPBTN() (!(LPC_GPIO_PORT->PIN0 & (1 << ISP_LOCATION)))

// deep power down
void deepPowerDown(void) {
// if (LPC_PMU->PCON & 0b100)
// return 1; // error
LPC_PMU->PCON = 3;
SCB->SCR |= 0b100;
asm(“wfi”);
}
void deepPowerDownWithWakuUp(int msec, int usewakeuppin) {
LPC_PMU->DPDCTRL = usewakeuppin ? 0b1100 : 0b1110;
LPC_PMU->PCON = 3;
SCB->SCR |= 0b100;
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 9); // enable WKT
LPC_WKT->CTRL = 0b111;
LPC_WKT->COUNT = msec * 10;
asm(“wfi”);
}

void init() {
LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 7); // enable SWM
// LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 18); // enabel UART

// pin config
LPC_SWM->PINASSIGN0 = 0xffff0004UL; // U0_TXD, U0_RXD
LPC_SWM->PINENABLE0 = 0xffffffbfUL;

LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 6); // enable GPIO
LPC_SYSCON->PRESETCTRL &= ~(1 << 10); // GPIO reset
LPC_SYSCON->PRESETCTRL |= (1 << 10); //

LPC_GPIO_PORT->DIR0 |= 1 << GND_LOCATION;
LPC_GPIO_PORT->CLR0 = 1 << GND_LOCATION;

LPC_GPIO_PORT->DIR0 |= 1 << LED_LOCATION;
LPC_GPIO_PORT->CLR0 = 1 << LED_LOCATION;

mrtInit(__SYSTEM_CLOCK / 1000); // multi-rate timer for 1ms
}
int main() {
init();
mrtDelay(100);
deepPowerDownWithWakuUp(60 * 1000, 0); // wake up after 30sec, disable wake up pin
}


Efficient DC 12V to 5V conversion forlow-power electronics, evaluation of six modules

$
0
0

Efficient DC 12V to 5V conversion forlow-power electronics, evaluation of six modules 5

I am currently working on a vehicle-installed Arduino project. The device is designed to be powered constantly and I decided to use the car battery as the constant power source. I am designing the device for low power consumption, consuming 50mA or less, ’cause who wants to get stuck with a flat battery, right?

Car battery typically provides 7 to 15 volts, but some standards mention that 40V spikes are possible. Car battery voltage is normally around 12V but drops to ~7V when you are cranking up the engine and it goes up to ~14V when the engine is running and the battery is being charged. Since we don’t want our device to reset during crank-ups we would like to perform conversion of input voltage of 7 to 20 volts to a fixed 5 volts output that the Arduino Uno expects.

Voltage regulators

The Arduino Uno has a voltage regulator on board which we could use. It is recommended for voltages between 7 and 12 volts. This means that we would have to lower the car battery high voltage first with an external component before we can feed it in the Arduino Uno board. Unfortunately, that alone would not solve our problems as it would not address our efficiency requirements.

The issue with using the voltage regulator is that the regulator is wasteful. Any extra voltage that needs to be dropped is converted to heat. The formula for efficiency is eff(reg)=Vout/Vin. A voltage regulator has some advantages too, one of them is stability, which means it can keep a very stable and accurate output voltage. Another advantage is its compact size.To perform an efficient conversion, we would have to use a switching power supply, specifically a buck converter, which will step down the voltage for us. A buck converter will turn the input on and off quickly as much as needed to provide the required voltage and power at the output. The rest of this article will compare six different step-down (buck) modules. If you are not familiar with how a switching-mode step-down converter works, read this article which also compares some modules at higher loads.

Candidate modules

One implementation that I considered is to drop the battery voltage to around 7 volts and then power the Arduino through its voltage regulator. The advantage is a more stable voltage for the Arduino, however, there would be waste of energy of 1-eff(reg)=1-5/7=28%. Furthermore, every conversion process requires some margin between Vin and Vout, so by having two stages it becomes difficult for us to support the lower end of the car battery voltage range, creating potential issues with resets during engine cranking.

So I ended up looking for modules that can take the car battery range and output 5 volts. This could be an adjustable module or one fixed at 5 volts. I would connect those modules to an Arduino USB port (preferred due to additional protections present there) or directly to an Arduino 5V pin. This means that there is some preference to modules with a built-in female USB output port, though adapters or converter cables can be made to compensate for lack of it.

Modules

The modules I tested originate from the Far East and most of them were bought on eBay for between 1 and 2 USD (including shipping). This means that most of them don’t have a clear model number or a manufacturer name. I will come up with a short name for each module so I can mention them easily. I acknowledge that the quality of the photos could be better. I tried my best with the equipment I had available. Also note that each photo is at it’s own scale. Here are the modules in no particular order.

Cigar

This adapter has a cigar lighter plug on one end and is built for plugging into to the cigar lighter socket in a car. The output socket is a female USB port. Such modules are sold to end users for charging USB devices in a car. I have no idea where I got this, but I found it in my parts bin, took it apart and used it in this research.

Since such converters are sold to end users, their listings typically don’t show a photo of the PCB, so it is a roulette with regards to what chip and efficiency you are getting.

Adjustable

This adapter was sold on eBay as “DC-DC Adjustable Step-down Power Module LM2596 4.75-24V To 0.93-18V”. In reality, there is no LM2596 chip there, something that shouldn’t be a huge surprise for eBay shoppers out there. It IS an adjustable step-down module which is great for prototyping. You adjust the output voltage with the multi-turn potentiometer. The input and output connectors are screw terminals and you can see I have connected them to a barrel plug for convenient use.

Ammeter

This module was sold on eBay as “DC Step Down Converter 2A Constant Voltage Current w/ Voltmeter Ammeter”. It has adjustable voltage, current and a display that can show input/output voltage and output current. Very nice for prototyping. For some people this can even be an alternative for a proper bench power supply. This module has connectors that are similar to the “Adjustable” module, the method of adjustment is also similar.

Fine

This module by QSKJ was listed as “Fine 6-24V 12V/24V to 5V 3A CAR USB Charger Module DC Buck step down Converter”. It is one of the smallest modules in the test. This is clearly built for integrating into other projects as it features two solder pads for input. The output is a rather nice female USB port. Listing mentions lots of additional features, such as latest USB identification circuit, protection circuits, ultra-low static current (of 0.85mA) and more.

600mA

This module marked “DM01” is 100% designed for integration. Inputs and outputs are through solder pads. Seems like this module also comes in 3.3, 9 and 12 volts editions. It was listed for sale as “600mA DC-DC Step Down Buck Module 6-55V to 5V Fixed Output Voltage Regulator”. It could be the smallest module of the 6, but the lack of a USB port makes it an unfair comparison. One feature that differentiates this module from others in the test is that it has an “EN” pad. You can control this connector to shutdown and start the module when needed. Shutdown current is advertised as less than 1uA. If you are just going to bridge this pad to “Vin+”, no worries too, this module’s “no load current” is just 0.7mA.

Precise

This module has the same connections as “Fine” but it is a bit larger. It was sold as “3A DC-DC 9V/12V/24V to 5V USB Step Down Power Module 2A Precise Vehicle Charger”.

Voltage and current

Here are some electrical properties of the 6 modules. I didn’t have module properties for “Cigar” so the ranges are based on chip specs and could be better than actual module ranges.

Module Input voltage Output voltage Max output current Peak output current
Cigar 3 – 40V 5.4 – 5.5V 1.5A ?
Adjustable 4.75 – 24V 0.93 – 18V 2.5A 5A
Ammeter 4.5 – 24V 0.93 – 20V 2A ?
Fine 6 – 24V 5.1 – 5.2V 2.1A 3A
600mA 6 – 55V 5V 0.6A 1A
Precise 7.5 – 28V 5V 2A 3A

Peak current refers to ability to provide high current for a limited length of time. Max current refers to maximum current the module can provide consistently. Mind that some modules mention that operating at max current might require an additional heat-sink or cooling solution.

Few points worth mentioning: first, the “Cigar”, with its fixed USB output connector is providing voltage that is too high by proper USB standards. It could be due to old age or just bad quality. The difference is about 10% and I would consider it not usable. Second, most modules are capable of input voltages up to about 25 volts, but few can do 40 volts and higher. Kudos for that.

Switching circuit properties

Module Chip Frequency Inductor Stated efficiency
Cigar MC34063A 100Khz 220µH ? 83% at 24V and 500mA
Adjustable MP23070N 340Khz 10µH ? up to 98%
Ammeter MP23070N 340Khz 10µH ? ?
Fine MP2315 (AGCG mark) 500Khz 4.7μH 12V to 5V 1A can up to 94%
600mA HT7463A (463A mark) 1250Khz 22µH up to 96%
Precise MP1584EN 500Khz 15µH ? up to 96%

Higher switching frequency will mean less ripple on the output (more accurate voltage/current) but causes more overhead due to switching, which reduces the efficiency a bit.

Some inductor values have a ‘?’ next to them. This means the component was not marked and the value was estimated based on recommendations in the datasheet. Usually a lower frequency will require, a larger, higher value inductor.

Testing

First I measured the current used by my device, on the output side of the converter, which was around 50mA. I then I created a dummy load of 100 ohm using two 200 ohm resistors in parallel. I used a resistor array to reduce the load on each individual resistor which was rated for 0.25W. Due to Ohm’s law, a 100 ohm resistor would cause a 50mA load for a voltage of 5 volts, similar to what the device would.

Next I measured the current used by the converter on the input side, for both a device load and a dummy load. I observed that a real load and a dummy load with same average current both have a similar efficiency. A difference could arise since the dummy load power draw is fixed while the device could draw power in bursts, but this didn’t affect the results significantly. I concluded that using dummy resistors is good enough approximation for this test.

I then made dummy loads for 25mA, 50mA and 100mA currents using 1, 2 and 4 resistors in parallel.

To affect the measurement as little as possible, I used the ammeter on the input side (in series) and calculated the current on the output side using Ohm’s law I=V/R. This way there was no impact on the output side which could add a voltage drop and influence the results. Voltage V was measured in parallel and resistance R is known and depends on the dummy load used for each test.

The power supply for the test was providing 12V, but due to the voltage drop in the ammeter, the input voltage of the modules is a bit lower.

Results

I calculated the efficiency of each module per each type of load as:

eff = Pin/Pout = (Vin*Iin)/(Vout*Iout)

Datasheets of some of the chips used in the modules contained an efficiency graph. The efficiency is a function of voltage and current. When available, I added the listed chip efficiency for the relevant Vin and Iout in the last column. Some modules have efficiency charts that don’t cover low current ranges, which might be an indication for the type of load the chips were (not) designed for.

Output current of 25mA

Output current of 50mA

Output current of 100mA

Conclusion

Differences can be significant as seen above. At the lowest load test (25mA), the worst performer uses 3 times more power than the best.

Efficiency differences between modules become more subtle as load increases: 2x for 50mA and 1.5x for 100mA.

Input voltages are different. Higher current on the input side means higher voltage drop in the ammeter, resulting in a lower input voltage relative to the output of the power supply.

Listed chip efficiency is within 5-10% of the measured module efficiency. The delta could be due to inefficiencies in the module itself or due to differences in the overall conditions (temperature, etc).

And the winner is: “Fine”! This module is clearly the best for low power scenarios. When reaching currents of 100mA the differences between the 3 leading modules are minimal.

What makes “Fine” better than others? It is a relatively new IC. The datasheet is from 2014 where, for comparison, the MP2307’s is from 2008. It also features a very low Rds(on) values (90mΩ/40mΩ), but most interestingly the MP2315 has AAM (Advanced Asynchronous Modulation) power-save mode for light load.

Advanced Asynchronous Modulation (AAM) is a proprietary technology of MPS. With this technology in place, the IC will reduce its frequency when it detects low loads, thus reducing the overhead of switching but potentially introducing instability and ripples. A resistor’s value on the AAM pin determines when to start this behavior. Feel free to correct me in the comments if I am not explaining this correctly.

In conclusion, if you want an efficient module for light loads, you might want to try this one by QSKJ with an MPS MP2315 chip marked as AGCx (I have seen AGCG or AGCE used specifically). If you have other recommendations, please share them in the comments below. Have a great project!


books

$
0
0
预计发货日期:  201710月24日 – 201710月26
多旋翼无人机技术基础
多旋翼无人机技术基础
符长青
¥ 33.00
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
玩转四轴飞行器(全彩印刷)
玩转四轴飞行器(全彩印刷)
鲍凯
¥ 43.00
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
四旋翼无人机控制--基于视觉的悬停与导航(精)/无人机制导控制技术丛书
四旋翼无人机控制–基于视觉的悬停与导航(精)/无人机制导控制技术丛书
Luis Rodolfo Garcia Carrillo
¥ 51.60
通常需要9-11天发货。
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
macOS软件安全与逆向分析
macOS软件安全与逆向分析
丰生强
¥ 62.70
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
高等学校电子信息类专业系列教材:多旋翼无人飞行器嵌入式飞控开发指南
高等学校电子信息类专业系列教材:多旋翼无人飞行器嵌入式飞控开发指南
林庆峰
¥ 55.80
库存中仅剩 3 件(更多商品正在运送途中)。
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
深度学习(deep learning)
深度学习(deep learning)
伊恩·古德费洛 (Ian Goodfellow)
¥ 124.60
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
DIY四轴飞行器:基于MSP430F5系列单片机与Android
DIY四轴飞行器:基于MSP430F5系列单片机与Android
黄和悦
¥ 34.10
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
四旋翼无人飞行器设计(清华开发者书库)
四旋翼无人飞行器设计(清华开发者书库)
冯新宇
¥ 31.90
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
四轴飞行器DIY:基于STM32微控制器
四轴飞行器DIY:基于STM32微控制器
吴勇
¥ 30.90
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
视觉SLAM十四讲:从理论到实践
视觉SLAM十四讲:从理论到实践
高翔
¥ 59.60
卖家: 亚马逊 (亚马逊)
礼品选项不可用。
STM32库开发实战指南:基于STM32F103(第2版)
STM32库开发实战指南:基于STM32F103(第2版)
刘火良
¥ 79.20
卖家: 亚马逊 (亚马逊)
礼品选项不可用。

STM32 Arduino Tutorial – How to use the STM32F103C8T6 board with the Arduino IDE

$
0
0

  1. Connect FTDI 232 to the board. 5V to Vcc. Gnd to Gnd. Rx  — Tx(A9), Tx — Rx(A10)
  2. usb-ttl-ft232rl-pinout
  3. Make sure boot 0 is connect to 1.
  4. Press the reset button
  5. Put the following url http://dan.drown.org/stm32duino/package_STM32duino_index.json to the Additional Board Manager URLs in Arduino Preference.
  6. Go to Board Manager under Tools -> Board. Find Stm32F1 and install it.
  7. In the Board list, select Generic STM32F103C Series. Change the upload method to Serial. Choose the correct port number.
  8. Open the blinky example and change it to
  9. /*
    BlinkTurns an LED on for one second, then off for one second, repeatedly.

    Most Arduinos have an on-board LED you can control. On the UNO, MEGA and ZERO
    it is attached to digital pin 13, on MKR1000 on pin 6. LED_BUILTIN is set to
    the correct LED pin independent of which board is used.
    If you want to know what pin the on-board LED is connected to on your Arduino
    model, check the Technical Specs of your board at:
    https://www.arduino.cc/en/Main/Products

    modified 8 May 2014
    by Scott Fitzgerald
    modified 2 Sep 2016
    by Arturo Guadalupi
    modified 8 Sep 2016
    by Colby Newman

    This example code is in the public domain.

    http://www.arduino.cc/en/Tutorial/Blink
    */

    // the setup function runs once when you press reset or power the board
    void setup() {
    // initialize digital pin LED_BUILTIN as an output.
    pinMode(PC13, OUTPUT);
    }

    // the loop function runs over and over again forever
    void loop() {
    digitalWrite(PC13, HIGH); // turn the LED on (HIGH is the voltage level)
    delay(100); // wait for a second
    digitalWrite(PC13, LOW); // turn the LED off by making the voltage LOW
    delay(100); // wait for a second
    }



Restore a Sony Vaio PC to its factory settings

$
0
0

Restore a Sony Vaio PC to its factory settings

You often say that, my computer failed to do an specific action or I didn’t broke my PC, my Windows is slow or is running extremely slow, my computer is virus infected, my computer has no sound or my webcam is not working any more … and so on. Often, the solution of computer problems resumes to Windows reinstall.

All of you should know that this operation is not very pleasant: you have to format your windows drive, reinstall drivers and all the applications and it can also be expensive if you pay some professional support. What if I tell you that for Vaio PC’s this operations is made with some few clicks? No disks, no flash usb memory, no other external devices … just few clicks.

Vaio PC’s has a tool called VAIO Recovery Center. This tool allows you to create backup points and restore your windows, to create hardware diagnostics, or you can have the possibility of reinstall programs or drivers, wipe and erase data, creating recovery disks or erase all data and restore your entire system to factory settings.

In this tutorial, I’ll show you how to restore your Vaio PC to it’s factory settings. In other words how to restore your computer to it’s original settings (in the exact state you bought it).

For that you have to:

1. Back-up all your data. Restoring to factory setting means to erase all data and reinstall Windows, drivers and preinstalled applications. If you have a single drive (C:) you have to backup your data to external drive or disks.

2. Start VAIO Recovery Center. Click on Start button and then click on All Programs. From the program list select “VAIO Recovery Center“.

3. Restore complete system menu. From the left menu of Vaio Recovery Center select “Restore complete system

4. Start button.

5. Select “Restore C: drive” and hit Next.

6. Read the information on this new window, select “I understand” and hit Start.

7. “Are you sure?” If you made backup for all your data and really want to restore your Vaio as it was when you bought it you have to make sure that have it plugged in to a stable source of energy and press YES.

8. So … next you should sit back and relax. Your computer will start showing the next messages
Shuting Down
Windows is loading files …
Restoring your operating system
Please wait a moment while Windows prepares to start for the first time…
Windows Vista setup: The initial setup may take up to 15 minutes. Do not turn off the computer. Click OK to continue the setup process and wait until the “Set up Windows screen appears”. Select OK

9. Take your time until your system install VAIO software

Finish to restart.

10. That’s all. Now, your VAIO has the original operating system, drivers and software. Now you have to configure your VAIO as you want.

 


大疆工程师教你如何成为一名机器人工程师

$
0
0

大疆工程师教你如何成为一名机器人工程师(上)

本文作者:金红 2016-09-08 23:00
导语:这篇文章里作者计划介绍一个电子工程、机械工程和计算机专业学生从大学一年级到研究生二年级的机器人学习计划,基本是其对自己过去学习方式的一个总结。

雷锋网(公众号:雷锋网)按:本文作者YY硕,来自大疆工程师。原文标题《机器人工程师学习计划》,全文篇幅较长,为了方便阅读,故分为三篇,此为上篇。

大疆工程师教你如何成为一名机器人工程师(上)

前言

很多朋友私信问我对机器人和人工智能感兴趣,该怎么展开学习。最近稍微有点空,我写写我的看法。

两年前,我在知乎回答如何定义「机器人」?的问题中试图给机器人做出一个比较仔细的定义,我觉得机器人和人工智能最大的区别在于是否要和物理世界进行交互。今年初在另一篇知乎“机器人或人工智能的研究会帮助我们更好的了解人类自己吗?”回答中,我说到传感器是和物理世界交互的基础。后来,我又在知乎“有哪些与控制、机器人等相关的 quotes?”的回答中提到莫拉维克悖论(Moravec’s paradox),谈到了机器人学里公认的难题是在物理世界中实现类人的活动能力。

把之前的回答再翻出来是为了支持以下观点:机器人学的核心问题是做好和物理世界的交互。现在主流的机器人学分支里,处理与物理世界的交互的学科分为三类:传感器和处理算法(激光雷达,多目视觉,融合算法);多刚体系统动力学控制(工业机器人动力学控制和接触力控制);机器人自主移动(locomotion不知道该怎么翻译,轮式、足式、飞行等移动机器人的研究)。我建议对机器人学有兴趣的同学着重在这几个问题上面。

另外,根据世界第一的机器人教育机构卡耐基梅隆大学的机器人学博士的课程分类方式(http://www.ri.cmu.edu/education/COSAug2016.pdf),机器人学有四个核心领域:

感知。视觉传感器、图像传感器、触觉和力传感器、惯导等。

认知。人工智能、知识表达、规划、任务调度、机器学习等。

行为。运动学、动力学、控制、manipulation和locomotion等。

数学基础。最优估计、微分几何、计算几何、运筹学等。

结合卡耐基梅隆大学的核心课程要求,我觉得我定义的机器人学核心问题算是基本没跑偏的。本文后面谈到的机器人项目都是以上述观点和课程要求为基础。

一些可能有争议性的观点:

1. 机器人学是富人的活动。虽然工业越来越发达,但好的开发板和电机还是非常贵。如果要下定决心学习机器人学并且做出实物,你必须找到做实物出来的资金。要么是自己花钱,要么就得找学校的机器人社团,或者找什么愿意资助年轻人学习的贵人。另外现在没有任何一本完整的书可以教你怎么造一个四旋翼空中机器人或者大狗机器人,你需要参考十几本不同的教科书,这些书不管中文版还是英文版都很贵。

2. 机器人学是屠龙之术。这话是Ninebot创始人说的。虽然最近几年,平衡车、扫地机器人、多旋翼飞行器让机器人学开始进入人们的生活,但是可行的商业应用还是很少,而且已有的机器人和理论都还很难解决好与物理世界交互这件事情。所以一定要确保自己在机器人学这个道路上同时练好了能去其他行当吃饭的技能,比如编程、机械设计和硬件设计。也要做好心理准备,接受自己有可能在学会屠龙之术以后几年都造不出对社会有用的东西的事实。

3. 基于上述所说的观点,如果是已经工作之后才想要学习机器人的话,可能已经太迟了,因为很可能兴趣战胜不了客观限制因素。如果作为兴趣去学习,只能学到做巡线小车和舵机机械臂什么的,可能也满足不了中二病的创造欲。

个人认为机器人学是一个艰苦的道路,想要成为一个独挡一面的机器人工程师需要多年理论和实践的同步训练。理论学习和动手实践的过程还要互相排好时间表,在做某个实践项目的同时去学习最相关理论往往可以达到事半功倍的效果,但是同时那些不太相关的理论会看起来非常枯燥,因此如何妥善安排自己的实践项目也是很重要的事情。

这篇文章里我计划介绍一个电子工程、机械工程和计算机专业学生从大学一年级到研究生二年级的机器人学习计划,基本是我对自己过去学习方式的一个总结。按照这个方法来学习,能够成为一个能力全面,但是稍微偏软件一点的机器人工程师。这个六年的学习计划,估算下来,全年中每天在上课和完成课程要求之外要投入学习时间6-8个小时,这些时间一方面用于阅读课程知识的英文教材,一方面用于阅读其他学科的教材,一方面用于实践项目。

机器人工程师在大型项目里的定位类似于飞机系统里的总体设计师。和机械工程师、硬件工程师、软件工程师、算法工程师、控制工程师比起来,机器人工程师参与某个具体技术的时间较少,但是能够听得懂所有工程师说的话,能够作为不同模块间的协调人,带领整个团队去攻坚。当然如果机器人工程师能够在一个领域达到那个领域的工程师的优秀水平,肯定更好。

由于时间仓促,再加上个人水平有限,文章中如有纰漏和错误,恭请读者指出,谢谢。如果同学还有什么想知道的内容和教材,也欢迎留言交流。

大一

刚上大一,你的机器人生涯开始了。先看看学校的校园网能不能翻墙,不能的话自己去买个一年一百多块钱的VPN,先确保自己能上Google,不要心疼VPN的钱,这能让你在之后的职业生涯里节省上万块钱。然后去注册一个gmail账号,再注册stackoverflow账号,再注册github的账号,再注册CSDN账号,注册完登录上去逛逛,暂时先不要问为什么。

英语水平一定程度上会是机器人工程师水平的限制因素,英语是同学们在大学最该努力学的一门课,而且不止要把它当成课,要当成一种技能,当成生活的一部分。当你开始努力学习一些高级的机器人知识以后,有可能会非常难以找到中文的参考资料,这个时候如果啃不下英文的资料,进步速度和眼界就会受到很大影响。因此大一的时候要多看看红宝书,看看美剧。

不管是什么专业背景的同学,大学一年级一定要上好的课是微积分和线性代数。线性代数的重要性需要特别强调。一般来说,优秀的工程师和科学家在职业生涯中要学至少五次线性代数,大一学一遍、学凸优化的时候学一遍、学线性系统的时候学一遍、学机器学习的时候学一遍……如果在第一遍学的时候就看到对的书,刷到对的题,那么以后的学习会轻松很多。

网上有很多对于如何学好线性代数的讨论,比如知乎问题如何理解线性代数?。Matrix67大神的文章随记:我们需要怎样的数学教育?也很有启发。我个人对学习线性代数的建议是两本书,一本叫做《Linear Algebra Done Right》,另一本叫做《Linear Algebra Done Wrong》,我比较喜欢的是Done Wrong这本书,第一它是免费的,第二只需要读前6章两百页就够了,第三它页边距很大,打印出来有很多空白做练习题。另外一个较好的教材是麻省理工公开课:线性代数。不论如何,学线性代数一定要用国外的教材,千万不要用国内的教材。啃英文书很累,但是考虑到之后还要啃更多的英文书,线性代数已经算是很入门的了,一定要啃下来,同时还要刷足够多的课后题。

学完线性代数以后,一个自然而然的问题就是怎么能用计算机自己去计算矩阵的乘法、向量的乘法、向量的内积。因此引入了编程的学习。

不管同学的专业是什么,一定要在大学一年级尽早开始学编程。至于用哪种语言开始学习编程,我推荐Python,比较好的教材是麻省理工学院公开课:计算机科学及编程导论,比较好的Python开发学习环境是Anacoda 。熟悉Python以后,同学就可以开始玩玩Python的数值计算包Numpy,这个时候线性代数题基本上也刷的差不多,可以通过Numpy帮助自己解决线性代数问题了。

对任何人来说,Python是一把瑞士军刀,你可以用他干很多东西,比如自动回复邮件、自动收集信息。但是真要去造机器人,合适的工具并不是瑞士军刀,而是C/C++这样简单粗暴的锤子和螺丝刀般的工具。在学习Python学到一定程度的时候(比如你听说有一种叫做cython的东西),最好开始学习C,而且要强迫自己练习用C的一维数组和指针来实现矩阵的加法、乘法、求逆等操作。之所以有高级的Python或者Java(不要问我Java哪里高级了)这些语言以后我们还需要去学C,是因为机器人上常用的不是完整的电脑,而是计算量有局限的嵌入式系统,嵌入式系统开发基本只能用C或者更低级的语言。

学习C我个人入门用的是清华大学出版的《C++语言程序设计》。虽然这个书标题是C++,但其实没什么太大问题。不过国内的C语言教材都有个巨大的问题是不引导学生去用Linux。近年来更好的一个教材是http://songjinshan.com/akabook/zh/index.html,这个网站的教材非常好,因为他教育学生用Linux环境作为程序编译的环境,而且还引入了一些计算机体系结构的介绍。

IT行业的程序员都会争论高级语言和低级语言哪个好,Linux和Windows哪个好,而对于机器人工程师来说,从现在到可预见的未来里,C是最好的语言,Linux是最好的操作系统,这都毋庸置疑。甚至对于Linux的发行版该选哪个,我们都是很少有质疑的:Ubuntu(The leading OS for PC, tablet, phone and cloud)。原因是机器人操作系统ROS(ROS.org | Powering the world’s robots)是基于Ubuntu开发的,因此在Ubuntu上运行最稳定。注意Ubuntu出了一个中文版叫做Kylin,个人感觉比较坑,建议大家不要装中文版。Ubuntu 作为一个开源操作系统,总是在快速迭代,2016年8月比较稳定的版本是14.04和16.04,建议同学安装14.04。

当你把C学得差不多,开始要学写包含多个头文件的程序时,一定要同时学习makefile的知识。这时候要上网去搜“Makefile详解”(Makefile详解(超级好)_mingw吧)这篇文章看。

我自己在大学一年级的时候还学习了HTML和Javascript,到大一结束的时候已经能够熟练用Javascript手写一些动态页面。我个人觉得HTML和Javascript也是机器人工程师必备的技术,而不只是软件工程师的玩具。这是因为web技术实际上已经渗透到了编程的方方面面,比如json开始是Javascript里的一种object定义的方式,但现在已经成为了一种很标准的数据交互、参数配置的格式。另外AJAX能够帮助初学者理解一定的网络技术原理,而网络技术也是机器人工程师必备的技能。再者,制作GUI(图形用户界面)是常规debug的办法,而近年来一个流行的趋势是用webkit嵌入程序用HTML和Javascript作为图形界面的后端,而在机器人操作系统ROS(ROS.org | Powering the world’s robots)里,通过rosbridge可以非常方便地把机器人程序的数据传递到websocket上,这句话看不懂没关系,反正你知道学学HTML和Javascript很重要就是了。更重要的是,HTML文档背后的DOM (Document Object Model)深刻地体现了面向对象的思想。大学中的面向对象程序设计一般都讲C++,在我看来应该讲HTML和Javascript。这一点不细说了,如果同学们去学习HTML和Javascript,自然会体会到。学习HTML和Javascript比较好的资料是http://www.w3schools.com/,把网站左侧的“Learn HTML”、“Learn CSS”、“Learn Javascript”和“Learn JQuery”学完就行,别的部分还有很多花哨的技术,没有必要去学了。为了培养自己对Javascript的兴趣,可以上three.js / examples跪着看看热闹。

以上介绍的这些知识点、书和资料应该在大一期间就全部看完,然后利用大一的暑假好好巩固这些知识。比如开始用HTML和Javascript做一个自己的个人主页,刷一刷编程的题目,学用Python的奇技淫巧(比方说做一个自己的个人主页)。另外还可以抽时间学学数学知识,比如开始看看代数和离散数学。我大一的时候看到了两篇文章,认识到了数学的重要性,一篇是MIT的CV大牛林达华写的[转]MIT牛人解说数学体系,另一篇是前Goolge研究员吴军博士写的《数学之美》。当时林达华还在MIT读博士,而《数学之美》还没有成书。两篇文章看完以后我感觉自己整个人对数学的认识上了一个新的层次,此后一直在注意提高自己的数学水平,几年下来觉得收益很大。在之后的介绍里我还会多次强调需要学的数学知识和对应的教材。

大二

上大二的时候,你已经会了基本的编程知识和基本的数学知识。大二这一年应该投入在嵌入式系统的学习中,同时继续拓展自己多方面的能力。学校的机器人社团,比如做Robocon,RoboMasters的团队应该在招新了,赶快去加入,有了学长学姐的指导以及同辈朋友的鞭策,应该会进步的快一点。

大二应该掌握的技能:Solidworks画基本的机械图,基本的数字电路知识、数模转换,51单片机、AVR单片机、STM32单片机原理,UART、SPI、I2C、CAN等协议的原理和数据收发,STM32开发板的使用,电机转动和驱动的原理,PID的原理,调试四轮机器人底盘的移动,基本的传感器如陀螺仪、码盘、红外线、超声波的原理和读取方式,网络知识如配置IP配置路由器等,微电子焊接,金工技术。我在知乎回答如果程序员每天都浅尝辄止地学一些不同的新技术,长久以往,人会变成什么样子呢?里谈过机器人工程师需要的技能数量是IT行业全栈工程师技能数量的三倍以上,这些技能的基础都应该在大二开始积累。

如果同学们的专业是机械工程相关,那么大二的时候要深入学习solidworks做图,买机械加工手册学习各种机械的奇技淫巧。你的专业知识还不足以让你进行缜密的受力分析,不过你可以尽量多做一些机械结构出来感受它们的乐趣。

如果同学们的专业是硬件、电路相关,那么大二的时候要深入学习Altium Designer做图、制板、焊板。你要从现在开始,就给自己积累一个工作记录,可以就是简单的txt文件,记录你做过所有板子的bug、解决方案、学到的原理图、PCB layout的注意事项等等。积累很多年以后,你的这个工作记录会值很多钱。

学习这些技能的最好的方式,就是参加自己学校机器人社团的训练和方案设计。一般来说,学校的机器人社团招新之后会有训练和测试,让新人分组去做机器人,这个过程中如果愿意努力学,提高得会很快。如果你所在的大学是机器人比赛强校,比如西安交通大学,电子科技大学,哈尔滨工业大学,华中科技大学,东北大学等等(排名不分先后,没有提到你们学校名字的话我表示抱歉),那么你很幸运,你们学校的机器人社团有很好的积淀,有很多资源可以帮助你学习。基本上只要天天泡实验室,保证自己每天只睡6-7个小时(但还是要多去跑步、游泳保持身体健康),勤于向学长学姐请教,那么一定会提高得很快。

大二阶段特别要强调的是对动手能力的培养,包括机械材料的加工、电路焊接、制作导线和接头、连接路由器、配置网络、做网线等等。机械加工的工具有螺丝刀、锯、钻、锤子、车床、铣床、钻床,进阶选手可以学一下氧焊,这个比较危险,我没尝试过;电路焊接的工具有焊机、焊锡、洗板水、松香、吸锡器;制作导线的工具有剪子、剥线钳、夹头钳、网线钳各种钳;网络配置就是连连路由器插插网线,但是Linux系统下配置网络有时会非常麻烦,一定要多积累这方面的知识,因为将来你造的机器人多半会顶着一个无线路由器跑来跑去,甚至有的机器人上各个模块自己就能组起一个小局域网。这些技能的熟练掌握需要你花很多时间去做真正能用的机器人来练手。

对于该选择造一个怎么样的“真正能用的机器人”练手,最好的选择肯定是机器人比赛中的机器人。如果参加Robocon,你会跟着学长学姐们学着造有人那么高的巨大机械;如果参加RoboMasters,你会学着造比汽车还要灵活的机器人以及快速发弹的机构。其他一些小型的比赛比如飞思卡尔智能车,也是很好的训练,因为飞思卡尔智能车已经发展得很成熟,参加这个比赛的参赛资料就够学一阵子的,学完以后能够获得比较多的机器人技能。

如果没有太多学校机器人社团的资源,同学们还有一些小型的比赛比如挑战杯、大创比赛等等可以选择,以三五个人的小团队参与这些比赛。如果同学所在的学校连这些比赛都不组织大家参与,那就只好自己花钱了。国内开源机器人社区有很多资源可以利用来学习,比如自己买Arduino STEM educational Robot kits Building Platform的各种开发套件做简单的机器人。Arduino的开发环境可能有些人不喜欢,因为它对硬件做了一级封装,如果更希望接触到单片机的本质,可以自己买STM32开发板学习。俗话说,没有什么嵌入式系统是一块STM32实现不了的,如果有,就用两块。STM32是ARM Cortex‑M家族中最为广泛应用的一款单片机,在网上也有很多的教材和开发板可供选择。在国内著名的电子论坛STM32/8 分论坛帖子清单 (amoBBS 阿莫电子论坛)上,有很多参考资料,有问题也可以在这里和大家讨论学习。

如果你很想参加机器人比赛,身边也恰好有一些志同道合的小伙伴,但是学校不支持。没关系,来找我,我尽量通过大疆的关系说服你们学校支持你们参加RoboMasters。

大疆工程师教你如何成为一名机器人工程师(上)

编者注:RoboMasters为大疆主办的全国大学生机器人竞技类比赛,第二届已于8月28日落下帷幕,电子科技大学的One Point Five S战队从32支总决赛参赛队中脱颖而出,摘得桂冠,成功卫冕全国总冠军。

虽然你是以机器人比赛为主线在探索机器人技术,但是要时刻记得,机器人比赛给你的理论方面的训练很差,还会让你养成一些坏习惯,比如凡事都希望用一些糙猛快的办法来解决。由于通常整个团队都没有太多的项目管理经验,到比赛前一段时间才会加紧功夫去做机器人,很多时候就会用“山寨”的办法去处理机器人的故障。比如说某个承重结构用久了会弯,为了赶比赛的进度,就拿锤子敲直了、再加一条辅助的结构在旁边继续用,而没有细致地去做建模、受力分析,思考是什么原因导致承重结构会变形。再比如说调PID参数就是生调乱改,而没有基于机器人的动力学模型去估测参数的大概范围。

大二的暑假,有可能你跟着学校的机器人队参加了一些机器人比赛。这是一个反思总结的好时机,为什么机器人队取得了这样那样的成绩?整个团队怎样才能更有效率?明年如何继续招新?暑假要把时间花在技术积累上面,这个时候可以回头思考思考之前准备比赛时用糙猛快的办法解决的问题如何能够细致地去解决。

如果大二的暑假没有参加机器人比赛,可以做一个舵机机器人,比如6条腿的蜘蛛,比如码垛机器人。舵机是机器人工程师的好朋友,一定要好好掌握。

另外你其他方面的能力也不能落下。大二结束的时候,你的Linux应该用的很熟练了,除了makefile,你也用起了cmake。你也应该开始理解Github存在的意义,因为你已经上去读了很多别人的代码,你也把自己的一些课程设计和小项目放在了Github上面。另外大二基本上了本专业一些比较难的基础课程,比如自动控制原理、机器学习、概率统计、材料和力学等课程,同学们会看到这些课程里又用到了线性代数和微积分的知识,以及建模的知识。这时候可以把大一的物理、线性代数和微积分再翻出来看看。

同学的学校应该给大二到大三的学生有开设面向对象的程序设计,一般用Java或C++教授。在面向对象的程序课里面,一定要积累3000行左右的代码的开发经验。经典的面向对象程序设计的练习通常是写游戏,比如俄罗斯方块,吃豆人等等,一定要自己能够做到完全手写一个完整的项目出来。

另外你可以开始学习Matlab当中的神器Simulink了。在大二这一年的学习中,你可能在不少课程里多多少少用到了Matlab。假设你已经在我的推荐下喜欢上了Python,你可能会觉得Matlab的计算工具没有比Python强多少;假设你自己在别人的推荐下喜欢上了mathematica(Mathematica 到底有多厉害? – Wolfram Mathematica),你可能会觉得和Mathematica这种神一样的语言比起来,Matlab弱爆了。但是要注意的是,Matlab最强大的工具是Simulink,通过它你几乎可以仿真一切的物理系统和控制系统。我建议同学可以通过Simulink实现一个倒立摆,然后理解Matlab的强大之处。对此我强烈推荐一个很好的教材(http://ctms.engin.umich.edu/CTMS/index.php?example=Introduction§ion=SimulinkControl),它详细介绍了一些经典的控制系统如何分析以及用Simulink实现。然后我再强烈推荐一个讲Simulink里面一个更加和物理仿真贴近的工具Simscape(Control of an Inverted Pendulum on a Cart)的文章。阅读并实现了这两篇文章里的内容,同学应该会对倒立摆有了比较深刻的认识。倒立摆是机器人学中一个非常重要的模型,因为火箭、导弹、双足机器人、四足机器人,基本都是倒立摆的变形。你自己实现出来的simulink模型一定要存好,以后可能还会再拿出来仔细看。

如果你按照我之前说的方法探索了一些HTML和Javascript的技术,那么JQuery,bootstrap,AngularJS你已经多多少少知道是怎么回事了。web后端的技术,比如PHP和MySQL,也可以了解一下,LAMP要学会怎么配置。如果有同学找你帮忙写小网站,尽量去帮个忙,帮别人做网站是提高自己系统编程能力的好练习。在做网站的过程中你可能还会顺便学一学如何用Photoshop和Illustrator让网站显得更漂亮。这些技能有最好,没空学也没关系。

大疆工程师教你如何成为一名机器人工程师(中)

本文作者:金红 2016-09-08 23:32
导语:大三大三开始的时候,你可以在学校的机器人队里担任重要角色了,或者能够带领一个小团队参加小型的机器人比赛。

雷锋网(公众号:雷锋网)按:本文作者YY硕,来自大疆工程师。原文标题《机器人工程师学习计划》,全文篇幅较长,为了方便阅读,故分为三篇,此为中篇。

大三

大三开始的时候,你可以在学校的机器人队里担任重要角色了,或者能够带领一个小团队参加小型的机器人比赛。你在系里甚至院里都小有名气了,可能有的人叫你大神,有的人觉得你技术还不错。但是一定要记得你现在的水平放到别的地方应该不算什么。每年我都往大疆的RoboMasters夏令营招进100个和你现在的水平相当的同学。

大疆工程师教你如何成为一名机器人工程师(中)

编者注:RoboMasters夏令营是大疆为理工科学生和机器人爱好者量身打造的暑期科研活动,从2013年开始举办。通过自主报名的形式召集百余名各大高校的学生,在大疆总部进行一个月的项目训练,由香港科技大学的教授以及行业行业精英进行指导并分组,最后各组之间将自己的研究成果进行验证。

大三一定要培养出自己一个人独立造出一个完整机器人的能力,比如一个Robocon水平的机器人,或者一个RoboMasters的战车,或者一个四旋翼飞行器。

Robocon水平的机器人,涉及大量的机械设计,单片机开发,电机驱动的开发,码盘和超声波等传感器的读取,底盘运动学的计算,PID调试,任务调度逻辑的调试,舵机控制。RoboMasters的战车的机械部分简单一些,但是还需要进行云台的控制、发弹系统的控制、功率控制等方面的知识,另外你也可以不搞这些部分,学习学习视觉识别和自动打击,那么就要开始研究OpenCV了。

四旋翼飞行器的机械部分最简单,但是算法比较复杂。对于大三学生来说,从零开始一步到位写一个稳定的飞控比较困难,因为飞控里面有很多细小的知识点要注意。目前我没有发现什么比较好的书籍推荐,已有的一些关于四旋翼系统的书要么太浅(上来就教你焊电路),要么太深(上来就教你state estimation),听说 @Liu Top的exbot小组在写一个教材,我是非常期待的。学习四旋翼飞行器有下面几个步骤:

第一步:自己调一个小四轴飞起来

现在开源社区的人言必pixhawk,其实我觉得从学习的角度来说,pixhawk太贵,而且不适合学习,我比较推荐的是第七实验室这家淘宝店卖的STM32F405飞控,买回来以后自己再随便买个机架(比如大疆F450)、接收机和遥控,就能按照飞控板附带的学习资料、调试软件飞起来。

第二步:看硬件图、读代码

chiplab7的飞控板附带一大堆学习资料,对加速度计、陀螺和磁感计都有很仔细的解释,硬件链路图也很详细。chiplab7淘宝掌柜的又很认真负责,我学用的时候,发现代码有bug和看不懂的地方,都可以直接找掌柜问。

看完代码以后,对一个飞控系统的基本模块:姿态解算、控制解算、混控输出、遥控器处理、嵌入式处理就很明白了。然而这里面有很多技术是需要另外学习的。除了基本的嵌入式编程以外,还有要把大二大三学的信号处理方面的知识再捡起来看看。因为飞行器在空中有振动,会让加速度计产生噪声,为了把这些噪声去除掉,需要对加速度计给出的信号做低通滤波处理,如何选择滤波器的参数呢?如果滤波滤得太狠,延迟就会比较大,对控制的表现会有影响;如果滤波滤得不够,可能会有一些低频的噪声偶尔会出现,导致加速度计的观测不能用。另外最重要的是要理解姿态解算和控制解算这两块知识。chiplab7的飞控板的代码采用的是最简单的互补滤波算法做为姿态解算模块,然后控制解算是对欧拉角的三个角度做闭环PID控制,基本都是基础的基础了。

第三步:小修小改加深理解

chiplab7的飞控是靠气压计定高的,飞行效果非常奔放。这时候可以淘宝买个20块钱的超声波模块,然后自己写个高度环去稳定飞控的定高表现。

我觉得这个过程至关重要,因为高度控制相对来说是个比较直观理解PID控制的方式,而且chiplab7的飞控加高度控制非常好加。工作量不大,因为改善效果很显著,所以可以让人很有成就感,加深继续学习的乐趣。

第四步:理解核心的数学和控制知识

这一部分大三是肯定来不及学的,但是我还是在这里列出来,因为这些知识你之后都需要慢慢学,我也会在之后不断重复提到这些知识点。

姿态解算和控制解算涉及的知识有:

1. 刚体姿态的表示、运动学方程和动力学方程。主要是对牛顿-欧拉方程的认识和理解、刚体姿态的欧拉角表示法、姿态与角速度的关系等等。

这部分说复杂不复杂,说简单也不简单,我同样是没有找到一本完整的书全都介绍过的,是学了好几个不同的书和论文以后搞明白的。现在看起来是从维基百科入手比较靠谱。

2. 自动控制原理。讲PID的书和文章就多了去了,没有太多复杂的书。

3. 线性估计基本原理。其实就是互补滤波:Reading a IMU Without Kalman: The Complementary Filter 。拿这个关键词百度各种搜就会了。

第五步:重头开始造轮子

知乎著名网友vczh曾经说过,学习要抱着勇于造轮子的心态才能进步。所以在熟悉了别人飞控基础上,可以自己重头造一个飞控的轮子。可以自己从芯片开始重新画一个飞控板,读读STM32的芯片手册、读读各种传感器的芯片手册,自己手画一个飞控的原理图、做PCB layout、制板自己焊元件,全套花不了1000块钱,能够加深很多对硬件的理解。这一部分如果大三没空,也可以不搞了。

制造整个机器人的过程中要特别重视文档的积累。在你大三末期,你可能随着学校的机器人队备战比赛,你可能主力负责一台机器人。你应该自己列一个excel表格,把机器人用了几颗螺丝,几根导线,每个零件的规格是什么,都列出来。这个表格一方面可以用来帮助团队管理机器人的物料,一方面也是你自己的经验技术积累,将来你做的其他机器人可能多多少少都是Robocon、RoboMasters机器人的变形。

另一个积累是建一个自己的buglist,buglist包括什么呢,可以像冷大这样,在“做控制、机器人等算法工程师是怎样一种体验?”的回答中,就简单把一些自己的发生过的问题和最后的解决办法罗列下来。比如说“杜邦线接插位不稳固容易脱开,接好后应该用电工胶布再裹一圈”,“外发给淘宝加工的机械图纸,要特别注意和加工商沟通有没有漏掉一些细节,如沉头螺丝孔,关键的倒角”等等。你也可以把其他机器人的问题也做这样的记录。buglist可以就是一个简单的文本文件,如果你一直往里面积累自己工作中的记录,等你将来工作了,这个文件可能会值很多钱。

大三的时候学校应该会开设软件工程的课程。不管你是不是这个专业,上不上这门课,都应该主动去听一听,甚至跟着课程的设计作业一起做一做。软件工程我觉得是机器人工程师必须具备的意识,因为一个机器人系统里涉及大量的硬件系统和软件功能,软件的部分往往还会涉及不同的语言、不同的编译环境、不同的开发工具链。几个人合作的话,大家的专业背景、编程习惯都不相同,这就导致不同的代码和模块之间的协议沟通非常复杂,必须尽早用UML和其他软件工程的工具帮助团队理解和互相沟通。

大三的时候学校应该还会开设操作系统原理和嵌入式系统原理的课程,而大二的时候讲过计算机组成原理(所谓的微机原理)。从大三开始同学需要开始体会实时操作系统和非实时操作系统的区别、原理以及使用时需要注意的地方。这是一个比较杂的知识点,我目前没有找到很好的教材去介绍。在STM32上,有freeRTOS,uCOS,Vxworks这么几种实时操作系统;Linux是一种非实时操作系统,但是可以通过打补丁变成实时操作系统。这些操作系统的细节在机器人开发中都会多多少少被涉及到,同学们可以随时上Google和CSDN去查大神们的介绍。

另外特别重要的一点是机器人系统里的嵌入式平台都有烧坏的可能性,有可能在某个嵌入式Linux平台上面辛辛苦苦写了一个多月代码,这个平台突然烧坏了,代码也就丢了。因此你的机器人如果有嵌入式Linux系统在里面,一定要尽早顶起来路由器,代码定时提交SVN或者git。

大三的暑假你可能会作为学校机器人队的主力去参赛了。备战比赛和参赛是一件磨练心性的事情。我在学生时代体会过和胜利擦肩而过的痛苦,体会过没机会再来一年的遗憾;也在负责大疆RoboMasters比赛的过程中被那些痛苦和遗憾的学生当做发泄的对象,非常有感触。我觉得参加机器人比赛,很努力,然后失败了,是一件让人快速成长的事情。同学如果有机会,一定应该参加至少一届机器人比赛。

大三的暑假你也可以选择来参加大疆的RoboMasters夏令营,关于夏令营大家可以看这个知乎问答了解更多:参加Robomasters 2016夏令营是怎样一种体验? 。每年我们都在全国范围内寻找有一定技术基础的学生,让他们一起分组做一个自动机器人的挑战。这个夏令营,作为组织负责人,不谦虚地说,我觉得应该是全世界范围内最好的技术类夏令营。

大疆工程师教你如何成为一名机器人工程师(中)

编者注:今年的RoboMasters夏令营比拼对于机器视觉技术的理解,挑战机器人自动飞行、自动取物、自动投掷技术。图为挑战机器人抓取娃娃并准备投入相应颜色框中,此过程机器人为全自动运行,机器人需要通过视觉识别娃娃的颜色与框的颜色。

大三的暑假有一件很重要的事情就是思考自己大四应该干什么。一般来说,你现在的能力保本校研究生肯定没有问题,当然你也可以选择考其他学校的研究生或者出国留学。虽然说你现在能力已经很全面了,但是你还需要2-3年的时间全面提升自己更多的能力,才能迈向卓越之路。不管是出国还是保研,最重要的目的是给自己争取到未来2-3年能够在一个优秀的环境中安心提升自己,有比较好的学习资源,能够参与到一些不错的项目中去。可能其他有些行当,出国留学始终是比在国内待着更好的选择,但是机器人行业并不是这样。我们国家这两年在机器人方面提高也很快,而且我们国家现在比较有钱。就像我开始说的那样,机器人是富人的活动,现在你在国内也能找到一些很有钱的实验室可以造比较牛逼的机器人。另外国外很多比较强的机器人公司也都在做比较敏感的军方项目,去找实习可能比较受限制。

出国去学机器人学方面的知识你有很多不错的选择,比如世界第一的机器人研究院卡耐基梅隆大学,或者麻省理工学院的CSAIL实验室。北美传统计算机四大名校(麻省理工学院,卡耐基梅隆大学,斯坦福大学,加州大学伯克利分校)里,除了斯坦福大学热火朝天在搞人工智能以外,其他几个学校的机器人研究都很不错。除了四大名校,你还有很多其他的选择,就像我开始说的那样,机器人是富人的活动,如果想接触到最好的机器人资源,你要选择有钱的实验室,而不是有名的实验室。

另外你还需要在大三的尾巴上选定自己将来的细分研究方向,而且开始往这个方向深挖,也就是我在文章开始提到的感知、认知、行为几个方向。当然同时你也不能放松其他方面的知识,尤其是数学基础。我在大三的暑假专门找数学系的同学给我开了个数学小讲座,学习了一点抽象代数的知识,对我后来学习密码学帮助很大。同时我也读了一些拓扑方面的教材(有一本很神奇的书叫做Topopogy Without Tears ),这样才理解了为什么数学分析要用奇怪的符号去解释一些看起来很浅显的道理。

大三阶段的机器人工程师该学什么基础数学是众说纷纭的,在我看来,你要基本掌握“群是什么”,能够用代数的眼光去证明”det(AB) = det(A)det(B)”,还要能理解“用一张纸就可以变出克莱因瓶”(当然是在四维空间里)。另外,你这个时候也要能够意识到自己需要再学一遍线性代数。

大四

大四开始了,你可以开始深挖自己的研究方向,同时也要开始学一些高级一点的通用技术和理论,这时候你和一般的机械、电子、计算机学生就不太一样了,你虽然也在狂编程,但也在狂学习物理和数学。通用技术包括ROS,simulink,gazebo和Vrep等工具。通用理论包括,再学一遍线性代数,学学凸优化、数值计算、旋转表示法等方面的知识。这些知识你在大四仅仅只能开一个头,因为你的大四要实习、毕业、考研、毕设,你会非常地忙。有些人会在大四进实验室和老师发论文,我个人觉得发论文这件事没必要操之过急。你的整个大学期间应该用在广泛涉猎各种各样的知识上面,而不是深入某一个细小的研究问题。

大四可以开始读一些著名入门书籍,我把这些书不分先后地列出来,你没有必要全部去读,而且每本书先读前几章就够了,能读多少尽量读多少。

1. 概率机器人学

2. 凸优化

3. 线性系统理论

4. Multiple View Geometry in Computer Vision

5. 线性估计

6. 《机器学习》,周志华老师的书。

7. An Invitation to 3-D Vision

8. Modern Control Systems

9. Rigid Body Dynamics。说实话刚体动力学理论我没有找到特别好的书,但是刚体动力学理论很重要。

10. Feedback Systems: An Introduction for Scientists and Engineers

就像我开始说的那样,这些书,大部分特别贵,还好有一些业界良心的作者放出了他们书的电子版。当然你也可以去一些名字都不能说的网站去找影印版。

在读上面这些书的时候,matlab,python都要放在手边,然后把书里面的知识尽量实践出来。很多教科书里都会在章节后面的习题里放一些写明是用matlab做的习题,要尽量多做一些这样的题。

你可能早就听说了ROS的大名,但是最好不要在大四之前去碰它。因为ROS用了很多操作系统和网络的底层技术。我在知乎回答“高手可以谈谈ROS机器人操作平台开发的一些经验吗?”里有简单的介绍。ROS的设计目标是把机器人的控制和传感器处理的软件和它的硬件隔离开,用上ROS以后,你可以方便地用到很多能直接跑的软件代码。但是ROS从入门到精通需要至少一年以上的时间,你必须不断地用,不断地尝试新的代码和硬件,才能对它熟悉起来。

ROS的可视化工具Rviz里面对于机器人旋转的表示用的是四元数,而在你之前研究四旋翼飞行器时,里面的代码表示旋转用的是欧拉角,做姿态解算用的可能是四元数。这个时候要开始有意识地去学习旋转表示法之间的区别和联系。

要重视大四期间的实习和毕业设计。很多大四的学生毕业设计都会非常颓地做一下,我觉得是不好的。要把做毕业设计的过程看做一个正式的项目。这个项目除了做好技术方面的工作,也要做好展示方面的工作。中国工程师的一大特点是,不会表达自己,可能做的东西水平很高,但是做出PPT就会犯字体花哨不正式、一页上面字太多,图文没有联系等表达上的问题。通过PPT介绍、展示自己的成果在工程师的职业生涯的任何一个阶段都非常重要,它甚至也一定程度上限制了机器人工程师能够达到的高度。只有能够把自己的成果清晰地表达给自己的团队,才能获得其他人的反馈、通过沟通提高团队的整体凝聚力和知识水平,这样自己在团队能够获得更多的认可,有助于团队整体工作效率的提高。我每年去参加几次学术会议,都在会议上感觉到一些中国的科研人员走到国际上以后,演讲能力很差就会导致他们的科研成果不受重视。当然其他国家的科研人员也是这样。

为了写出美观的技术报告和毕业论文,你可以开始学习Latex。Latex作为国际国内第一写作神器,学习资料在网上有很多。Latex的学习和使用同样也是需要不断地熟能生巧,多写多练就熟悉了。写毕业论文有个问题是怎么做出精美的矢量图,我推荐Draw Freely | Inkscape,一个比Illustrator更轻量化、但是有些功能反而更强大的免费软件。

对于那些想申请出国留学的同学,你要做一个自己个人的成果展示,用网页的形式呈现比较好。把自己Github链接(如果你按我说的,大学第一天就申请Github账号,现在已经是一个三年的老油条了)、做过的机器人视频、写过的技术报告和文章(最好是英文的)放在上面。

关于毕业设计的选题,我推荐这么几个:

1. 手写双目视觉里程计。涉及到图像处理、特征匹配、位置解算、空间变换等等。

2. 手写四旋翼飞行器基于GPS的轨迹规划。涉及到深挖四旋翼飞行器的运动原理、IMU原理、轨迹生成和优化等。

3. 造一个被推了也不会倒的双足舵机机器人。涉及到舵机控制、倒立摆建模、动力学分析、PID控制、IMU原理等。

4. 深度学习训练一个小车追人跑。涉及到深度学习工具包使用、数据集采集、数据集分析、小车控制等。

5. 机械臂给人端茶倒水。这个相对来说土豪一点,因为能直接拿来用的机械臂都很贵,这个要看实验室有没有条件了。涉及到多自由度机械臂原理的学习、工具包的使用、轨迹规划等等。

这几个项目要做好,都要持续投入三个月以上的时间以及一定的资金,每一个都是理论多于实践。当然同学们自己也可以自己选择自己的毕业设计题目,但是最好还是选做出来能跑能飞的东西,同时避免选择需要花大量时间去拧螺丝、焊板子的题目,尽量买现成的电机、开发板、3D打印结构,大四要多给自己留时间去看书和写代码。

大四到研究生之前的暑假,最好去一些比较不错的机器人公司实习一下,比如说大疆。当然你也可以继续做机器人比赛,比如RoboMasters和大疆的飞行器比赛。

大疆工程师教你如何成为一名机器人工程师(下)

本文作者:金红 2016-09-09 00:08
导语:研究生的时候,你的目标比较清晰了,就是做一种机器人至少两年时间,并从中发掘出可以发表论文的知识点。

雷锋网(公众号:雷锋网)按:本文作者YY硕,来自大疆工程师。原文标题《机器人工程师学习计划》,全文篇幅较长,为了方便阅读,故分为三篇,此为下篇。

研究生一年级

研究生的时候,你的目标比较清晰了,就是做一种机器人至少两年时间,并从中发掘出可以发表论文的知识点。上面我给出的书单里面,你要开始精读里面的几本。

如果做机器人视觉定位、传感器融合方面的研究,1、4、5、7四本书一定要精读。

如果做控制系统的研究,3、8、9、10一定要精读。

如果做规划算法的研究,那么还要读其他偏CS一些的书,比如讲A* search,random forest,图论方面知识的教材。由于我在这方面造诣不深,就不托大了。

如果学习随机系统的控制和最优控制,除了1、2、3,还要读一本神书Stochastic models estimation and control

如果研究机器人视觉定位,几种常用的定位算法:PTAM,ROS的标配VOSVOLSD-SLAMORB-SLAM,都必须自己学习之后全部跑一遍。只会用OpenCV的函数和这些工具包并不能说明你会视觉定位,必须要能自己手写出一个能用的才算。国内有一个很厉害的SLAM专家叫高翔,他的博客要关注一下:机器人 – 标签。由于SLAM这两年很火,研究的人很多,所以网上可以参考的资料也很多,比如https://github.com/hcdth011/ROS-Hydro-SLAM,就在ROS上实现了几种定位算法的对比。

我现在非常不建议同学们选择从四旋翼飞行器的动力学控制里找问题作为研究课题。因为四旋翼飞行器的特点已经被研究透了。目前国际上对多旋翼飞行器的研究主要集中在造一些奇葩形状的飞行器,以及给多旋翼飞行器上安装一个机械臂去做力控制,这样做就对多旋翼飞行器控制的动力学造成了一些影响。因此需要同学对动力学和多自由度机械臂控制有比较深的认识。

自动导航和驾驶是这两年的热点,一方面汽车的自动化是大势所趋,另一方面多旋翼飞行器异军突起,产生了很多对自动飞行的需求。除了机器人视觉定位算法以外,同学还需要学习其他的传感器,以及这些传感器与视觉定位算法怎么融合。这里面有很多坑,比如计算量的问题,怎么保证融合算法不崩,怎么处理传感器的延时等等,都需要同学结合自己的项目去踩,坑踩得多了才能成长。如果大家想找一个多旋翼飞行器平台研究自动导航,我推荐大疆的M100,我已经在知乎回答“RoboMasters2015夏令营是怎样的?” 里吹过一波M100,前面说过的今年夏令营的知乎回答“参加Robomasters 2016夏令营是怎样一种体验? ”里也有人帮我吹了一波。

一些大学里学过的知识点,是必须结合研究生期间的项目的需求弄得很清楚的,比如三大变换(傅里叶变换,拉普拉斯变换,Z变换),旋转表示法(欧拉角、四元数、旋转矩阵),数值计算怎么防止矩阵出现数值问题等等。除了自己的项目,还需要把凸优化、微分方程、卡尔曼滤波还有多自由度机械臂的控制学习一下。这三个领域的知识,是任何一种机器人都会用的到比较难的知识。

凸优化和凸优化的各种变形是非常重要的知识,因为各行各业里的研究问题,多半是会建立一个优化问题去解决的。上面提到的《Convex Optimization》,也是一本神书,同学们一定要认真读一读。Matlab、Python、C++都有一些现成的工具包可以帮助你解优化问题,不过最好同学们能自己手写一些基本的优化算法,比如gradient descend,barrier method等等。另外现在主流的SLAM算法,后端都是通过一种叫做g2o的优化算法来出效果的。而且g2o能够整合bundle adjustment 和structure-from-motion这两大计算机视觉里的关键问题,可以说是一种很好的计算思想了,非常有必要学习一下g2o。

卡尔曼滤波在上面书单里的1和3都有提到,同时在神书Stochastic models estimation and control也有相当多的篇幅。卡尔曼滤波有好几种证明的方法,同学最好能自己学会1-2种。

多自由度的机械臂的难点在于机械臂的运动学正反解、运动学控制和动力学控制,基本是一个建模分析和数值算法实现的问题。如果你所在的学校没有一个财力雄厚的机器人实验室的话,你基本上没有机会接触到多自由度的机械臂。这时候之前学到的Simulink和就要学的Gazebo就派上用场了,你可以用Simscape里面的刚体搭一个多自由度机械臂,然后通过Simulink仿真去学习机械臂的控制;也可以用Gazebo的URDF语言写一个机械臂,然后通过Gazebo和ROS的接口去控制机械臂;也可以用ROS里面的著名工具包MoveIt! Motion Planning Framework,不过MoveIt的问题是,他只能仿真运动学,而不能仿真动力学。工业领域对多自由度的机械臂控制通常用一个叫做D-H表示法的建模工具(Denavit),这个东西我并不太会。我只会向同学们推荐我导师的著作《A mathematical introduction to robotic manipulation》。

有一个非常神奇的事实:《A mathematical introduction to robotic manipulation》这本机械臂控制领域的著名教材的第二章和计算机视觉领域的著名教材《An Invitation to 3-D Vision》的第二章基本是一样的,都在讲旋转表示法。这是因为所有的旋转表示法都可以归纳为一种优雅的李群结构:SO(3)群。而计算机视觉和机械臂控制都涉及到理解刚体的旋转,事实上用计算系统去观测和控制所有的刚体构成的系统,理解旋转都是很关键的问题。旋转表示法应该作为研究生阶段的一个重要学习的知识点。

李群和李代数是刚体旋转表示背后的数学理论,如果想要深挖一些,可以看这篇文章An elementary introduction to groups and representations的前50页。这是我自己读着觉得最好的文章,当然网上也有很多其他的介绍。

研究生阶段还要培养的一个能力是借助各种工具仿真机器人系统的能力。显然地,很多机器人系统真的造出来的话造价昂贵,需要在实际制造之前写一个比较真实的仿真系统出来测试算法。我觉得做仿真系统的能力直接衡量了机器人工程师的技术水平。当你开始要搭一个仿真系统的时候,第一步是通过欧拉方程和牛顿方程确定刚体的运动特点,甚至要自己写刚体二阶微分方程;第二步是确定刚体之间的互联关系,设计不同类型的关节,如果有软性连接需要加入弹簧阻尼模型;第三步是确定被仿真的刚体系统会不会和外界产生碰撞或者其他形式的力,如果有的话,需要设计合适的接触力和摩擦力仿真的模型。多旋翼飞行器的仿真是很简单的,不需要考虑什么接触力。但是多自由度机械臂基本都需要仿真接触力,不和物理世界去交互的机械臂只有很小的实用意义。而能够自行运动locomotion系统,比如双足、多足机器人,则涉及到更多的接触力,多到接触力都会影响仿真系统的数值稳定性。搭建一个仿真系统需要很强的系统建模能力和数值分析的能力,虽然Simulink、Gazebo、Vrep提供了不同程度的工具简化你的工作,但是要让仿真系统能够稳定运行,必须要能深入其中的细节。有些看起来很高大上的仿真工具,比如Nvida的PhysX,在仿真的时候是忽略掉科里奥利力的,如果不理解仿真的本质,可能就会忽略这一个重要的缺陷。

研究生二年级

你的学习计划接近尾声。现在你已经进入了一个很好的状态:看到一个机器人,能够很果断地分析出它用了什么传感器、执行器、计算平台大概是什么量级,他的执行机构能够承受多少力量。看到一个新的算法,能够大约判断清楚它的执行流程,在什么环节做了优化。看到一个新的没学过的知识,能够分析出它和你以前学过的什么知识有联系,你还需要再学什么才能弄明白这个知识点。

研究生二年级要深化第一年学到的那些技术和知识,要做到完整地读过四五本书,五十篇以上的论文。你已经积累了几万行代码的经验,也能熟练地谈论谁家的电机回差小,谁家的电机线性程度好。

你这个时候可以去写作一些论文,也可以开始学习一些更高级的技术和工具,比如用FPGA和GPU优化算法、魔改Linux内核、玩玩液压系统、了解更多机器学习的知识比如强化学习等等。你也可以从计算机图形学或者计算力学里面找到一些帮助你更好进行机器人仿真和系统分析的工具。由于你懂很多机器人方面的知识,你可以给学校的机器人队做指导,或者带队参加一些比较有挑战性的机器人比赛。

写到这里,我就不可能给出很多不同领域的指导了,因为随着学习的进一步深化,我自己熟悉的领域也在收缩。我只能对几个领域给出我的意见。

对视觉定位和传感器融合来说,SLAM急需新的突破,目前通过几何约束去实现loop closure看起来已经走入了死路,没法有更多的发展了,下一步可行的方向是与深度学习进行结合。具体的一些介绍可以阅读行业中大牛的一篇文章http://www.computervisionblog.com/2016/01/why-slam-matters-future-of-real-time.html,记述了几个业界大牛们最新的观点。传感器融合技术,目前还有很多问题可以探索,因为传感器的延时、不均匀的信号,会给定位系统造成困扰,如何去除这些干扰,需要建立比较复杂的非线性优化问题,具体可以关注香港科技大学Shaojie Shen的工作。

对于多自由度机械手和机器人的locomotion来说,这里面还有非常多可以探索的研究问题。我前面提过接触力和摩擦力很难仿真,大神告诉我现在没有任何一种工具和理论能把接触力和摩擦力正确仿真出来,因此如何在机器人系统里妥善处理对这些力的控制,就是很难的问题了。现在业界的一个前沿发展方向,也是利用机器学习技术来帮助机器人学会处理这些外力,不过人类目前最优秀的多自由度机器人系统,Berkeley的Brett机器人,叠几块积木就要用十分钟(New ‘deep learning’ technique enables robot mastery of skills via trial and error),显然还有很多提升的空间。这方面的问题同学可以关注知乎大神@戴泓楷@周佳骥。

最后我想再强调一遍表达能力的重要性。你可以从自己带的课程和机器人队入手,把自己这几年来学过的知识做成PPT讲给学生们听,然后让他们给你反馈。多做这样的练习,提升自己做演讲的能力,这将来会让你受益匪浅。

研究生二年级之后,你可以准备进机器人公司工作了,也可以根据你自己感兴趣的研究方向申请博士接着努力。由于你已经掌握了广博的知识和技能,你的职业生涯将会大有作为。

结束语

我从2008年展开自己的机器人生涯。那一年波士顿动力刚刚发布他们的大狗机器人,Python还是很小众的语言,Ubuntu 8.04还很不稳定,Chrome还没有多少人知道。在之后的几年中我目击了深度神经网络的复兴,看到波士顿动力的机器人日渐强大,经历了ROS的起源和繁荣,帮助了大疆的崛起,深深为这个产业的未来感到激动。我希望这篇文章能够帮助更多的年轻人进入机器人学的海洋,为未来机器人学的继续发展贡献力量。


Blink on stm32f103c8t6 Using PlatformIO (Mac)

$
0
0
    1. Install stlink.

      brew install stlink

    2. check stlink is installed.
    3. set up connection and jump.
    4. use ST Nucleo F103RB to init the board.
    5. platfromio.ini
      [env:stm32f103c8t6]
      platform = ststm32
      framework = mbed
      board = nucleo_f103rb
      upload_protocol = stlink
    6. blink code
    7. http://www.nutdiy.com/2016/05/blink-on-stm32f103c8t6-using-platformio.html
    8. It is also possible to use Arduino. The platfromio.ini will be
      [env:genericSTM32F103R8]
      platform = ststm32
      board = genericSTM32F103C8
      framework = arduino
      upload_protocol = stlink

9. Connect the blue pill with stlink
STLink pin BluePill pin
GND (3 or 4)  GND
3.3V (7 or 8)3.3
SWDIO (2)  DIO
SWCLK(6)  DCLK

The mode in which STM32 starts is determined by pins BOOT0 and BOOT1 :

BOOT1 BOOT0 Boot mode
X 0 User Flash memory
0 1 System memory (bootloader)
1 1 Embedded SRAM

To get USB Serial working, I did as described in Hardware installation paragraph here and soldered a 1.5k resistor between 3.3V and PA12, while also desoldering R10 from PCB.

https://shortn0tes.blogspot.ca/2017/06/how-to-use-platformio-to-develop-for.html


Solar Power

Swift Top 10 Articles For the Past Month (v.Oct 2017)

$
0
0

Swift Top 10 Articles For the Past Month (v.Oct 2017)

For the past month, we’ve ranked nearly 1,100 Swift articles to pick the Top 10 stories that can help advance your iOS career (0.9% chance to be picked in the list)

  • Topics in this list: MVVM, Architecture, iPhone X, Animation, Game, Reusable Framework, Server-side, Auto Layout, Algorithms, Type-Safe File Paths, Card UI
  • Swift Open Source of the Month is included at the bottom.
  • Swift Previous Month: Here

Mybridge AI ranks articles based on the quality of content measured by our machine and a variety of human factors including engagement and popularity. This is a competitive list and you’ll find the experience and techniques shared by experienced iOS developers useful.

Rank 1

How not to get desperate with MVVM implementation. Courtesy of S.T.Huang Brewery


Rank 2

Imagine Engine Tutorial #1: Asteroid Blaster [836 stars on Github]. Courtesy of John Sundell

……….[ ImagineEngine Open Source ]


Rank 3

Getting Started with Reusable Frameworks for iOS Development. Courtesy of Alec O’Connor


Rank 4

Server-side Swift Using Vapor. Courtesy of Tanner Nelson, Creator of Vapor


Rank 5

Swift 4: Introduction to Auto Layout Programmatically (Ep 1). Courtesy of Brian Voong


Rank 6

iOS Animation Tutorial: Getting Started [Part I]. Courtesy of Marin Todorov, Co-Author of RxSwift book

……….. [ Part II: Custom View Controller Presentation Transitions ]


Rank 7

The worst possible application: The purpose of app design patterns. Courtesy of Matt Gallagher


Rank 8

iOS Architecture: A State Container based approach. Courtesy of Luis Recuenco


Rank 9

Back to the fundamentals: Sorting algorithms in Swift (from scratch!). Courtesy of Ennio Masi



Viewing all 759 articles
Browse latest View live