[toc]

git 原理图

git command

git 命令大集合

git add

1
git add -h

查看更详细的帮助内容

1
git add . 

不加参数默认为将修改操作的文件和未跟踪新添加的文件添加到 git 系统的暂存区,注意不包括删除文件。

1
git add -u .

-u == --update,表示将已跟踪文件中的修改和删除的文件添加到暂存区,注意不包括新增加的文件。

1
git add -A .

-A == --all,表示将所有的已跟踪的文件的修改与删除和新增的未跟踪的文件都添加到暂存区。

stash local changes

  • If you want remove all local changes from your working copy, simply stash them.
1
git stash save --keep-index  
  • If you don’t need them anymore, you now can drop that stash.
1
git stash drop

git pull

1
git pull origin target_branch_name

下载指定分支代码合并到当前分支:相当于指定分支的代码与当前分支的代码合并到了一起)。

每次使用该命令前,需要保证本地工作区是没有任何修改代码的,也就是说需要将本地工作区编辑过的文件添加到暂存区 (git add .),或提交到本地仓库中 (git commit),才可以使用该命令拉取指定分支的代码合并到当前分支中。

建议:每次在操作完 git commit 命令后,必须拉取一下 master 分支代码,保持本地正在开发功能逻辑的代码分支代码是最新的,避免后续在提交时冲突过多或覆盖掉其他人的代码的问题出现。

git brach

1
git branch -a

加上 - a 参数可以查看远程分支,远程分支会用红色表示出来

1
git log --graph

查看分支合并图

git log

1
git log --oneline --author=git_name

git log 中根据 author 过滤

1
git log --pretty=one

显示 git 提交记录的第一行,方便检索和管理提交记录

1
git log --oneline --after="2020-05-21 00:00:00"  | grep "region"

查询某段时间的提交记录关键字

1
git log --all

查询所有分支的 commit 记录,比如找到之前操作的分支

git cherry-pick

1
2
3
4
5
nothing to commit, working directory clean
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

git commit –allow-empty

It’s exactly what it says: the changes you’re trying to cherry-pick are already wholly already integrated/cherry-picked in the branch you’re on. I.e. the result of the cherry-pick is no changes. You can create an empty commit with the --allow-empty flag to indicate that you attempted to cherry-pick, but there were no changes to pull in.

git shortlog

查找 commit description 包含某些字符的 log 日志

1
2
3
4
5
git shortlog --format='%H|%cn|%s' | grep 'your_search_info'

%H: commit hash
%cn: committer name
%s: subject

git commit

修改 commit 信息

用一条新的 commit 信息修订现有的 commit,这会覆盖原始 commit。请勿在已推送的 commit 中使用它。

1
git commit --amend -m "<new commit message>"

恢复指定 diff

1
2
// You can specifically apply an out-of-date diff or a diff which was never attached to a revision by using this flag.
arc patch --diff diff_id --nobranch

删除多个本地 branches

1
2
# 执行前需要切换到master分支执行
git branch | grep -v "master" | xargs git branch -D

如何把分支比较结果输入到指定文件

  • Linux 输出重定向
1
2
> 输出重定向:会将原来的文件内容覆盖。
>> 追加:不会覆盖原来文件的内容,而是追加到文件的尾部。
1
2
3
4
# 使用 Linux 重定向命令
git diff [branchA] [branchB] >>d:/diff/exportname.diff # 追加

git diff [branchA] [branchB] >d:/diff/exportname.diff # 覆盖

git patch

有时候,我们需要进行代码迁移,比如把 A 开发机上的代码迁移到 B 开发机上,这时候就可以使用补丁。

git 提供两种补丁方案:

  • 通过 git diff 生成 .diff 文件。
    • 可以指定文件生成 .diff 文件,也可以指定单个或多个 commit 生成。
    • 生成的文件不含有 commit 信息。
  • 通过 git format-patch 生成 .patch 文件。
    • 一个 commit 对应一个 patch 文件。
    • 生成的文件含有 commmit 信息。

git format-patch

1
2
3
4
5
6
7
8
# 当前分支所有超前 master 的提交
git format-patch -M master

# 某次提交以后的所有 patch。[commit id] 指的是 commit name,可以通过 git log 查看。
git format-patch [commit id]

