Use SNOPT as A ROS Service
As a mathematical solver, SNOPT is good enough to solve optimization problems such as Linear-Quadratic-Regulator and Model-Predictive-Controller. In ROS framework,
packing SNOPT as a service is an efficient method to get the optimized result. Here we will introduce the whole configuraiton and setting step by step.
Build a Server(C++)
In order to use SNOPT service, a server is required to receive the request and response the result.
Actually, a specified srv file is also needed to transfer inform ...
Linear-Quadratic-Regulator(LQR) Controller
The theory of optimal control is concerned with operating a dynamic system at minimum cost. The case where the system dynamics are described by a set of linear differential equations and the cost is described by a quadratic function is called the LQ problem. One of the main results in the theory is that the solution is provided by the linear–quadratic regulator (LQR), a feedback controller whose equations are given below.
General Description
From Wikipedia
The settings of a (regulating) controll ...
ROS Services
ROS Services are defined by srv files, which contains a request message and a response message. These are identical to the messages used with ROS Topics.
roscpp converts these srv files into C++ source code and creates three classes that you need to be familiar with: services defitions, request messages and response messages.
Using srv
Before creating a service server and service clients, the srv file is required. srv files are saved in the folder named srv in the same diretory as the folder na ...
Configuration of SNOPT
SNOPT (Sparse Nonlinear OPTimizer) is a general-purpose system for constrained optimization, which requires a license to be executed.
It minimizes a linear or nonlinear function subject to bounds on the variables and sparse linear or nonlinear constraints.
It is suitable for large-scale linear and quadratic programming and for linearly constrained optimization, as well as for general nonlinear programs.
Simple Tutorial in 2D
Apply the license
UCSD offers evaluations versions (for 3 months) of op ...
Smart Pointer in C++
C++ 编程中,指针一直是重要且深奥的一项,在很多时候因为指针使用不当会导致内存泄漏,产生严重后果。
Example
如以下代码所示,在类中存在类型为指针的成员变量,如果该类没有重新编写拷贝,赋值构造函数,在对该类的对象进行拷贝,赋值操作时,
会调用编译器生成的默认的拷贝,赋值构造函数。此时,当执行c2(c1)或者c3 = c2时,指针data的地址被复制了多次,
c1,c2,c3各持有一份,因此在进行析构的时候便会产生内存错误。
1234567891011121314151617181920212223242526272829303132#include <iostream>class ErrClass {private: int* data;public: ErrClass(int _data):data(NULL) { init(_data); std::cout << "construct" << std::endl; } virtual ~ ...
Proportional-Integral-Derivative(PID) Controller
A proportional-integral-derivative controller (PID controller) is a control loop mechanism employing feedback taht is widely used in industrial control systems and a variety of other applications requiring continously modulated control.
Principle
A PID controller continuously calculates an error value e(t)e(t)e(t) as the difference between a desired setpoint (SP) and a measured process variable (PV) and applies a correction based on proportional, integral, and derivate terms (denoted P, I and D ...
Self-driving Hardware and Software Architectures
本篇为多伦多大学的自动驾驶车辆课程中的第二周课程笔记,涉及到自动驾驶车辆的软硬件设计。
Sensors and Computer Hardware
Sensors
传感器(Sensors)作为检测外界和车辆自身情况的硬件,在无人驾驶车辆中是必不可少的。传感器可以根据其感知数据范围的不同分为两类:
Exteroceptive:extero = surroundings
proprioceptive:proprio = internal
摄像机
摄像机(Camera)作为感知外界环境的核心,主要有以下3个评价指标(Comparison metrics):
分辨率(Resolution):分辨率影响摄像机的清晰度,分辨率越高,则可以观察到的物体细节越多
视场角(Field of View):视场角顾名思义为摄像头可以观察到的范围
动态范围(Dynamic Range):动态范围指的是摄像头从黑暗到明亮环境时的成像调节能力
有的摄像机通过两个镜头加上融合算法处理,可以得到深度信息,被称作双目摄像机,得到出来的图像除了三个颜色通道外(RGB),
还有一个通道存储深度信息(Depth)。
...
VIM 的主题配色与语法高亮设置
在 VIM 编辑器中,想要源代码语法高亮,不仅需要有配色方案,还需要有对应的 syntax 文件。
配色方案
VIM 中,所有的配色方案都可以存放到 ~/.vim/colors 文件夹下, 以 [name].vim 文件的形式存储。
配色方案中存储的是针对所有文件的基础语法高亮的配色。
以 Monokai.vim 为例,将网上下载到的配色方案放入到 ~/.vim/colors 文件夹下后,在 ~/.vimrc 中加入以下内容:
123syntax on "Open syntax highlight"set background=dark "Set color of background"colorscheme Monokai "Set colorscheme"
语法高亮
但是,只设置了配色方案的话,是无法针对某种类型的源代码进行语法高亮的。
为了实现针对不同语言的源码进行语法高亮,需要有对应的 syntax 文件,所有的 syntax 文件都存放到 ~/.vim/syntax 文件夹下。
syntax 文件中存放的是语法通配 ...
Use Vimdiff as Git Mergetool
什么是 vimdiff ?
vimdiff 是 vim 文本编辑器自带的用于对比文件差异的工具,详细说明 点击此处。
因此,vimdiff 可以用于解决 git 合并的产生的冲突。
使用方法
Git 配置
使用 vimdiff 之前需要对 git mergetool 进行配置,指定 vimdiff 作为其默认的查看工具。
123git config merge.tool vimdiff # 指定vimdiff作为默认mergetoolgit config merge.conflictsytle diff3 # 设定mergetool风格git config mergetool.prompt false # 取消打开文件时的warning显示
使用流程
当我们在使用git pull或者git merge命令因为文件冲突报错而不能成功合并时,通过执行git mergetool命令打开 vimdiff.
vimdiff 打开后,可以看到4个窗口排列成两行:
第一行的3个窗口从左到右分别被命名为LOCAL,BASE,REMOTE,分别代表了当前分支上文件的内容,两个分支的上游分支的内容, ...
vimdiff
对比文本文件(源文件)是项目开发中经常会碰到的情况,现在很多专业的IDE已经提供了文件对比的功能,
但是这些IDE在远程连接服务器的时候必须通过虚拟桌面才能使用,因此vimdiff成为了远程连接服务器的对比文件工具的首选。
启动方法
vimdiff 是文本编辑器vim的功能之一,依赖于系统的diff功能。启动命令如下:
1vimdiff <file1> <file2>
除了上面的方法,也可以在vim中使用窗口分割模式来启动diff命令
123vim <file1> # 打开第一个文件:vertical diffsplit <file2> # 使用diff模式打开第二个文件在右边的窗口
合并文本
文件比较的最终目的就是为了减少差异或者合并文件,通过下面的基本命令可以方便地进行文件合并的操作。
将差异内容拉取到当前文件
如果想快速修改一个差异点内的内容,即将另一个文件的内容拉取到当前文件,通过do命令即可实现。
将差异内容推送到另外一文件
反之,如果想要将当前文件的某个差异点的内容推到另外一个文件,可以通过dp命令实现。
刷新比较文件
当 ...