Yearly Archives: 2015


[leetcode] Decode Ways

Decode Ways A message containing letters from A-Z is being encoded to numbers using the following mapping: ‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing digits, determine the total number of ways to decode it. For example, Given encoded message “12”, it could […]


[leetcode] Subsets II

Subsets II Given a collection of integers that might contain duplicates, nums, return all possible subsets. Note: Elements in a subset must be in non-descending order. The solution set must not contain duplicate subsets. For example, If nums = [1,2,2], a solution is: [ [2], [1], [1,2,2], [2,2], [1,2], [] […]


[leetcode] Gray Code

Gray Code The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. For example, given […]


[leetcode] Triangle

Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the following triangle [ [2], [3,4], [6,5,7], [4,1,8,3] ] The minimum path sum from top to bottom is 11 (i.e., 2 + 3 […]


[毕设笔记]利用Android手机的传感器进行APP开发

自己的毕业设计是用安卓手机控制无人机。今天尝试了下读取安卓手机传感器的信息,通过手机的重力感应器,通过手机的倾斜来控制无人机的飞行方向。 基础知识 安卓手机配置的传感器有加速度传感器(Accelerometers),陀螺仪(Gyroscope),电子罗盘(Magnetic),光传感器(Illumination),距离接近传感器,环境温度传感器(Ambient Temperature)等。 一般的安卓手机都会配置前三个传感器,这也是我们本文所要讨论的重点。 获得手机的姿态 有趣的是,手机内置的陀螺仪(Gyroscope)的直接输出并不是角度而是角速度。这和我们的常识有些违背。原因是包括手机在内的很多电子设备中内置的陀螺仪,是利用震动物体在旋转时产生的科里奥利力来检测角速度,通过计算而间接地得到角度。而不是利用我们平常见到的那种巨大的依靠角动量守恒而保持旋转轴指向不变的陀螺仪来直接得到角度数据。 上图:微电机陀螺仪获得角速度的原理 必须指出,如果单独用陀螺仪获得角度的话,需要对角速度在时间上积分。这带来了累积误差。并且,陀螺仪本身会发生漂移,导致误差会随时间急剧地增大。为了减小误差,我们必须利用其它的传感器,比如加速度传感器来进行互补融合计算,减小误差。 多传感器融合算法 为了抵消陀螺仪的累积误差和漂移误差,我们往往用加速度传感器进行修正。