# 某两次提交之间的所有patch:
git format-patch [commit sha1 id..[commit sha2 id]

git format-patch 命令中,一个 commit 对应一个 patch 文件,所以生成的补丁文件默认从 1 开始顺序编号,并使用对应提交信息中的第一行作为文件名。

apply patch

1
2
3
4
5
6
7
8
# 先检查 patch 文件
git apply --stat xxx.patch

# 检查能否应用成功
git apply --check xxx.patch

# 打补丁。使用 -s 或 –-signoff 选项,可以 commit 信息中加入 signed-off-by 信息。
git am --signoff < xxx.patch
  • branch 中修改文件所在目录,git 是可以跟踪这个变化的。

git submodule

有种情况我们经常会遇到:某个工作中的项目需要包含并使用另一个项目。 也许是第三方库,或者你独立开发的,用于多个父项目的库。 现在问题来了:你想要把它们当做两个独立的项目,同时又想在一个项目中使用另一个。

Git 通过子模块来解决这个问题。 子模块允许你将一个 Git 仓库作为另一个 Git 仓库的子目录。 它能让你将另一个仓库克隆到自己的项目中,同时还保持提交的独立。

在配置网站的 gitHun Actions 中,主题 Next 是一个 submodule。我将 Next submodule 转化为普通文件夹,步骤如下所示。

1

如何把 Git Submodule 变成普通文件夹

References

近年来互联网数据大爆炸,数据的丰富度和覆盖面远远超出人工可以观察和总结的范畴,而机器学习的算法能指引计算机在海量数据中,挖掘出有用的价值,也使得无数学习者为之着迷。

机器学习是什么

在我看来,机器学习研究的是计算机怎样模拟人类的学习行为,以获取新的知识或技能,并重新组织已有的知识结构使之不断改善自身。简单来讲,就是计算机从数据中学习出规律和模式,以应用在新数据上做预测的任务。

机器学习关注什么问题

并非所有的问题都适合用机器学习解决 (比如逻辑清晰的问题用规则就能很高效和准确地处理),也没有一个机器学习算法可以通用于所有问题。那么,机器学习,到底是关心和解决什么样的问题。

如果在 IT 行业 (尤其是互联网) 里溜达一圈,你会发现机器学习在以下热点问题中有广泛应用:

从功能的角度分类,机器学习在一定量级的数据上,可以解决下列问题:

  • 分类问题:根据数据样本上抽取出的特征,判定其属于有限个类别中的哪一个。比如:垃圾邮件识别。

  • 回归问题:根据数据样本上抽取出的特征,预测一个连续值的结果。比如:电影票房预测。

  • 聚类问题:根据数据样本上抽取出的特征,让样本抱团 (相近 / 相关的样本在一团内)。比如:新闻分类。

其实,上述常见问题可以划到机器学习最典型的 2 个分类上:

  • 分类与回归问题需要用已知结果的数据做训练,属于 “监督学习”。

  • 聚类的问题不需要已知标签,属于 “非监督学习”。

入门方法与学习路径

机器学习对大多数入门者也有一个比较通用的学习路径,也有一些优秀的入门资料可以降低大家的学习门槛。简单说来,大概的一个学习路径如下:

因为机器学习是一个将数学 / 算法理论和工程实践紧密结合的领域,需要扎实的理论基础帮助引导数据分析与模型调优,同时也需要精湛的工程开发能力去高效化地训练和部署模型和服务,所以最左边之所以列了『数学基础』、『典型机器学习算法』、『编程基础』三个并行的部分。

数学基础

机器学习之所以相对于其他开发工作,更有门槛的根本原因就是数学。每一个算法,要在训练集上最大程度拟合同时又保证泛化能力,需要不断分析结果和数据,调优参数,这需要我们对数据分布和模型底层的数学原理有一定的理解。

如果只是想合理应用机器学习,而不是做相关方向的理论研究,需要的数学知识基本都集中在微积分、线性代数、概率与统计中。

典型算法

机器学习里所说的 “算法” 与程序员所说的 “数据结构与算法分析” 里的 “算法” 略有区别。前者更关注结果数据的召回率、精确度、准确性等方面,后者更关注执行过程的时间复杂度、空间复杂度等方面。

绝大多数问题用典型机器学习的算法都能解决,粗略地列举一下这些方法如下:

基本工作流程

当我们基本具备了机器学习的必要条件后,剩下的就是怎么运用它们去做一个完整的机器学习项目。

机器学习的工作流程如下:抽象成数学问题 - 获取数据 - 特征预处理与特征选择 - 训练模型与调优 - 模型诊断 - 模型融合 - 上线运行。

这些工作流程主要是工程实践上总结出的一些经验。并不是每个项目都包含完整的一个流程。这里的部分只是一个指导性的说明,只有大家自己多实践,多积累项目经验,才会有自己更深刻的认识。

参考资料

对泰山的向往,要从课本说起,从冯骥才的《挑山工》,到杜甫的 “造化钟神秀,阴阳割昏晓”,自己对泰山的向往不断被加深,一直渴望去看朝阳从云海中喷薄而出,领略孔子登泰山而小鲁的心境。

多平台维护不易,内容实时更新于 个人网站,请移步阅读最新内容。

泰山本来是毕业旅行的一部分,中间却不断耽误和延后,工作一年多了也未成行,最后一狠心,不愿意再等待最佳的季节和时机,选择了一个秋日的周末 (2019 年 10 月 19~20 日),和女朋友从北京出发,小憩济南,夜爬泰山,圆了自己的泰山梦。

ps. 这个时间点被许多人劝说天气比较冷,不适合夜爬,结果自己做足攻略和准备后,一趟下来,发现并不是别人描述的那么寒冷和危险,每个人对冷暖、风险的感受不同,所以小马过河,深浅还是需要自己试。

本次路线规划的特点:

  • 适合上班族和学生,占用周末时间,不影响周末晚上的休息,周一工作和学习元气满满。

  • 密集游览济南 (趵突泉、大明湖和芙蓉街) 和泰山 (泰山和岱庙) 的主要景点。

  • 浏览时间分散,休息时间比较充分,不会特别累。

  • 两个人同行,旅行花销 (交通、食宿、门票) 不到 1400 元。途中高铁、打车较多,外加一晚的住宿,整体花销多一点。

2019 年 10 月 18 日 (周五) 晚上,和女朋友乘坐 K101 火车从北京出发,在火车上休息。第二天早上五点一刻抵达济南站,火车站附近寄存行李 (10 元钱),我们轻装简行,徒步前往趵突泉景点 (离车站 3 公里),沿途可以看济南的景色,感受生活气息,以及解决早饭,抵达趵突泉景点的时间正好是开园时间 (7:00),门口微信购票,园内游客比较少,不用人挤人地排队等待。

景点的清晨,地面湿漉漉的,空气很适宜,旁边有不少本地人在晨练。

趵突泉位于景区的深处,三眼泉水喷突翻滚,旁边小泉串串珍珠,不愧是 “泉水甲天下”。我们到达的时间比较早,游客很少,拍照和欣赏景色很方便,所以建议先游趵突泉,后看大明湖,错峰出行。

园内除了趵突泉,周边也是百泉争涌,各有特点,时间充裕可以看看,这些泉水先会流到济南的护城河,最终流向大明湖畔,“四面荷花三面柳,一城山色半城湖”,正是这个城市的写照。我们在趵突泉景点看得比较细,逗留的时间比较长,大概用时 2 小时。

浏览完趵突泉后,向北 800 米可以到达芙蓉街 (小吃街),芙蓉街已经被全国各地的美食和网红食品占据,本地有特色的食品并不多,所以我匆匆路过,没有在这里停留,去看大明湖,哈哈。

从芙蓉街出来后,继续向北,便能到达大明湖。走在湖边,湖光潋滟,秋风阵阵,很是惬意,自己绕湖行走一圈,大概用时 1.5 小时。

大明湖的荷花还是蛮多的,但是秋季的时节不对,荷花已经盛开过,茂盛的荷叶依旧可以让我想象出荷花布满湖面的美景。

从大明湖出来后,时间略微有点紧,打车返回济南站,然后乘坐 G459 去泰安 (泰山所在地)。

济南旅游建议:

  • 趵突泉旁边的小亭,有免费的泉水品尝,清冽甘美。

  • 抵达趵突泉后,门口有自助买票 (成人 40 元),不用排队。

  • 济南的趵突泉、大明湖和芙蓉街都聚在中心区,离济南站比较近,离济南西站比较远,建议买票到济南站,而非济南西站。

从济南出发,高铁不到半小时就能抵达泰安。我们打车抵达岱庙附近的酒店,稍作休息,然后游览岱庙。

ps. 网上攻略说泰山出租车不打卡,自己不喜欢搞价,所以整个行程一直选择滴滴打车,避免被黑出租坑和不必要的搞价。


岱庙是历代帝王举行封禅大典和祭拜泰山神的地方,园内碑林众多,一部分是泰山上的石刻复制,文化底蕴很厚实,需要静下心慢慢体会。

岱庙对古石刻和壁画的保护并不到位,好多石刻裸露在外,仍有游客对壁画拍照,遗憾。岱庙周边的城墙对游客开放,可以登上城墙绕行一圈,瞭望远处的泰山。自己对碑文看得略微细一点,时间稍微长点,游览时间大概 1.5 小时。岱庙和泰山的门票是共用的 (成人 115 元,三日内不限次数),可以微信公众号购票,景区身份证验票。

下午五点半游览完岱庙后,回到酒店休息,为晚上的夜爬储能。晚上 10:30 醒来,点外卖吃晚饭,然后打车直接到红门登山口,开始泰山的夜爬之行。

因为游览岱庙时已经买好了泰山和岱庙的通票,直接刷身份证进入景区,比排在外面买纸质票方便许多。我们大概是凌晨零点从红门开始爬山,同行爬泰山的游客很多,整个行程周围 10 米内基本会一直有同行者,很热闹,不用担心独行夜路。刚从红门上来时,道路中间会摆放一些财神塑像,注意安全。

泰山夜行路线比较成熟,一路上提供矿泉水、方便面、爬山杖、军大衣的商家比比皆是,完全不用担心错过这家没下家。到达中天门后,继续向前走 200 米左右,会有一个比较便宜的补给区 (中天门附近车辆运输方便),比如矿泉水 10 元 4 瓶,如果继续向上爬,价格就不会那么便宜了,所以建议在中天门适度补给。因为是夜间,水的需求量应该不会太多,不建议购买太多背上去 (推荐 1 瓶 / 人),可以自带一些热水。此外,夜间爬山时运动量大,不会太冷,所以不建议开始爬山时租军大衣,否则爬山时不方便,归还时也不方便,建议爬到南天门后再租军大衣。

夜爬泰山看不清远处,所以低着头一步一个脚印向前走,反而简单起来。我们在爬山时,中间有半个多小时的休息,抵达南天门时已经 4 点半 (从入口开始算起,大概花费 4.5 小时)。南天门的风明显变大,气温也比较低,那里可以租军大衣 (租金 10/20/30 元不等,押金 100 元,返还衣服时退押金)。我们在那里才穿上背了一路的羽绒服 (夜爬真心不冷),外面套着租的军大衣,全副武装抗冷。

整装完毕后,便可以看时间提早去日观峰挑个好位置,观鲁台也可以。从南天门到观日出的好地点 — 日观峰 (拱北石),大概需要半小时,建议至少比日出时间提早一小时到,可以占个好地方,否则只能在别人的手机里看日出啦。我们提早一小时抵达时,天还很暗,但日观峰上已经是 people mountain people sea,大家翘首以待。

我们在寒风里等待了一个多小时,但这次太阳有点害羞,躲在云里迟迟不肯出来 (多云天气),大概 7 点多才露个脸,把大家乐得不行,也算是不枉夜爬吧。虽然没有看到朝阳从云海里喷薄而出,但是自己和一堆人盯着远处看足 2 个小时,从天黑到蒙蒙亮,到泛起鱼肚白,再到最后的亮堂堂,看天上云卷云舒,也算是一次很值得回忆的观日活动吧。

看完日出后,去旁边的玉皇顶登上最高处,一览众山小,便开始往回折返。我们第一次选择的是比较成熟的红门路线,路线大概是岱庙 -> 岱宗坊 -> 红门宫 -> 万仙楼 -> 斗母宫 -> 经石峪 -> 壶天阁 -> 回马岭 -> 中天门 -> 快活三里 -> 云步桥 -> 五大夫松 -> 十八盘 -> 南天门 -> 天街 -> 碧霞祠 -> 唐摩崖 -> 五岳独尊 -> 日观峰 -> 玉皇顶。

因为晚上夜爬无法看清楚风景,所以自己选择原路折返,一路下坡,从高处看着下面曲折的山道,感慨自己是如何登上来的,正所谓 “登高必自卑,行远必自迩”。我们走到中天门时,因为女朋友比较累,所以在那里乘坐景区的摆渡车下山 (30 元 / 人) 到天外村,大概中午 11 点半到达山脚。

泰山旅游建议:

  • 预定的酒店最好在岱庙附近,距离岱庙和泰山登山口都比较近,方便出游。

  • 夜爬泰山,晚上记得要吃好饭,下一顿饭估计要清晨了。看完日常后,在天街有几家 10 元管饱的早餐,但是不太卫生,我亲眼看到服务员会把其他人吃剩的咸菜重新放回去。

  • 最好轻装简行,记得拿充电宝,拿点热水和士力架,不要带太多的零食。山上网络不好,可以带一些现金。

  • 虽然路上游客比较多,但是很多路段没有灯,建议购买头灯或手电筒,偶尔借着灯光看看远处,也是不错的体验。带上头灯,你一定是泰山最亮的仔。

  • 泰山光污染不严重,天气晴朗时,抬头应该可以看到月亮和繁星。

  • 夜爬注意安全,泰山最抖的是十八盘路段,尤其是升仙坊这一段,记得抓好路旁边的扶手。

  • 路上小贩特别多,买东西一定不要在第一家买,对半还价。尽管我做了攻略,也深谙这个道理,但是饥饿和寒冷让我一次次忘记,比如我在中天门第一家买的西瓜很贵,继续行走 200 米,有一排商家,可以便宜一大半,租大衣同理。

  • 记得买保险,比如支付宝的旅游险,一般是三日,可以覆盖自己的短期游。

中午在酒店修整后,2 点出门吃午饭,乘坐 4 点多的 G322 从泰安高铁站返回北京,到北京大概是晚上 6 点半,可以美美休息一晚,第二天依然是精气神饱满。

ps. 本文实时更新于 个人网站,请移步阅读。

国内的网盘虽然免费,但总让人对隐私不太放心,毕竟 “免费的永远是最贵的”。

自己之前购买了一个 VPS,搭建自己的网站后,感觉没有充分利用 VPS 的流量和性能,于是琢磨搭建一个私人的云服务,随后就发现了 Nextcloud 这一开源云服务。

通过 链接 注册并购买搬瓦工 VPS,就可以按下面的教程安装 NextCloud 私人云盘啦,我也可以得到新客注册的返现。

About NextCloud

Nextcloud is the open source file sync and share software for everyone from individuals to large enterprises and service providers. Nextcloud provides a safe, secure and compliant file sync and share solution on servers you control.
With Nextcloud you can share one or more folders on your PC, and sync them with your Nextcloud server. Place files in your local shared directories, and those files are immediately synced to the server, and then to other PCs via the desktop client. Not near a desktop client? No problem, simply log in with the web client and manage your files there. The Android and iOS mobile apps allow you to browse, download and upload photos and videos.
Whether using a mobile device, a workstation, or a web client, Nextcloud provides the ability to put the right files in the right hands at the right time on any device in one simple-to-use, secure, private and controlled solution.

简而言之,Nextcloud 是一个自由及开放源代码的私有云网盘,每个人都可以在私人服务器上安装并运行它,能够快速同步你的文件到你的私有服务器,方便你跨平台 (现在支持 PC、Android 和 iOS) 同步和分享文件,功能和百度云不差多少,优点是隐私好,同步下载速度取决于服务器带宽。

与 Dropbox 等专有服务相比,Nextcloud 的开放架构让用户可以利用应用程序的方式在服务器上新增额外的功能,并让用户可以完全掌控自己的数据。同时,Nextcloud 可与在 Windows、macOS 或是多种 Linux 发布版上运行的客户端同步。

Nextcloud 用户可以管理日历、联系人、计划工作与流媒体。此外,用户也可以在 Nextcloud 上使用基于浏览器的文本编辑器、书签服务、缩略网址服务、相册、RSS 阅读器与文件查看器。因为有良好的扩展性,Nextcloud 可以透过鼠标点一下即可完成安装的应用程序强化其功能,并可连线至 Dropbox、Google 云端硬盘与 Amazon S3 等产品。

安装简介

Nextcloud 虽然这么好用,但是安装依赖却非常复杂,需要安装 LNMP 集成环境 (i.e. Linux + Nginx + MySql + PHP),在搭建过程中或多或少都会出点问题。

本文推荐一个很方便的安装方法 docker-nextcloud,使用纯命令形式在 Docker 上安装 NextCloud (Docker file 会帮你把负责的依赖都配置好),并探讨如何配置反向代理,适合尝鲜的新手。

安装 Docker 后,需要安装两个容器:mysql 和 nextcloud。其中,mysql 用于存储用户的数据,nextcloud 通过向 mysql 容器读写数据,从而实现数据的存储和访问。

安装 Docker

Docker 是一个开源的应用容器引擎,让开发者可以打包他们的应用以及依赖包到一个可移植的镜像中,然后发布到任何流行的 Linux 或 Windows 机器上,也可以实现虚拟化。容器是完全使用沙箱机制,相互之间不会有任何接口。

1
2
3
4
# CentOS 7、Debian、Ubuntu
curl -sSL https://get.docker.com/ | sh
systemctl start docker
systemctl enable docker

复习知识点

  • curl 是一个工具,用于传输来自服务器或者到服务器的数据。
  • systemctl 是一个系统管理守护进程、工具和库的集合,用于取代 system V、service 和 chkconfig 命令,初始进程主要负责控制 systemd 系统和服务管理器。
  • systemctl start 启动服务
  • systemctl enable 激活服务并在开机时启用

安装 Nextcloud 服务器

1
2
3
4
5
6
7
8
# 拉取 Mysql 镜像和 Nextcloud 镜像
docker pull rootlogin/nextcloud && docker pull mariadb:10

# 创建 mysql 容器,注意修改数据库信息
docker run --name nextcloud_db -d --restart=always -e MYSQL_ROOT_PASSWORD=test -e MYSQL_DATABASE=test -e MYSQL_USER=test -e MYSQL_PASSWORD=test -v /var/nextcloud/mysql:/var/lib/mysql mariadb:10

# 创建 nextcloud 容器,添加链接到 mysql 容器;ip 是浏览器访问云盘的端口号。使用镜像 rootlogin/nextcloud,以后台模式启动一个容器, 容器命名为 nextcloud,将容器的 80 端口映射到主机的 3000 端口,主机的目录 /var/nextcloud/data 映射到容器的 /data,并添加链接到上述的 nextcloud_db 容器。
docker run --name nextcloud_db -d --restart=always -e MYSQL_ROOT_PASSWORD=test -e MYSQL_DATABASE=test -e MYSQL_USER=test -e MYSQL_PASSWORD=test -v /var/nextcloud/mysql:/var/lib/mysql mariadb:10

MariaDB 和 MySQL 的关系:MariaDB 数据库管理系统是 MySQL 的一个分支。开发这个分支的原因之一是:甲骨文公司收购了 MySQL 后,有将 MySQL 闭源的潜在风险,因此社区采用分支的方式来避开这个风险。
MariaDB 的目的是完全兼容 MySQL,包括 API 和命令行,使之能轻松成为 MySQL 的代替品。

 

恭喜你,现在初级版的云服务器已经搭建成功。访问地址为 http://your_ip:3000。
启动命令里的 3000 端口可自行替换,不过后面有关端口的命令都可自行修改,/var/nextcloud/data 为网盘的数据库,可以自行修改。

复习知识点

  • docker pull 是从镜像仓库拉取镜像。
  • docker run 是创建一个新的容器并运行一个命令。
  • –restart=always,设置开机重启

防火墙开启端口

1
2
3
#CentOS 7
firewall-cmd --zone=public --add-port=3000/tcp --permanent
firewall-cmd --reload

初始设置

  • 访问 http://your_ip:3000。
  • 创建管理员帐号和密码
  • 数据库选择 MySQL/MariaDB,如果配置不成功,可以选择 SQLite (性能差点,但是可以满足个人基本的需求)。
名称 值
用户名 test
密码 test
数据库名 test
地址 nextcloud_db:3306

mysql 数据库默认端口是 3306。

  • 恭喜你,进入自己的网盘界面。

域名访问

IP 访问会直接把云盘的 IP 和端口暴露出来,感觉不太妥。如果要通过域名访问自己的网盘,就需要反代了。

反代可以用 Nginx、Apache、Caddy,本文讲述如何使用 Nginx。

Nginx 是一款轻量级的 Web 服务器 / 反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在 BSD-like 协议下发行。其特点是占有内存少,并发能力强,

默认用户已经完成购买域名、安装 Nginx 的前序步骤,鼓励折腾一下,有问题欢迎下面留言交流。

certbot 生成 https 证书

Let’s Encrypt 是很火的一个免费 SSL 证书发行项目,自动化发行证书,证书有 90 天的有效期。适合个人使用或者临时使用,不用再忍受自签发证书不受浏览器信赖的提示。
附上 CentOS 7.2 的 免费 SSL 证书 Let’s Encrypt 流程。

1
./certbot-auto certonly --email your_mail --agree-tos --no-eff-email --webroot -w /var/nextcloud -d drive.example.com

配置 Nginx 配置文件

在 /etc/nginx/conf.d/ 下的配置文件里添加如下配置。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
server {
listen 80;
listen [::]:80;
server_name drive.example.com;
# enforce https
return 301 https://$server_name$request_uri;
}

server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name drive.example.com;

ssl_certificate /etc/letsencrypt/live/drive.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/drive.example.com/privkey.pem;

add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";

location / {
proxy_pass http://your_ip:3000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

最后,重启 nginx,就可以通过网址访问自己的云盘啦!

1
systemctl restart nginx

安装中可能遇到的问题 FQA

  • Q: 初始化时,提示 “看起来您正在尝试重新安装您的 Nextcloud。但您的 config 文件夹中没有 CAN_INSTALL 文件。请在您的 config 文件夹中创建 CAN_INSTALL 文件以继续。”
  • A: 运行如下命令。
1
cd /var/nextcloud/data/config && touch CAN_INSTALL

其中,/var/nextcloud/data 为网盘的数据库,请自行修改。


  • Q: 反向代理后,网址无法直接访问,比如提示 403。
  • A:请先定位问题,可以在 /var/log/nginx/error.log 查看代理错误。

  • Q: 关机重启后,原来配置好的网盘无法访问。
  • A: 在使用 docker run 启动容器时,已经使用–restart 参数来设置容器开机自启。如果发现服务器重启后,无法访问网盘,可以尝试 update 命令设置 --restart=always。
1
docker update --restart=always 容器名称

Docker 提供了 restart policy 机制,可以在容器退出或者 Docker 重启时控制容器能够自启动。这种 Restart policy 可以保证相关容器按照正确顺序启动。


  • Q: 通过 IP 方式 登录时,没有出现登录界面,显示 “HTTP ERROR 500”.
  • A: 根据 Nextcloud 12 HTTP Error 500 提供的方法,更新 PHP 模块可以解决问题。
    • 我使用 apt-get upgrade 升级了所有软件的版本,然后问题得到修复。

HTTP 500 错误,全称为 HTTP 500 Internal Server Error,即 HTTP 500 内部服务器错误。HTTP 500 内部服务器错误表示服务器遇到意外情况,导致其无法履行请求,但它无法说明具体错误或发生错误的根本原因。当发生错误时,访问的网站会显示发生错误。

ps. 本文实时更新于个人网站,请移步阅读。

Gif 是当下较为流行的一种交流方式,其文件比视频小,而且比 jpg 图片生动形象,所以不仅在微薄、QQ 等社交中尤为常见,而且适用于产品和功能的展示。同时,Gif 文件大小一般是普通 MP4 格式的数倍。

GIFs are an average of 5-10 times larger than an efficiently encoded MP4 video. This difference in size means that GIFs waste a large amount of bandwidth and also load at a slower rate leading to a bad user experience.

下文主要分享下如何在 Ubuntu 18 上录制 gif 动画以及处理 gif 文件,不必动用到 Windows 中像 Photoshop 这样的神器。

软件需求

ImageMagick 是一款用于创建、编辑和合并位图图像的一款开源软件。

byzanz 是通过输入命令方式来录制文件小、清晰的 GIF 动态效果图。

Gif 录制

本文使用 byzanz 来录制 Gif,其主要的参数选项有:

参数 单位 含义
-d, --duration SECS 动画的时间 (默认:10 秒)
–delay SECS 开始之前的延时 (默认:1 秒)
-c, --cursor 录制鼠标光标
-a, --audio 录音
-x, --x 像素 要录制矩形的 X 坐标
-y, --y 像素 要录制矩形的 Y 坐标
-w, --width 像素 录制矩形的宽度
-h, --height 像素 录制矩形的高度
-v, --verbose 详细
–display 要使用的 X 显示

例子

1
byzanz-record -d 10 --delay=5 -x 0 -y 0 -w 1440 -h 900 out.gif  

上面的命令是录制屏幕坐标 (0,0) 处宽度 1440 像素、高度 900 像素的矩形区域 (指定的坐标为矩形左上角),延时 5 秒开始录制,录制时间 10s,输出文件 out.gif。

Gif 合并

如果想将录制的多个 Gif 合并成一个文件,只需将要合并的文件存到同一文件夹当中,再执行如下命令即可,不需要安装其他软件,Ubuntu 比 Windows 强大之处。

1
convert -delay 120 -loop 0 *.gif output.gif

其中,"-delay 120" 表示 Gif 动画速度,"-loop 0" 表示无限循环。

参考文献

Record Screen as Animated GIF in Ubuntu with Byzanz

Gifs vs animated videos - which should you use

[toc]

Socially Aware Motion Planning with Deep Reinforcement Learning

Paper download link


简评:之前的方法使用特征匹配 (feature-matching techniques) 的做法来描述和模仿行人的轨迹,但是人和人之间的特征是有差异的 (vary from person to person),所以生成的行人轨迹并不理想。这篇文献指出,尽管导航时指明机器人什么应该和人类交互做是比较困难的 (精确的行人导航机制),但是却可以简单地指明,什么是不应该做的 (违反社交规范)。尤其是,本文使用深度强化学习,提出一种时间高效 (time-efficient) 的遵守社会规范的导航策略。

This work notes that while it is challenging to directly specify the details of what to do (precise mechanisms of human navigation), it is straightforward to specify what not to do (violations of social norms). Specifically, using deep reinforcement learning, this work develops a time-efficient navigation policy that respects common social norms.

此外,本文是在作者基于深度强化学习的多智能体避障的研究基础上,在多智能体系统中引入具有社交意识的行为,本文的主要贡献是如何在 CADRL 中引入和融合社交行为。所以,可以简单认为,SA-CADRL = SA (socially aware) + CADRL (collision avoidance with deep reinforcement learning)。

This work extends the collision avoidance with deep reinforcement learning framework (CADRL) to characterize and induce socially aware behaviors in multiagent systems.

多平台维护不易,内容实时更新于 个人网站,请移步阅读最新内容。

INTRODUCTION

人机交互方法演进

  1. 将行人视为具有简单动力学的动态障碍物,执行特定的反应式避障行为。

    A common approach treats pedestrians as dynamic obstacles with simple kinematics, and employs specific reactive rules for avoiding collision.

    • 缺陷:这种方法没有观察人类的行为,会产生不安全、不自然的行为,尤其当机器人的速度和人类行走速度比较靠近时。

    Since these methods do not capture human behaviors, they sometimes generate unsafe/unnatural movements, particularly when the robot operates near human walking speed.

  2. 使用更精致的运动模型来推理附近行人的运动意图 (hidden intents),产生一系列预测轨迹。然后,使用传统的路径规划算法为机器人生成无碰撞 (collision-free) 的路径。

    More sophisticated motion models have been proposed, which would reason about the nearby pedestrians’ hidden intents to generate a set of predicted paths. Subsequently, classical path planning algorithms would be employed to generate a collision-free path for the robot.

    • 缺陷:导航问题分割为不关联的预测和路径规划,可能导致机器人冻结问题 (the freezing robot problem),机器人无法找到任何可行的行为,因为预测的轨迹让大部分的空间不可通行。

    Separating the navigation problem into disjoint prediction and planning steps can lead to the freezing robot problem, in which the robot fails to find any feasible action because the predicted paths could mark a large portion of the space untraversable.

  • My comment (MC): 虽然作者认为这种做法不合理,但是这是在目前工业界比较流行的做法。导航问题分割为多个层次模块,上下游之间透明,容易迁移和调试。
  1. 合作 (cooperation)

基于上述研究的问题,作者提出一种做法,合作 (cooperation),建模 (model)/ 预测 (anticipate) 机器人对周围行人的影响。

A key to resolving this problem is to account for cooperation, that is, to model/anticipate the impact of the robot’s motion on the nearby pedestrians.

  • 现阶段,基于合作的社交导航研究,主要分为基于模型 (model-based) 的做法和基于学习 (learning-based) 的做法。

    Existing work on cooperative, socially compliant navigation can be broadly classified into two categories, namely model-based and learning-based.

    • 基于模型的做法,是一种典型的多智能体避障 (multiagent collision avoidance algorithm) 的扩展,通过增加参数来引入对社交交互行为的考虑。

    Model-based approaches are typically extensions of multiagent collision avoidance algorithms, with additional parameters introduced to account for social interactions.

    模型方法的缺陷:不确定行人是否会遵循预设的几何模型;势力场需要针对不同的行人,调节参数;可能导致规划轨迹震荡 (oscillatory)。

    • 基于学习的做法,旨在通过匹配特征统计来开发一种策略。

    Learning-based approaches aim to develop a policy that emulates human behaviors by matching feature statistics.
    In particular, Inverse Reinforcement Learning (IRL) has been applied to learn a cost function from human demonstration (teleoperation), and a probability distribution over the set of joint trajectories with nearby pedestrians.

    学习方法比模型方法更贴近人类的行为,但是同时需要更高的计算代价 (computational cost)。同时,特征统计在人和人之间变化明显 (vary significantl),也引起其在不同场景下的泛化能力的担忧。

简而言之,存在的方法试图建模或复制详细的社交行为机制 (mechanisms of social compliance),因为行人行为的随机性 (stochasticity),仍然很难去量化 (quantify)。

In short, existing works are mostly focused on modeling
and replicating the detailed mechanisms of social compliance, which remains difficult to quantify due to the stochasticity in people’s behaviors.

作者认为人类会遵循一系列简单的社交规范,比如从右侧通过 (passing on the right)。所以在强化学习框架中描述 (characterize) 这些行为的特征,发现通过解决合作避障的问题可以生成 (emerge) 类人的导航惯例。

Building on a recent paper, we characterize these properties in a reinforcement learning framework, and show that human-like navigation conventions emerge from solving a cooperative collision avoidance problem.

Symmetries in multiagent collision avoidance

BACKGROUND

Collision Avoidance with Deep Reinforcement Learning

首先,多智能体的避障,可以表述为在强化学习下的一系列行为决策 (a sequential decision making) 问题。

A multiagent collision avoidance problem can be formulated as a sequential decision making problem in a reinforcement learning framework.

  • 强化学习问题建模

这部分理论分析非常精彩,建议多阅读几次,理解深意。

  1. 为了刻画附近行人意图的不确定性 (uncertainty),将状态矢量分为可观察部分 (observable) 和不可观察部分 (unobservable)。其中,可观察部分包括行人的速度,位置和大小;不可观察部分,包括行人的目标位置,偏好速度和方向。

  2. 所以,模型的目标是开发一种策略,在避开和附近行人碰撞的基础上,最小化抵达目标的时间。

  3. 在此模型基础上,这个问题可以在强化学习框架下表述为和邻近行人的关联配置 (joint configuration)。另外,引入奖励函数,奖励那些抵达目标的智能体,惩罚那些发生碰撞的智能体。

    In particular, a reward function can be specified to reward the agent for reaching its goal and penalize the agent for colliding with others.

  • 状态转移函数模型,因为考虑了其他智能体的隐藏意图 (hidden intents),所以也简介考虑了其他智能体的行为不确定性。

    The unknown state-transition model takes into account the uncertainty in the other agent’s motion due to its hidden intents.

  1. 随后,解决这个 RL 问题就是找到表达到达目标点的预估时间的最优值函数 (the optimal value function),然后可以由值函数回溯得到最优策略 (optimal policy)。

Solving the RL problem amounts to finding the optimal value function that encodes an estimate of the expected time to goal.

然后,找到最优值函数的主要的挑战是,关联状态是连续的、高维的矢量,使得离散化和枚举状态空间不可行。

A major challenge in finding the optimal value function
is that the joint state sjn is a continuous, high-dimensional vector, making it impractical to discretize and enumerate the state space.

最近,可以使用深度神经网络来解决这个强化学习的问题,去表示高维空间的值函数,并且具有人类水平的表现。
Recent advances in reinforcement learning address this issue by using deep neural networks to represent value functions in high-dimensional spaces, and have demonstrated human-level performance on various complex tasks.

MC: 到目前为止,作者是在介绍自己已有的研究,the collision avoidance with deep reinforcement learning framework (CADRL),接下来会在这个基础上,引入多智能体间具有社交意识的行为。

最后,作者公开的实现代码 mit-acl/cadrl_ros 。

Characterization of Social Norms

与其直接去量化人类行为,本文认为复杂的规范行为模式,是由一系列简单的局部交互组成的。MC: 我赞同这个观点,可以把复杂的问题拆分为小问题,容易解决。

Rather than trying to quantify human behaviors directly, this work notes that the complex normative motion patterns can be a consequence of simple local interactions.

因此,本文进一步猜想,相比于一系列精确定义的规则 (a set of precisely defined procedural rules),社交规范是从相互避免碰撞的机制中新生的。

Thus, we conjecture that rather than a set of precisely defined procedural rules, social norms are the emergent behaviors from a time-efficient, reciprocal collision avoidance mechanism.

Reciprocity implicitly encodes a model of the other agents’ behavior, which is the key for enabling cooperation without explicit communication.

有点哲学感:局部避免碰撞中的互惠原则,衍生出来了所谓的社交行为规范。作者进一步实验表明,无规则的 CADRL 也可以展示出一定的导航规范。(可以作为 research hypothesis)

Reciprocity implicitly encodes a model of the other agents’ behavior, which is the key for enabling cooperation without explicit communication. While no behavioral rules were imposed in the problem formulation, CADRL policy exhibits certain navigation conventions.

所以,作者在这个基础上认为,通过多智能体的避碰学习,可以习得人类现在的行为规范。

已有的文献报道,人类导航趋向于合作和时间最优。所以,作者在 CADRL 基础上,通过引入最小时间奖励函数和互惠假设 (学习到的最优行为,智能体基本都会采用)。

Existing works have reported that human navigation (or teleoperation of a robot) tends to be cooperative and time- efficient. This work notes that these two properties are encoded in the CADRL formulation through using the min-time reward function and the reciprocity assumption.

同时,作者指出,从 CADRL 衍生的合作行为,和人类现有的理解是不同的。所以,作者会进一步解决这个问题。

However, the cooperative behaviors emerging from a
CADRL solution are not consistent with human interpretation. The next section will address this issue and present a method to induce behaviors that respect human social norms.

APPROACH

本章首先描述两个智能体如何在 RL 框架中塑造规范行为,然后将这一方法推广到多智能体场景。

We first describe a strategy for shaping normative behaviors for a two-agent system in the RL framework, and then generalize the method to multiagent scenarios.

Inducing Social Norms

和自己的解法基本是一致的,只不过没有使用神经网络罢了

现有的社交行为是众多解决对称避障的方法之一。为了引入一个特定的行为,就需要向 RL 中引入一点偏爱 (bias),更偏向于一组行为。

This work notes that social norms are one of the many
ways to resolve a symmetrical collision avoidance scenario. To induce a particular norm, a small bias can be introduced in the RL training process in favor of one set of behaviors over others.

如作者所说,这一方法的优点在于,违背特定性为的做法一般容易被识别,并且这一规范不需要精确。这是因为新增的惩罚打破了避碰的平衡和对称,所以会偏向于遵守社会规则的行为。

The advantage of this approach is that violations of a particular social norm are usually easy to specify; and this specification need not be precise. This is because the addition of a penalty breaks the symmetry in the collision avoidance problem, thereby favoring behaviors respecting the desired social norm.

最后,训练的结果表明学到了和人类行为类似的策略,比如 left-handed and right-handed norms。

As long as training converges, the penalty sets’ size does not have a major effect on the learned policy. This is expected because the desired behaviors are not in the penalty set.

Training a Multiagent Value Network

因为上文的训练只是在两个智能体之间,所以很难引入到更高阶的行为,比如多智能体环境。这部分主要讲述如何训练多智能体。

Since training was solely performed on a two-agent system, it was difficult to encode/induce higher order behaviors, such as accounting for the relations between nearby agents. This work addresses this problem by developing a method that allows for training on multiagent scenarios directly.

为了刻画多智能体对称的特性,本文使用了权重共享 (weight-sharing) 和最大池 (max-pooling layers) 的神经网络。该网络涉及 4 个智能体,其中附近三个智能体的状态可以互换而不影响训练结果。

网络结构的详细设计,可以阅读原文。

To capture the multiagent system’s symmetrical structure,
a neural network with weight-sharing and max-pooling layers is employed,

Network structure for multiagent scenarios

在训练中,会先生成轨迹,然后将轨迹转化为经验集。

The trajectories are then turned into state-value pairs and assimilated into the experience sets.

CADRL 和 SA-CADRL 的训练区别

  • Two experience sets are used to distinguish between trajectories that reached the goals and those that ended in a collision.
  • During the training process, trajectories generated by SA-CADRL are reflected in the x-axis with probability.
    • This procedure exploits symmetry in the problem to explore different topologies more efficiently.

作者在网络训练时已经设置开关 (a binary flag indicating whether the other agent is real or virtual (details),所以 n - 智能体的网络也可以用于 p (p<=n) 个智能体的场景。

An n-agent network can be used to generate trajectories for scenarios with fewer agents.

RESULTS

Computational Details (online performance and offline training)

模型具有比较优秀的实时和收敛 (convergence and time-efficient) 表现。

The size and connections in the multiagent network are tuned to obtain good performance (ensure
convergence and produce time-efficient paths) while achieving real-time performance.

Simulation Results

三组对比试验:一组没有社交行为奖励函数,另外两组是偏向左和右的行为奖励函数。

Three copies of four-agent SA-CADRL policies were
trained, one without the norm inducing reward, one with the left-handed, and the other with the right-handed.

Hardware Experiment

硬件设备

  • The differential-drive vehicle is outfitted with a Lidar for localization, three Intel Realsenses for free space detection, and four webcams for pedestrian detection.

A hardware demonstration video can be found at here.

CONCLUSION

Contribution

  • In a reinforcement learning framework, a pair of simulated agents navigate around each other to learn a policy that respect human navigation norms, such as passing on the right and overtaking on the left in a right-handed system.
  • This approach is further generalized to multiagent (n > 2) scenarios through the use of a symmetrical neural network structure.
  • Moreover, SA-CADRL is implemented on robotic hardware, which enabled fully autonomous navigation at human walking speed in a dynamic environment with many pedestrians.

Future work

[toc]

文献下载地址

这篇论文主要研究如何在人行道上给机器人导航。论文根据人行横道上行人的多与少,来使用两种不同的算法为机器人导航。在行人密集 (pedestrian-rich) 的环境下,使用 Group Surfing 方法,模仿前方的行人,以遵守规则 (socially-compliant) 的行为来避开行人和障碍物,并最后抵达目的地;在行人稀疏 (pedestrian-sparse) 的环境下,通过检测马路沿,沿着马路沿导航。在这两种算法下,底层的避障模块是有模仿人类倾向 (human-aware)。最后,作者在仿真和实物上均验证了算法。

总体而言,这篇文章跟踪行人的思路比较好,算法实现细节清楚,在算法验证阶段有条理,总体质量比较高。

多平台维护不易,内容实时更新于个人网站,请移步阅读最新内容。

INTRODUCTION

本文的一个侧重点是,人机交互,强调机器人尽量不影响行人的行为,或者以人的方式去交互。所以,研究目标不是一个简单的 (类似于最短路径) 求最优解的问题。

首先,这篇文章的应用场景是人行道 (Sidewalk),导航空间在路旁,行人的方向大概是两个线性的。

Sidewalks present a unique yet challenging environment in that the navigable space combines elements of both roads and free indoor spaces. Often sidewalk motion is restricted to two linear directions and the resulting navigable space is limited, like on roads.

问题的复杂性在于,行人的活动比较随机,可能聚团 (group) 一起走。

However, pedestrians generally do not walk in perfect queues. Instead, people tend to walk in groups of variable sizes and speeds and move along with a general self-organizing crowd flow.

人行道导航 (sidewalk navigation) 的特点是,必须考虑行人的随机行为,同时遵守一定的社会规则,比如行人的交互常识 (pedestrian conventions),人际距离学 (appropriate proxemics),即行走方向保持的距离比垂直方向的距离要远。

Compared to autonomous road navigation, sidewalk navigation must also account for stochastic human movement that necessitates dynamic obstacle avoidance. Furthermore, certain social rules, such as walking in lanes or affording more space in the direction of walking than in the perpendicular direction, are rules that a robot should follow as well.

已有的研究方法有推理 (reasoning) 和学习 (learning),或者两者的结合。社会规则 (Social rules),在推理方法中作为代价函数,或在学习方法中作为奖励函数。

In general, methods are based on either reasoning, learning, or a combination thereof.

已有方法的局限性在于,利用对行人意图的理解,通常适用于开放环境 (open environments),而本文的研究问题是有限制的人行道环境,同时没有考虑人行横道的物理边界,机器人的运动会影响行人流等。

Here, the aforementioned approaches may be less effective as they do not account for the physical sidewalk boundaries, or how robot movement will affect pedestrian flow.

所以,本文的主要研究问题是如何考虑附近行人的行为和行人流,机器人最终抵达终点。

The key research question this paper considers is how mobile robots can utilize nearby pedestrian behaviours and flows to navigate towards a global goal.

针对这个问题,作者给出的答案是,模仿行人的行为。当检测到有行人朝向机器人的终点时,会允许机器人模仿并从用行人的社交行为。

When our navigation stack detects people moving towards the robot’s goal, a ‘group surfing’ behaviour is used. This allows the robot to imitate and participate in pedestrian social behaviours.

在行人稀疏或者简单的人行道,距离人行道的路沿一段距离,沿着这个向目标走 (trajectory following)。

In an unpopulated and simple sidewalk environment, the default behaviour is to follow a trajectory offset from the sidewalk curb towards the goal.

SYSTEM

系统的设计比较中规中矩,有新意的是,在航路点外,生成动态的子目标点 (subgoals)。

示意图

  1. 首先利用 Google Maps’ API 去生成高层次的航路点 (waypoint);
  2. 导航模块 (sidewalk navigation module) 根据附近是否有行人流 (nearby pedestrian flow) 来采用 group surfing 或者 sidewalk following 方法。
  3. 无论哪种方法,对外输出是子目标点 (subgoals),这是避障算法的输入,最后输出速度矢量 (velocity command) 指令,控制机器人的运动。
  4. 周期轮训,是否抵达当前目标点。

METHODS

Group Surfing

核心思路和目标:模仿人类的自然行为,包括沿路行走 (walking in lanes),避障 (avoiding collisions with other pedestrians or obstacles),路口等待 (waiting at intersections to cross),不走入交通中 (not walking into traffic)。类似于仿生学,这次模仿的只不过是人类自己罢了。

  1. Filter Candidate Groups
  • 过滤那些远离航路点的行人组。

Filter out groups moving away from the waypoint.

  • 重点解释下,$[v_{G_{i}}\cdot x_{I}]$ 的意义。在我看来,这个并没有物理意义,作者只不过想利用向量点乘的正负来判断行人是否在远离航路点。ps. 向量点乘的正负性取决于余弦角,只要两个向量的夹角小于 90 度 (向目标点靠近),就是正值。

If this value is non-positive, discard Gi as a subgoal candidate.

示意图

  1. Smart Group Selection
  • 方法核心思路和目标:从筛选后的行人组中,选择平均速度小于且最接近于机器人最大速度的作为最优跟踪组 (the optimal group to follow)。选择该组中距离机器人最近行人的当前位置作为子目标点 (subgoals)。

Once we have filtered out unsuitable groups, the algorithm selects the optimal group to follow.

  • 那么,路径规划和避障的问题就是在机器人当前位置和最优跟踪组的最近行人之间,规划出一条无碰撞的路径。

We intentionally select the closest person as a subgoal as attempting to reach the average group position could lead to path planning through pedestrians located between the average group position and the robot’s current position.

Curb Following

方法核心思路和目标:使用 3D laser sensor 采集点云,然后利用 Random Sample Consensus (RANSAC) 算法去识别马路沿。

We make use of contextual knowledge; sidewalks are normally surrounded by streets and buildings or empty space. Our robot first acquires a surrounding point cloud using a 3D laser sensor and filters out points that are at the same height as or above the plane defined by the robot wheel contacts.

Collision Avoidance

  1. Human-Aware Collision Avoidance
  • 在 group surfing 和 curb following 中,使用已有的学习方法,Socially-Aware Collision Avoidance with Deep Reinforcement Learning (SA-CADRL) 来作为避障算法。

Socially-Aware Collision Avoidance with Deep Reinforcement Learning (SA-CADRL), as the collision avoidance component of our navigation stack. The collision avoidance system navigates to a local subgoal generated by either the group surfing or the curb following approach.

  • 其中,引入社交奖励函数来鼓励社会行为。
    The reinforcement training process induces social awareness through social reward functions, which give higher values to actions that follow social rules.
  1. Static Obstacle Avoidance:
  • 把静态障碍物作为静态的行人,仍然使用 SA-CADRL 算法来处理。

We also use SA-CADRL to avoid these static obstacles by adding “static pedestrians” to the state vector.

SIMULATION DEMONSTRATION AND EXPERIMENTS For

仿真环境的构建:使用 ROS 和 Gazebo 仿真套件。

We use the Robot Operating System (ROS) and Gazebo simulator suite. To simulate pedestrians, we use the Pedsim ROS library, which relies on the social force model.

Simulation Demonstration

在虚拟环境中,以 GPS 校准,重新搭建了周围的环境,复制了机器人模型。

Simulation Experiments and Evaluation

目的:验证机器人可以沿着社会接受 (socially-acceptable) 的行为,最后抵达终点,即机器人的路径和行人的路径是相似的。

In evaluating our navigation system, our main goal was to show that the system successfully navigates the robot to its final goal through a socially-acceptable path. That is, the path that our robot takes to the goal is similar to what a pedestrian would take to the same goal.

首先,在虚拟环境中,使用提出的算法抵达终点;然后,文中引入对比试验,使用最短路径的方法抵达终点。

We tracked the path taken by the robot and the path taken by a simulated pedestrian. We also tracked the shortest path that the robot could take within the confines of the sidewalk.

现在,有三组轨迹,行人的真实轨迹,现有算法轨迹,最短路径的轨迹。本文使用 an independent samples t-test 等数学方法,比较两个轨迹和人类实际轨迹的相似度,来证明现有的算法更加符合人类的行为。

MC:赞一下,比较的有理有据。

HARDWARE DEMONSTRATION

Hardware Setup

机器人的配置如下:

We use the PowerBot from Omron Adept Mobile Robots as our differential drive mobile base. The robot is equipped with multiple sensors: a Velodyne VLP-16 3D LiDAR sensor; a SICK LMS-200 2D laser sensor; a RealSense RGB-D sensor, and GPS and IMU sensors. Our PowerBot’s max speed is 0.8m/s. This limits its capacity of following faster pedestrian groups.

Demonstration and Discussion

  • 使用 SPENCER 算法来识别行人和行人流。
  • 原打算使用 lidar 来识别行人的腿部,但是错误率太多,使用 SPENCER 提供的 RGB-D-based 的上身识别算法。
  • 对机器人局限的探讨,以及算法的不足之处,从工程的角度讨论。

CONCLUSIONS

待提高的地方:

  • For the group surfing component, one main area for improvement is in the selection process of groups to imitate.
    • Criteria: group velocity; group trajectory; group size
  • External observers of the group surfing behaviour will be interviewed to gauge if the imitation behaviour is socially acceptable.
  • For collision avoidance, a more specialized technique would allow for more efficient navigation.
  • We hope to decouple static collision avoidance from dynamic collision avoidance.
  • For curb following, our approach only works for sidewalks that limit directly to the street, ignoring common tree belt, median, hellstrip, etc. Our future plan is to introduce detection and recognition of these non-transitable areas and incorporate them in our navigation module.

[toc]

Background

Recently, I updated my Ubuntu version from 16.04 to 18.04, and I’d like to share my experience on how to build a work or study environment for yourself.

This blog mainly introduces how to install Sogou pinyin in non-Chinese versions of Ubuntu.

How to install Sogou pinyin

Firstly, you should install fcitx, a lightweight input method framework aimed at providing environment independent language support for Linux.

1
2
sudo apt install fcitx-bin
sudo apt install fcitx-table

You can also uninstall ibus, an input-method framework for Unix-like computer operating-systems.

1
2
sudo apt purge ibus
sudo apt autoremove

BTW, you can read Understanding & setting up different input methods if you are interested in the difference between fcitx and ibus.

Recall that:

remove - remove is identical to install except that packages are removed instead of installed. Note that removing a package leaves its configuration files on the system. If a plus sign is appended to the package name (with no intervening space), the identified package will be installed instead of removed.

purge - purge is identical to remove except that packages are removed and purged (any configuration files are deleted too). This of course, does not apply to packages that hold configuration files inside the user’s home folder.

what sudo apt autoremove actually does? Whenever you install an application (using apt-get), the system will also install the software that this application depends on. It is common in Ubuntu/Linux that applications share the same libraries. When you remove the appplication the dependency will stay on your system. So apt-get autoremove will remove those dependencies that were installed with applications and that are no longer used by anything else on the system.

You can subsequently open Language Suppor to double-check that Key board input method system has change from ibus to fcitx, and you can change it manuallyif not. You can ignore it and click the “Remind Me later” button if you are reminded that “The language support is not installed completely”.

Importantly, you must reboot your system after that.

After that, you can download the deb package from the official website, 搜狗输入法 for Linux, or here (also official links) directly.

You can install it in Ubuntu Software by double-clicking, shown as below.

Importantly, you must reboot your system again.

You can open fcitx config tool after rebooting, as you can see below. You should also see Sogou Pinyin in the lists. Unfortunately, if not, you can add it by clicking the + mark, choose Sogou Pinyin and reboot the system again.

Now, you should input Chinese characters at the same time. In other words, you can use it as convenient in Windows system, like the Shuangpin input method. Yeah, you can learn more detail about Shuangpin in 双拼学习.

Just enjoy Ubuntu 18.04.

References

Ubuntu Chinese Setup
How to install Sogou input on Ubuntu 16.04

How to install rtags for vim in Ubuntu 18.04 / 如何在 Ubuntu 18.04 vim 上安装 rtags 插件

This blog introduces how to install the best cross-reference tool, rtags, that I have ever used in vim, step by step. I hope it helps.

What’s rtags

Rtags is a client/server application that indexes C/C++ code and keeps a persistent file-based database of references, declarations, definitions, symbolnames etc. It allows you to find symbols by name (including nested class and namespace scope). Most importantly, it gives you proper follow-symbol and find-references support.

Rtags comes with emacs support but there are projects supporting other IDEs: vim-rtags and sublime-rtags.

In this blog, We would install vim-rtags later.

How to install rtags

First, you need clang, which is a compiler front end for the C, C++, Objective-C and so on. It uses the LLVM compiler infrastructure as its back end and has been part of the LLVM release cycle since LLVM 2.6.

1
2
3
4
// Commands in Ubuntu terminal
// sudo apt install clang-5.0 lld-5.0
// sudo apt install libclang-5.0-dev
sudo apt install llvm-7-dev libclang-7-dev

Secondly, make and install rtags as follows.

1
2
3
4
5
6
// Commands in Ubuntu terminal
git clone --recursive https://github.com/Andersbakken/rtags.git
cd rtags <-- in rtags directory
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 .
make
sudo make install

Thirdly, you should install vim-rtags in Vundle.vim. I think it’s the easiest way to install rtags plugin in vim.
You need to add the following line to .vimrc if you have installed Vundle, and then run :PluginInstall in vim.

1
Plugin 'lyuts/vim-rtags' <-- install in vim

Finally, the last but essential step is that forcing cmake to output compile_commands.json (like DCMAKE_EXPORT_COMPILE_COMMANDS) and link it with rtags according to your project.

1
2
3
cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=1 [***] your_src_path
rc -J your_build_folder_path <-- use compile_commands.json in your build folder
rdm & <-- launch the rtags server

[toc]

前言

在 Website FAQ,实现了使用 "卜算子" 来统计网站访问人数,但是 "卜算子" 仅可以提供访问人数的统计,进一步的信息却无法提供。那么,如果想知道过往访客来自哪些国家和地区,显示网站访问实时动态的信息,应该怎么做呢?

多平台维护不易,本博客实时更新于 个人网站,请移步阅读最新内容。

clustermaps 是什么

clustrmaps.com 是美国的一家数据网站,能够汇总公共记录来分析美国城市的社会人口和商业环境。

Add the ClustrMaps hit tracker to your site or blog and see a real-time map of your visitors from around the world! Proudly show and grow your hidden community of interest.

网址提供了生成访问者地址分布图的代码,可以嵌入到网站或博客中,来显示来自世界各地访问者的实时地图,有助于发展您隐藏的兴趣社区。最重要的是,这个功能是免费的,能够满足个人网站的需求,如下图所示。

配置 clustrmaps

  • 选择自己喜欢的插件格式,现在 Hexo 的 Next 两种主题都是支持的,但是自己比较喜欢 Map widget 的主题。

  • 点击选择后,拷贝网站出现的脚本 javascript 代码,粘贴到 Next 主题下某个位置。博主测试过如下两个位置,挑选一个配置即可以。推荐位置二,自定义程度高。
    • 位置一:将代码插入到 themes\next\layout\_partials\header.swig 的最后。
1
2
3
4
5
6
7
  {% endif %}
</nav>

<!-- Insert clustrmaps.com -->
<script type='text/javascript' id='clustrmaps' src='//cdn.clustrmaps.com/map_v2.js?XXX'></script>

{% include '../_custom/header.swig' %}
  • 位置二:将代码插入到 \themes\next\layout\_macro\sidebar.swig 文件的
    图层。
1
2
3
4
5
6
7
8
9
10
11
<aside class="sidebar">
<div class="sidebar-inner">

{%- set display_toc = page.toc.enable and display_toc %}

<!-- Begin Insert clustrmaps.com -->
<script type="text/javascript" id="clustrmaps" src="//clustrmaps.com/map_v2.js?d=iBmc9XXXXXX=a"></script>
<!-- End Insert clustrmaps.com -->

{%- if display_toc %}
{%- set toc = toc(page.content, { class: "nav", list_number: page.toc.number, max_depth: page.toc.max_depth }) %}
  • 重新部署网站,就可以在首页看到实时访客来源图,如我的网站首页所示。另外,点击地图,可以看到更详细的信息,包括访客的地图、浏览设备以及 IP。

0%