-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.json
1 lines (1 loc) · 134 KB
/
search.json
1
[{"title":"LIO_SAM mapping代码解析","date":"2023-05-10T07:10:18.166Z","url":"/2023/05/10/SLAM/8_LIO_SAM/","tags":[["SLAM","/tags/SLAM/"],["机器学习","/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/"],["LIO_SAM","/tags/LIO-SAM/"]],"categories":[["undefined",""]],"content":"LIO_SAM代码学习LIO_SAM全称是Lidar-Internal-Odometry Smoothing and Mapping,就是利用Lidar和IMU两个传感器进行融合得到Odometry,再输入到GTSAM库中构建图优化结构,从而实现Mapping。本学习新的参考以下博客,对我帮助非常大。LIO_SAM代码注释详解LIO_SAM工程LIO_SAM论文地址同时也参考了从知乎中LIO_SAM代码详解整体的流程在github中也给出了,很好地解释了如下图:从中我们可以看到整体代码是非常轻量级的,一共只有四个cpp文件,对应四个功能: 1. ImageProjection.cpp:激光运动畸变校正。利用当前帧起止时刻之间的IMU数据、IMU里程计数据计算预积分,得到每一时刻的激光点位姿,从而变换到初始时刻激光点坐标系下,实现校正。这是整个LIO-SAM系统的输入,包括imuHandler和cloudHandler,imuHandler直接存入到imuQueue中,但是cloudHandler中需要进行畸变校正,下面对代码进行分析: 订阅原始lidar数据 1、添加一帧激光点云到队列,取出最早一帧作为当前帧,计算起止时间戳,检查数据有效性 2、当前帧起止时刻对应的imu数据、imu里程计数据处理 imu数据: 1) 遍历当前激光帧起止时刻之间的imu数据,初始时刻对应imu的姿态角RPY设为当前帧的初始姿态角 2) 用角速度、时间积分,计算每一时刻相对于初始时刻的旋转量,初始时刻旋转设为0 imu里程计数据: 1) 遍历当前激光帧起止时刻之间的imu里程计数据,初始时刻对应imu里程计设为当前帧的初始位姿 2) 用起始、终止时刻对应imu里程计,计算相对位姿变换,保存平移增量 3、当前帧激光点云运动畸变校正 1) 检查激光点距离、扫描线是否合规 2) 激光运动畸变校正,保存激光点 4、提取有效激光点,存extractedCloud 5、发布当前帧校正后点云,有效点 6、重置参数,接收每帧lidar数据都要重置这些参数void cloudHandler(const sensor_msgs::PointCloud2ConstPtr& laserCloudMsg){ // 添加一帧激光点云到队列,取出最早一帧作为当前帧,计算起止时间戳,检查数据有效性 // 这里是检测header是否符合要求,默认是velodyne格式,目前使用pandar的时候会遇到时间对不上的问题。 if (!cachePointCloud(laserCloudMsg)) cachePointCloud // 当前帧起止时刻对应的imu数据、imu里程计数据处理,需要保证时间同步 if (!deskewInfo()) deskewInfo projectPointCloud cloudExtraction } 2. FeatureExtraction.cpp提取特征。对经过运动畸变校正之后的当前帧激光点云,计算每个点的曲率,进而提取角点、平面点特征。同样的,这部分的代码直接从上一部分得到的topic中进行输入,从laserCloudInfoHandler进行分析: 订阅当前激光帧运动畸变校正后的点云信息 1、计算当前激光帧点云中每个点的曲率 2、标记属于遮挡、平行两种情况的点,不做特征提取 3、点云角点、平面点特征提取 1) 遍历扫描线,每根扫描线扫描一周的点云划分为6段,针对每段提取20个角点、不限数量的平面点,加入角点集合、平面点集合 2) 认为非角点的点都是平面点,加入平面点云集合,最后降采样 4、发布角点、面点点云,发布带特征点云数据的当前激光帧点云信息void laserCloudInfoHandler(const lio_sam::cloud_infoConstPtr& msgIn){ cloudInfo = msgIn; cloudHeader = msgIn->header; // 当前激光帧运动畸变校正后的有效点云 pcl::fromROSMsg(msgIn->cloud_deskewed, extractedCloud); // 计算当前激光帧点云中每个点的曲率,跟LOAM中一样 calculateSmoothness(); calculateSmoothness // 标记属于遮挡、平行两种情况的点,不做特征提取 markOccludedPoints(); markOccludedPoints // 点云角点、平面点特征提取 // 1、遍历扫描线,每根扫描线扫描一周的点云划分为6段,针对每段提取20个角点、不限数量的平面点,加入角点集合、平面点集合 // 2、认为非角点的点都是平面点,加入平面点云集合,最后降采样 extractFeatures(); extractFeatures } 这两个部分跟前面的LOAM基本上是相同的,我们只需要知道它输入是雷达点云,即config.yaml中的lidar_topic,输出则是publish到/lio_sam/feature/cloud_info中同时也会发送到后面的程序。 前面两个模块还很好理解,从这里开始就开始非常复杂了。 3. IMUPreintegration.cppIMU预积分模块,在该预积分模块中有两个类: lidarOdometryHandler类订阅激光里程计(来自MapOptimization,lio_sam/mapping/odometry)和IMU里程计(odomTopic+”_incremental”,来自ImuPreintegration类),根据前一时刻激光里程计,和该时刻到当前时刻的IMU里程计变换增量,计算当前时刻IMU里程计(odomTopic);rviz展示IMU里程计轨迹(局部)。 在该类中,定义了两个handler,lidarOdometryHandler (2) imuOdometryHandlervoid imuOdometryHandler(const nav_msgs::Odometry::ConstPtr& odomMsg) 而对于IMU里程计,是通过上一帧时刻中的激光里程计对应的imu里程计位姿,以及当前imu位姿算出imu的增量,最后得到当前时刻的imu里程计位姿// 最近的一帧激光里程计时刻对应imu里程计位姿 Eigen::Affine3f imuOdomAffineFront = odom2affine(imuOdomQueue.front());// 当前时刻imu里程计位姿Eigen::Affine3f imuOdomAffineBack = odom2affine(imuOdomQueue.back());// imu里程计增量位姿变换Eigen::Affine3f imuOdomAffineIncre = imuOdomAffineFront.inverse() imuOdomAffineBack;// 最近的一帧激光里程计位姿 imu里程计增量位姿变换 = 当前时刻imu里程计位姿Eigen::Affine3f imuOdomAffineLast = lidarOdomAffine * imuOdomAffineIncre; 从这后面的代码是发布当前里程计的位姿,坐标系变换关系以及其位姿的路径。 ImuPreintegration类这里面同样也订阅了两个topic,关于激光里程计的(lio_sam/mapping/odometry_incremental,注意这里有incremental)以及IMU里程计(imuTopic),而输出是IMUodometry(odomTopic+”_incremental”)用激光里程计,两帧激光里程计之间的IMU预计分量构建因子图,优化当前帧的状态(包括位姿、速度、偏置);以优化后的状态为基础,施加IMU预计分量,得到每一时刻的IMU里程计。 (1) imuhandler这里的imu是Topic是原始数据,是真正的imu里程计,即odomTopic+”_incremental”。用上一帧激光里程计时刻对应的状态、偏置,施加从该时刻开始到当前时刻的imu预计分量,得到当前时刻的状态,也就是imu里程计imu里程计位姿转到lidar系,发布里程计。 (2) odometryhandler这里从mapping节点中得到的激光里程计(lio_sam/mapping/odometry_incremental)进行分析。这里最重要的是利用gtsam库构建图优化因子,来进行计算。 使用ISAM2优化器对各个因子以及imu数据进行初始化使用ISAM2优化器对各个因子以及imu数据进行初始化 初始化后,他执行三个步骤: 每隔100帧激光里程计,重置ISAM2优化器,添加里程计、速度、偏置先验因子,执行优化第100帧时的代码 2、计算前一帧激光里程计与当前帧激光里程计之间的imu预积分量,用前一帧状态施加预积分量得到当前帧初始状态估计,主要是利用gtsam库进行分析,这里主要是对imu预积分模块输入imu预积分模块输入 在这里,我们得到了 prevState_,就是四元数加上方位角,接下来进行优化 3、优化之后,执行重传播;优化更新了imu的偏置,用最新的偏置重新计算当前激光里程计时刻之后的imu预积分,这个预积分用于计算每时刻位姿优化之后更新预积分器和计算预积分 4. MapOptimization.cpp主类mapOptimization 可以看到输入主要是两个一个是激光特征点云,另一个是gps的里程计(gps的输入),我们分析数据流先从输入开始,先看这两个输入的handler函数做了什么。(1)laserCloudInfoHandlerlaserCloudInfoHandler// 提取局部角点、平面点云集合,加入局部map// 1、对最近的一帧关键帧,搜索时空维度上相邻的关键帧集合,降采样一下// 2、对关键帧集合中的每一帧,提取对应的角点、平面点,加入局部map中 extractSurroundingKeyFrames(); // 当前激光帧角点、平面点集合降采样downsampleCurrentScan(); scan2MapOptimization(); transformUpdate(); saveKeyFramesAndFactor(); (3)闭环检测。在历史关键帧中找候选闭环匹配帧,执行scan-to-map匹配,得到位姿变换,构建闭环因子,加入到因子图中一并优化。 "},{"title":"N1文法","date":"2022-12-15T08:15:40.192Z","url":"/2022/12/15/nihongo/nihongo/","tags":[["日语学习","/tags/%E6%97%A5%E8%AF%AD%E5%AD%A6%E4%B9%A0/"],["N1","/tags/N1/"]],"categories":[["undefined",""]],"content":"N1 文法1. ~も同然だ意味:ほとんど~ と同じだ。同じ様子だと言いたい。接続:名詞(も)+同然だ、ないも同然だ、動詞た形も+同然だ。 例: (1):毎日二十時間半年もN1を勉強したんだから、合格したも同然だ。因为半年来每天学习20小时的N1,跟已经合格了已经一样了。个人理解:这里的同然だ就是理所当然的意思,有因果关系导致的结果虽然还没发生,但是在说话人眼里已经发生了,理所当然会发生。 (2):彼女と三年間一緒に住んでたから、これは結婚生活も同然だ。跟女朋友一起住了三年,这跟结婚生活没有区别了。个人理解:这里的同然だ与同じだ区别不大,重点是前面有一个これは,意思是二者已经相同了,差别不大的意思。 (3):会社からものを借りて返さないのは、泥棒同然だと思います。借公司的东西不还,我认为跟小偷没有区别。个人理解:这里的同然だ指的是同样有两件事,将“借东西不还”跟小偷作比较,二者相同的意思。 (4):この医者じゃら手術をもらえば、完治したも同然だ。如果这个医生给我做手术的话,就等于是医治好了。个人理解:同样的,这里也有如果这个因果关系,跟前面的から也是差不多的,有点类似虚拟语气的感觉。 (5):あなたは家族同然ですよ。你跟家人一样了。个人理解:这里二者需要本质不能是确认关系,本来不是家人的情况下,跟家人一样,前面可以有原因等等支持。 2. とは意味:意外な気持ちを強く表す。残念や驚きを言いたい場合は使える。接続:名詞(も)+とは、い形容詞+とは、な形容詞(だ)+とは動詞普通形+とは。 例: (1):あんな静かな由香先生があんなに怒るとは、何があっただろう?这样安静的由香老师居然这么生气,发生了什么呢?个人理解:对“安静的由香老师居然这么生气”具有惊讶的感觉,所以为とは,表示强调自己很惊讶,很意外。普通就是のは,没有这么强调自己的表达感情。 (2):おとながこどもに負けるとは、情けない!大人输给小孩这件事,太可耻了!个人理解:同样的对“大人输给小孩”表示惊讶,也有遗憾等意外的感情 (3):あいつが由香先生とデートするとは!这人跟由香老师居然约会了!个人理解:同样的对这人跟由香老师约会了这件事很惊讶,完全没想到。 (4):あんなに家族と仲良くしてる人に、愛人がいるとは想像もできない。跟家里人关系这么好的人,居然有情妇是想象不出来的。个人理解:同样前面添加了一个条件,后面有情妇是意外的,想象不出来的。 3. ~に越したことはない意味:~のほうがいい、最高だ接続:名詞(である)に、い形容詞、な形容詞(である)、動詞普通形+に越したことはない。 例:(这个词组很好理解,不解释了,注意这些接的词都是要接个に) (1):会社は近いに越したことはない。离公司近是最好不过了。 (2):結婚相手は、子供好きの男性に越したことはない离公司近是最好不过了。 (3):成功のために、好きなことをやるには越したことはない。要成功的话,做自己喜欢的事情是最好不过了。 (4):初デートの終わりはキスに越したことはない。初次约会以吻来结束是最好不过了。 4. aいかん「によって」(で、では)、b bはaいかん「だ」(による、にかかっている)意味:aが、どれぐらいか、どのようなものかによって、Bが決まるa怎么样,是什么样的、来决定b是怎么样的,a是条件接続:名詞+(の)+いかんによって 例: (1):N1合格は君のやる気いかんによると思うよ。我觉得N1的合格取决于你的干劲。个人理解:いかんによる前面接的是条件,可以翻译成取决于,虽然N1合格放在了前面,但是这个词组接的就是条件。 (2):明日の天気いかんいよっては、試合は中止するかもしれない。看明天的天气如何,可能会中止比赛。个人理解:虽然后面这个终止比赛表示b,前面的明天天气是a,可能终止比赛就是一个可能的结果,取决于明天的天气。 (3):筆記試験いかんで、面接が決まります。笔试怎么样,决定你能否进入面试。个人理解:这个“面试”在这里是b,同样也只是其中一种结果,就是可不可以面试取决于笔试过没过。 5. aいかん「によらず」(にかかわらず、をとわず)、b意味:aとは関係なく、Bは決まっている不管a怎么样、b都决定了接続:名詞+の+いかん「によらず」(にかかわらず、をとわず)。 例:很好理解,注意前面是名词要加の,a是要有两种以上的不确定性 (1):お支払いになった会員料は理由のいかんによらず、お返しすることができません。已经支付了的会员费不管什么理由,都不能返还。 (2):結果のいかんによらず、今回の大会に参加できたことに価値を感じております。不管结果如何,我都感受到了参加这次比赛的价值。 (3):会議の参加、不参加のいかんによらず、明日までは報告集を提出しなきゃいけない。不管参不参加会议,明天之前都必须要提交报告书。 6. aずにはおかない、 aないでおかない意味:絶対にaにする、自然に(感情)になる绝对要做a这件事,这件事变成这样是很自然的,很应该的。接続:動詞のない形+ずにはおかない。 例: (1):犯罪を見たら、警察に通報せずにはおかないだろう。见到犯罪的话,就应该绝对要报警。个人理解:ない形接おかない就是不做什么是不行的,但是中文翻译的话有点强迫的意思,其实更应该是主动的。 (2):あの映画俳優が出演したから、この映画は観客を泣かせずにはおかないはずだ。因为那个电影演员出演了(这部戏),这个电影不让看了的人落泪是不可能的。(这个电影让看了的人流泪是必然的) (3):子供の非行は親の心を傷つけずにおかなかった。孩子做错事让父母伤心是自然的吧。个人理解:这里这样说更像是一些常理性质的事情也可以用这个句型。 (4):高額の美術品を壊したから、彼に弁償させずにはおかない。破坏了高价值的美术品的话,让他赔偿是无可厚非的。个人理解:这里同样是用了使动的动词,与上一句中傷つけ也是类似的,也是一个很自然的事情吧。 (5):自分が悪いのに逆切れしてる社員を叱らずにおかないぞ明明是自己的错还要反咬一口的职员肯定要被训斥的。个人理解:这里是用了被动的动词,这里没有用は,就是说ずにおかない也是可以的。 7. aずにはすまない 、 aないではすまない意味:aの状態をけっして許さない字面翻译就是不a的话不能完成(不能结束、或者说要道歉),就是绝对不能允许a的发生或者状态,比较客观接続:動詞のない形+ずにはすまない。動詞のない形+ないではすまない。 例: (1):父が入院したから、お見舞いにいかずにはすまない。父亲入院了,一定要去看望他。个人理解:表示一些必须要做,如社会氛围,伦理等让你必须去做的。如果不做就是不对的这样的程度。 (2):人に迷惑をかけたら、あやまらずにはすまないと思うよ。给人带来麻烦的话,不道歉是不行的。个人理解:这个就是一些社会氛围和规则,道德上导致你必须做的事。 (3):あの政治家は税金を私用に使ったわけだから、引退せずにはすまない。弹幕:这里面说的是比较像have to,也是客观地说这件事是不被允许的,不被接受的。 (4):病院は生命に対する倫理意識がなければ、いろんな問題を引き起こさずには済まないだろう。病院如果没有生命伦理意识的话,一定会引起各种各样的问题吧。个人理解:这里有个双重否定,翻译是变成了肯定,双重否定就会是,不发生各种问题是不行的。中文里很怪。 8. aを禁じ得ない意味:aを我慢できない 不禁。。。 但是跟我不能忍受意味有点区别,更加主观接続:名詞+を禁じ得ない 例: (1):先生の変顔に笑いを禁じ得なかった。对着老师的鬼脸我不禁笑了理解:正常用法,禁じ得ない前面用名词性 (2):日本の料理文化に対する海外での人気の高さに驚きを禁じ得ないよ。日本料理文化在海外的人气之高,不禁感到惊讶。理解:这里的不禁也是指个人感情,惊讶这件事情也是个人的想法。 (3):こんなバカな行政政策に対して、今の国民たちは不満を禁じ得ないです。对于这样愚蠢的政策,现在的国民都不禁表达出不满。 9. aてやまない意味:すごくaを願っている 非常想要a,由衷地,。。。。到不行 的意思接続:動詞て+やまない 愛してやまない娘のさらんちゃん喜欢到不行的女儿萨兰酱。理解:这里的やまない。。就有点类似于做什么停不下来,。。到不行的意思,就是表达非常,由衷地意思。 N2合格後、日本語の勉強をやめたことに後悔してやまないです。N2合格了以后,非常后悔自己停止学习了日语。理解:同样地,这里表达的是一种主观的感受,加强自己的后悔程度。 娘の伸びる英会話を見て、将来を期待してやまない。看了女儿的不断变强的英语会话,非常期待她的将来 みなさんがN1に合格するのを願ってやみません。我由衷地希望大家都能N1合格。 10. ~といったらない、~といったらありはしない、~ったらない、~といったらありゃしない意味:とても~だ、すごい~だ、言葉でうまく言えないほど~字面意思是说起来~的话就不是,很难字面意思理解,就理解成难以言喻就可以了,是一个中性词汇接続:名詞+といったらない あのラーメン屋の汚さといったらない。那个拉面店太脏了理解:这里就是难以言喻地脏。 エディ レッドメインの格好良さといったらなありはしない。エディ レッドメイン帅的难以言喻。 しまかわ先生は優しいったらない。岛川老师非常温柔 11. ~極まる ~極まりない意味:とても~だ。極限に~だ。同样是表达非常的意思 这个表达很极端,在一个量度上非常的高,到达了极限的意思接続:い形容詞+こと極まる/極まりない な形容詞+(なこと)極まる/極まりない 彼の失礼極まりない態度にがまんてきない。我忍受不了他这非常无礼的态度。理解:这个词的用法是接在形容词后面的,是对该形容词程度的描述。 あんな速度で交差点にはいるなんで危険極まりない行為である。用这样的速度进入十字路口是非常危险的行为。理解:这里这个词比とても要重,也要高级一些。 彼の迷惑極まりない行為に大学は退学処分を下した。大学对他这个非常迷惑的行为下达了退学处分。理解:同样的这里加重了他的迷惑程度。 いつも飲み会でセクハラに近い行為をする社長に不愉快極まる。对在酒会做出很像性骚扰行为的社长非常的不愉快。 12. ~極みだ意味:とても~だ。極限に~だ。同样是表达非常的意思 这个是名词的用法接続:名詞+の極みだ 和有限的名词组合使用的方式更多 飛行機が墜落して、多くの方がなくなり、悲痛の極みだ。飞机坠落了,死了很多人,感到非常的悲痛 大事な試合の最後に、逆転されてしまい、痛恨の極みだ。重要的比赛在最后被逆转了,非常地痛心悔恨。 13. ~至りだ意味:とても~だ。極限に~だ。同样是表达非常的意思 这个是名词的用法(也是一样的意思,只是以前用的更多)比较正式的用法接続:名詞+の至りだ 有限的名词组合使用的方式更多 ノーベル賞の授賞式に自分が出るなんて、光栄の至りでございます。我能出席诺贝尔颁奖仪式,感到非常的光荣(荣幸之至)理解:这里光栄の至り 若気の至り 感激の至り 赤面の至り 汗顔の至り是一个固定搭配 最近は若気の至りによる、軽犯罪が増えている。最近因为年轻气盛的情况,轻犯罪增加了若気の至り 这里是非常年轻,引申至太过年轻,什么都不知道的意思(弹幕说这个是血气方刚,年轻气盛) 皆様から、こんなサポートを頂けるなんて感激の至りでございます。从大家得到这样的帮助,真的非常感激! 忘年会で酔いつぶれてしまい、赤面の至りです。在年会上醉倒了,感到非常惭愧。 とんだミスをしてしまい、誠に汗顔の至りでございます。做了很大的失误,真的很惭愧。 14. ~ことこの上ないだ意味:とても~だ。これ以上なく。表达的意思是非常,在这之上没有别的了,对形容词进行修饰,表示~的东西是最好的接続:い形容詞+ことこの上ないだ な形容詞な+ことこの上ないだ 丁重なことこの上ない歓迎をいただきありがとうございました。得到非常由衷的欢迎实在是非常感谢。理解:类似于最高级的感觉,因为意思是【没有比他更】的意思。 箱根の紅葉は、きれいなことこの上ないものであった。箱根的红叶,没有比这个更漂亮的东西了。 留学して一人暮らしを始めると、寂しいことこの上ないものだ。开始了一个人的留学生活,没有比这更寂寞的了。 15. ~限りだ意味:とても~だ。限界まで~だ。接続:い形容詞+限りだ な形容詞な+限りだ和表达感情的表现一起使用为多 如开心 寂寞 伤心等 ノベール賞をおらうなんて、嬉しい限りです。得到了诺贝尔奖,非常开心!理解: ハワイにいくんだって、羨ましい限りです。去了夏威夷啊,真的非常羡慕了。 ビジネスの本を一冊も読まずに、しごとをおこすなんて恐ろしい限りです。商业的书一本都没看完,要做工作的话非常害怕。 16. ~てかなわない意味:~がひどすぎて、我慢できないかなわない=がまんできない多数在想要表达不满或者有意见的场合使用接続: Vて+かなわない い形容詞+てかなわない な形容詞+でかなわない 名詞+でかなわないて形+ 毎日こんな寒くちゃかなわない。每天都这么冷真的受不了了。理解:这里的ては变成了ちゃ,冷是不满的负面的意义 今日バイト3人も休まれてかなわないよ。今天打工三个人都休息了受不了了。 暴走族のバイクの音がうるさくてかなわないわ。真的受不了暴走族摩托车的嘈杂声。 みすずせんせいの顔を見ると、可愛すぎて授業に集中できなくてかなわないわ。看了美玲老师的样子,太可爱了不能专心上课受不了了。 17. ~まい、~まいと意味:「まい」絶対~しない、~しないだろう 「まいと」絶対~しないという接続: Vる+まい/まいと この難病は治るまい。这个重病治不好的吧。理解:这里有很难,非常难的意思,是说话人表达的主观意念。 ベトナムはもう電車ができたから、じゅうたいするまい。越南已经可以坐电车了,塞不了车了。 昨日から二度と酒を飲むまいと決心した。昨天起就下定决心不第二次喝酒。理解:这里有绝对不做~的意思。 もう親からの世話はいるまいと、独立を決めた。已经不需要父母的照顾了吧,决定要独立生活了。理解:这里的了吧意思可以是一个主观意念认为不需要了。 怖い映画をみて、叫ぶまいと我慢した。看了恐怖电影,我忍着不叫出来。理解:主观意念要不做这个事~。这里的と可以表示为(为了绝对不。。。) 18. ~べからず意味:するべきではない 不应该做~某事 引申为禁止做某事接続: Vる+べからず するべからず/すべからず看板に書かれている場合が多い、会話では使わない。多为写在公告栏上,日常会话不使用。 産業廃棄物を山に捨てるべからず 工業汚水を川に流すべからず 山にゴミをすてるべからず 野生動物出没。この先はいるべからず 関係者以外立ち入るべからず 19. ~べからざる跟上文同义,在老书中比较常见,读到了知道意思即可 戦争は、どんな理由があっても、許すべからざる国際的な犯罪である。 天空の城ラピュタは世界のアニメでは欠くべからざる名作である。欠くべからざる 不可或缺 妻に言うべからざる言葉に覚えておかないと離婚されかねない。记不得跟妻子说了什么不应该说的话就可能会被离婚了。 20.~ではあるまいし/じゃあるまいし意味:~ではないのだから。 即使是。。。也 又不是~(所以没必要—)注意やアドバイスをするときよく使う 经常用于提醒或者建议目上の人には使えない。 不能对的上司,长辈使用接続: 名詞+ではあるまいし Vる+わけ/の/ん+ではあるまいし Vた+わけ/の/ん+ではあるまいし 子供ではあるまいし、そんな馬鹿な事をするな。又不是小孩子了,不准做这样的事。 大学生ではあるまいし、電話対応が下手すぎるわ。又不是大学生了,回复电话太不熟练了。 難しい英語の原稿を読むのではあるまいし、たくさん練習しましょう。又不是读很难得英文原文,多多练习吧。 21.AべくしてBした意味:Aになるのは当然だからBする。 A是必然的话那就做BAとBが同じ場合が多い。「AなるべくBした」をよく使う。 接続: Vる+べくして 全然勉強しないからN1に落ちるべくして落ちた。因为完全不学习,N1过不了是必然的所以没过。理解:表示一种必然性,强调结果会必然发生。 ここには交通標識一つもなかったから、今回の事故は起こすべくして起こった事件であった。这里一个交通标识都没有,这次发生的事故就必然地发生了。 あなたとは結婚すべくして結婚した。和你结婚是必然的所以已经结婚了。 22.~べくもない意味:当然~だから、~しなくてもいい 因为~是必然的所以不~也可以 没有必要。。同样表示成一种没有可能,必然性的,多表否定。接続: Vる+べくもいない する+べくもない/すべくもない アップルがうちより大きい会社ということは、比べるべくもありません。我们公司跟那些大公司相对而言,经常使用苹果电脑这件事是没法比的(没有必要去比)。 アメリカが韓国より広いことが比べるべくもないね。美国跟韩国比起来,比领土大小是没必要的(不可能的)。 主力メンバーが五人も抜けているから、勝つことは望むべくもない。主力人员已经被抽掉五个了,赢已经不指望了() このお金が偽札ということは、一般人である私には知るべくもないことである。这个钱是假币这件事,我作为一般人是不会(不可能)知道的 23.~のではあるまいか。意味:~のではありませんか。 是不是~? 难道是~这样的吧 有不确定性~なのではないだろうか。接続: Vる+のではあるまいか い形容詞+のではあるまいか な形容詞/名詞+なの+ではあるまいか 彼は国に帰ったのではあるまいか。他是不是回国了呢。 雨がずっと降らないから今年は凶作ではあるまいかと首相は心配している。一直不下雨首相一直担心今年会不会变成歉收呢。 お葬儀でにこにこしているのは、失礼なのではあるまいか。在葬礼上笑嘻嘻的,不是很失礼吗? この野菜は農薬がたくさん使われたのではあるまいか、と思うほどきれいだ。这个蔬菜是不是用了大量农药呢,这么漂亮的蔬菜的话。 あの二人は付き合っているのではあるまいか、と疑うほどいちゃついている。这两人互相打闹得让我怀疑这两人是不是已经在交往了呢。 24. 组合记忆词组意味:Aがおきます その後すぐにBがおきます。A发生了以后马上B就发生了| | AそばからB | AなりB | Aが早いかB | Aや否やB || —— | —— | —— | —— | —— ||とき| 過去のこと | 過去のこと | 過去のこと | 過去のこと ||AとBの関係| Bがよくないこと | Bがよくないこと | AとBが同時に | AとBが同時に ||主語| AとB 同じ | AとB 同じ | 異なってもOK | 異なってもOK ||回数| いつも | 1回 | 1回 | 1回 ||意志動詞 無意識動詞| 両方 | 両方 | Bが意志動詞だけ | 両方 | (1) AそばからB意味:Aしたら、またすぐBの状態になります。接続: Vる/Vた+そばから Vたの場合が多い 文句や不満をいう場合よくつかう ときはいつも いつも同じ結果になる 1回で使えません このブランドのカバンは店内に置いたそばから、売りけれてしまう这个牌子的包包放在店里以后,马上就卖完了。 娘は新しい服を着たそばから、服を汚す。女儿穿上新的衣服以后,马上就弄脏了。 うちの子は部屋を片付けたそばから、おもちゃを散らかす。我家的孩子在收拾好房间后,马上又把玩具乱放了。 英語は難しい。新しい単語を見たそばから、忘れてしまう。英语太难了。看了新单词马上就忘了 (2) AなりB意味:Aしたら、すぐBの状態になります。接続: Vる + なり 一回に限る出来事。 Bには意志や命令文は使えない。 Bはネガティブな場合が多い。 常表示不好的事情发生了 社長は部屋を出るなり、現場に向かっていた。社长出了房间门马上就朝着现场方向走过去。 彼女は部屋に入るなり、浴槽に入り、泣き出した。女朋友刚进房间就马上进了浴缸哭了出来. 彼は車に乗るなり、猛スピードで走り出した。他刚坐上车就以非常快的速度跑了。 女子高生が部屋に入るなり、A容疑者は卑猥な言葉を投げかけた。女高中生刚进房间,A嫌疑人就对她说猥琐的话语。理解:这个是要同一主语的句式,两句都是女高中生是主语。 (3) Aが早いかB意味:Aしたら、すぐBの状態になります。A和B哪个更快是不知道的,大概是同时发生的接続: Vる/Vた+が早いか B只能使用意志動詞 チャイムが鳴るが早いか、生徒は弁当を取り出して食べ始めた。闹铃响的时候,学生们同时拿出便当开始吃。理解:这里是意识动词,表示大概时间别人在做这个事情。 ラーメンがテーブルに置かれるが早いか、面をすすり始めた。拉面放上来桌子上的时候,就开始嘬面了。 給料をもらうが早いか、全員飲み屋を探し始めた。大家收到工资后,马上就开始找喝酒的地方了。 空港で出会うが早いが、キスをするカップルをみて、羨んだ。刚到机场就看见在激吻的情侣,非常羡慕。 (4) Aや否やB意味:Aするかしないか、短い時間でBがおきるA不知道发生了没,非常短的情况下B就发生了接続: Vる+や否や 彼はご飯を食べ終わるや否や、すぐに誰かに電話をかけていた。理解:这里的程度比之前更快,表示A可能还没结束B就发生了 野良猫はひな鳥を捕まえるや否や、獲物をくわえたまま木の上に逃げた。野猫抓到雏鸟之后,马上就咬着猎物跑到树上去了。 部屋を開けるや否や、彼女は部屋に飛び込んで入った。房间门不知道开没开的时候,女朋友就飞进屋子里了。 川に糸を入れるや否や超でかい魚が取れた。河流里刚放入线就掉到超大的鱼。 25.よくも~ものだ意味:本当に~したんだ。 强调惊讶,愤怒,意外,憎恨,厌烦的感情。居然还~的意思接続: よくも+V普通/V可能/Vた+ものだ あんな罪を犯して、よくも平気で入れれるものだ。犯了那样的罪,还能这样没事的走进去。理解:这里的程度比之前更快,表示A可能还没结束B就发生了 こんなところで、よくも仕事ができたものだ。这样的地方,居然还能工作。 あれは全然仕事をしていないのに、よくも部長になれたものだ。他啥事不干居然还能当社长 こんな大きいラーメンをよくも一人で食べられたものだ。这么大份的拉面居然一个人能吃完了。 ほかに恋人がいるのに、よくも私の前で、私だけ愛してるとか言えるもんだな。明明有其他的恋人,居然还在我的面前说只爱我一个。 26.~ないものは~ない意味:絶対したい、できない 强调惊讶,愤怒,意外,憎恨,厌烦的感情。居然还~的意思接続: V可能+ないものは+V可能+ない 双重否定并不表示肯定的意思,字面意思是不是什么的就不是什么,做不到就是做不到 食べれないものは食べれない吃不了的东西就是吃不不了。理解:二次否定,再强调一次做不到某事。 いくら頑張ってもできないものはできない。无论怎么努力,做不到的事情就是做不到。 秘密だから、話せないものは話せない。 いくらお金を積んでも、復縁できないものはできない。 27.~以外の何物でもない意味:それ一つしかない、絶対だ除此以外没有别的了 yyds!接続: 名詞+以外の何物でもない こんあことするなんて、悪党以外の何物でもない。 あんなに何度もお辞儀をするなんて日本人以外の何物でもない ヒョウ柄のシャツにトラ柄のパンツを合わせるなんて大阪のおばちゃん以外の何物でない。豹纹的短袖配上虎纹的内裤只有大阪的老奶奶做的出来。 女性の色気を使って高いバッグや貴金属をかわせるのは詐欺以外何物でもないんじゃない?用女生的色气来买很贵的包包和金银就是诈骗。 28.~て からというもの意味:Aして以来今までBの状態が続く。A发生以来都是以B的状态持续着接続: Vて +からというもの 実家から離れてからというもの、規則正しい生活ができていない。从老家出走以来,都没能过上正常生活。 ダイエットを始めてからというもの、コメや甘いものを食べていない。自从减肥开始,没有吃过饭或者甜的东西。 都会の生活から離れているというもの、時計を見ることが少なくなった。离开了都市生活以后,看手表变得很少了。 恋人と別れてからというもの、女性と話すこともなくなる和恋人分手了以后,一直没有跟女生说过话了。 29.~ものなら意味:もし~できるなら話し手は~が絶対できないと思う 说话的人认为这事是绝对做不到的接続: Vる(可能) +ものなら 殴れるものならなぐってみろ!要是能打我的话就打我啊! 別れるものなら早く別れたい。要是能分开的话想早点分开。 できるものなら朴先生と結婚したい。可以的话我马上想跟朴老师结婚。 できるもんならブラピに生まれ変わりたい。可以的话想长成布拉德皮特那样。 辛い物はにがてなんだけど、食べられるもんなら激辛キムチを食べてみたい。吃辣实在是不在行,要是能吃的话想尝试一下超辣泡菜。 30.~ないものでもない意味:全くできないことはない。少し可能性がある。也不是不能。。。。接続: Vない+ものでもない この会社で昇進できないものでもないけど私の能力ではかなり難しそうだ。在这家公司升职也不是做不到,只是以我的能力会很难。 この商品売れないものでもないけど、儲けは望めそうもないね。这个商品也不是卖不出去,但是也不指望能赚钱。 今日中にこの仕事を終わらせろって言われたから、残業すればできないものでもないけどなあ...跟我说了让我在今天内把这个工作做完,如果加班的话也不是不能完成。。。 クラシック音楽は聞かないものでもないけど、聞き始めて五分で寝れしまう。也不是不能听古典音乐,刚开始听五分钟就睡着了。 31.~ものを意味:Aすればbになるのに明明做了A就可以达到B的。。接続: な形容詞+ものを 過去の話に使うことが多い、~たものを 多表示过去明明做了A发生B就好了。。 的意思 もっと早く話してくれれば良いものを。なんで話さなかったんだ明明早点跟我说就好了,为啥没有说呢。 私においしいものおごってくれれば、その問題の答え教えてあげたものを。明明你如果给我好吃的话,我就会给你这个问题的答案了。 社長はかれのためを思って厳しているものを、彼は社長の気持ちがわかってないな。社长明明是为他着想才严厉要求,他却不明白社长的良苦用心 あの先生は一回でもいい保護者に謝ればいいものを。くびになってしまったよ。那个老师明明只要给监护人道一次歉就好了。现在已经被解雇了。 32.~をものともせずに意味:難しいことにも負けないで虽然~这样的情况但是也不会输的 不顾。。也,不管。。也接続: Vない+ものともせずに 困難をものともせずに前進しろ!不管困难向前进。 貧困をものともせずに、彼女は強い女性に育っていった。不管有多贫困,她也成长为很强大的女性。 五体満足で生まれず、苦労させたが、障害をものともせずに育っていった。没有很好的四肢,受尽了苦难,不管遇到了什么障碍他也成长起来了。 暑さをものともせず、炎の中に飛び込んで子供を助けた虽然很热但是也冲进火中去帮助孩子。 運動不足をものともせず42キロのフルマラソンをも語と走りぬいた不顾自己运动能力的不够,也跑完了42千米的马拉松。 33.~ないものだろうか意味:できそうなのに できないのはなぜか 明明看上去可以做得到 为什么做不到呢 (也不是做不到呀 接続: 名詞+をものともせずに 葬式の日にけんかしている家族を見て、仲良くできないものだろうか、と感じた。看到了在葬礼日上吵架的家人,感觉明明可以关系好点的啊。 昔の人は長生きできないものだろうか、と動物の血をのんだりしたそうだ。以前的人想着难道不能更可以长寿一点吗,都去喝动物的血了 どうにか女性からモテないものだろうか、と毎日SNSを使って写真をアップしたり、大量のメッセージを送っている。难道不受女性欢迎吗,然后就每天用社交软件多发照片,发了很多的信息。 自分だけが幸せにならないものだろうかと考えているとともだちはへるだろう。只想着为什么不是让自己变得开心的想法,朋友会变少的的吧 ちょっとでも瘦せられないものだろうかといろいろなダイエットを試している女性たちを見て冷ややかな目で見ている男性たち。冷眼看着那些带着努力一下为什么不能瘦呢想法的,尝试了各种减肥方法的女性的男人们。 34.せめてもの意味:坏的情况中只有他是好的 至少。。 万幸的是。。不幸中的万幸接続: せめてもの+名詞 火事で全焼になったが、せめてもの救いは家族全員が無事だったことだ。因为火灾全烧了,万幸的是家人们都没事。 会社で不祥事を起こした社員にせめてもの情けで一か月分の給料の半額を渡して首にした。对于这个对公司做了不好事的社员,万幸的是给了他半个月的薪水再解雇了。 35.~こととて意味:~というわけだから、~なので 因为~。。。 现在日本人也不用,以前用的比较多接続: な形容詞+な+こととて 名詞+の+こととて きゅうなこととて、お茶と漬物しかありませんが、どうぞ召し上がってください因为很突然,只有茶和咸菜,请客人吃吧。 まだ五歳の子供がしたこととて、何とか許してやってください。只是五岁的孩子而已,他做了什么请原谅他吧。 まだ、仕事に未熟なこととて、勘弁してください。工作还不是很熟练,请原谅包含一下。 世間知らずのこととて、法律反する行為をした場合は、罰を免れない。尽管不了解世事,违反了法律的话,也免不了罪罚。 紅葉の季節のこととて、紅葉を見に行かずにいられない。因为是枫叶的季节,所以一定要去看枫叶。 36.~ことなしに~意味:AをしないでBをする 不做A的情况下做了BAをしなければBできない 做了A才能做B 接続: Vる+ことなしに 何も聞くことなしに、冷蔵庫の中のプリンを食べたら、妻は口をきいてくれなくなった。没有问的情况下,吃了冰箱里的布林,妻子不跟我说话了。 グルメと名乗るからには、食べることなしに食べ物の評価はできない。美食家和名人的话,不吃的话不能对食物做出评价。 SNSが普及している世の中、直接会うことなしに結婚するカップルがいるらしい。社交媒体普及的现在,不直接见面就结婚的情侣好像是有的。 漢字を書くことなしに覚えられるなら苦労しない。如果汉字不写就能记下来的话就不用这么辛苦了。 前回の借金を返済することなしに、さらにお金を貸せだと?ふざけるな!上次借的钱没还,还想再借钱?开什么玩笑! 37.~ことだし意味:今は~なので、~から 现在是因为。。 强调的是因为现状已经是这样了接続:普通形な形容詞+な(である)名詞+の(である)+ことだし この現場はは五人いることだし、私たちは別の現場に行こう 肉は内に十分あることだし、後は野菜を買えば、焼き肉だ。 日本語の森のビデオがあることだし、ほかの教材はいらないかもね。 今日は土曜であることだし、はやめにしごとおわらせてパーティーしましょう。 子供も成人したことだし、老後は夫婦でのんびり過ごししましょう。 38.AてもBすぎることはない。意味:AしてもBには十分じゃない 尽管A发生了,做了A 对于B来说还是不过分接続:(いくら)Vても+Vます+すぎることはない 这里两个V是相同的 この交差点は過去に事故が多発してるから、注意してもしすぎることはない。 あの子は注意散漫だから何度言っても言い過ぎることはない。 インターネットの情報は全部が真実ではないから疑っても疑いすぎることはない。 果物は体にいいから食べても食べ過ぎることはない。 栄養ドリンクをいくら飲んでも飲みすぎることはないと思っていたら、その人は死んだらしい。 39.よほどのことだ意味:普通以上、何か特別な理由がある接続:理由+よほどのことだ会話:よっぽどのことだ 普段穏やかなユハ先生が怒っている。よほどのことだ。把平时沉稳的yuha老师惹怒了,肯定有什么特别的原因。 いっつも成績がいい彼が今回の試験が平均以下だなんて、よほどのことがあったんだろう 手術が長引いている、よほどのことがあったんではないかと落ち着かない。 業界トップの売り上げの会社の株が暴落したのだから、よほどのことだ。 あそこに人だかりができている。よほどのことがありそうだ。 40.もさることながら意味:AはもちろんBもある 虽然A是当然有的但是B也有的 (也要注意B,或者B更重要)是递进关系接続:名詞+もさることながら 人件費もさることながら、雑費も気になるところだ。 今の生活もさることながら、年金の有無が騒がれているので、老後の生活も心配だ。虽然现在的生活是可以的,但是大家都在讨论有没有养老金,担心着老年生活。 両親との関係もさることながら、親族一同のこともきにしないといけない。 福岡を代表する食べ物として豚骨ラーメンもさることながら、明太子も外せない。福冈代表食物当然是豚骨拉面了,但是也不能不包含明太子。 妻の気持ちもさることながら、妻の家族といかにうまくやっていくかが家庭円満の秘訣だ。家庭和睦的秘诀就是 不仅要考虑妻子的感受 更要和妻子的亲戚搞好关系。 41.~までだ/までのことだ意味:最後は~する 只能我去做这个事情了 最后我做某事接続:Vる+までだ/までのことだ 君がいかないなら私が行くまでだ。你不去的话只能是我去了 AしゃがダメならB社にいって契約をとるまでのことだ 試験前日まで猛勉強したのに失敗したら、それはもうあきらめるまでだ。直到考试前一天都在猛学习还失败的话,那就只能放弃了。 来週までにお金を返さないなら直接彼の家に行って取り返すまでだ。 夜中に停電したら、何もしないで寝るまでのことだ。 42.~に限ったことではない意味:AだけではないBも 不止A还有B接続:名詞+に限ったことではない 更年期は女性に限ったことではない男性にもあるらしい。更年期不只是女性独有的男性好像也有。 太りやすい食べ物はお菓子に限ったことではなく、米やパンや麵類等もダイエットに大敵らしい。 欠陥住宅はこの家に限ったことではない。あの住宅メーカーの家はすべて疑わしい。 浮氣をするのは男性に限ったことではないよ。 動物によって媒介される病気は野生動物に限ったことではなくペットにも要注意 43. を皮切りに意味:~をはじめに、後が続く 从~开始,后面还要继续的接続:名詞+~をはじめに ひらがなを皮切りに日本語の勉強を始めた。 ワードを皮切りにパソコンの機能を覚えていった。 フォーを皮切りにベトナムの食文化に触れていった。从河粉开始接触越南的食物文化 大差で勝っていたのに、彼のエラーを皮切りに試合の流れが変わり、逆転されてしまった。 地震を皮切りに停電、水の供給停止、ガス管の破損による火事がおこるので備えが必要だ。 44. ~をもって意味:~があれば、~で 以~ 、 有~的话接続:名詞+をもって 本日をもって営業を終了させていったいただきます。 何かを習得するには、身をもって経験することが一番の近道です。 あなたの能力をもってすればこんな作業、朝飯前でしょう。 日本の建設技術の全てをもって東京スカイツリーは完成した。 アメリカ同時多発テロは、世界中に恐怖と衝撃をもって伝えられた 45.を余儀なくされる意味:仕方ないけどといけない、断れない 虽然没有办法了只能做了 , 不能拒绝了 被迫 不得已的意思接続:名詞+を余儀なくされる 地震が発生し、電車に遅れが出たため、会議の時間変更を余儀なくされる。 国会の討論で一言の失言をきっかけに辞職を余儀なくされる。 父が不治の病にかかってことをきっかけに長男は生活の費用の負担を余儀なくされた。 焼きそばが無性に食べたかったのに売り切れのため、うどんを食べることを余儀なくされた。 留学生としては働きすぎて、入館に見つかって帰国を余儀なくさてた。 46.を余儀なくさせる意味:仕方ないけど相手にさせる 没有办法了让对方去做(上一个是自己做)接続:名詞+を余儀なくさせる 地震による津波は、地域全域の住民を高いところに避難を余儀なくさせた。 社内改革は、次期社長として、外国人社長の任命を余儀なくさせた。 異物混入が見つかったの食品メーカーに入った一報は全商品の回収を余儀なくさせた。 激しさを増すスーパーの価格競争は地元商店の閉店を余儀なくさせた。 近所で起きた殺人事件は、すべての車両、通行人の迂回を余儀なくさせた。 47.ところ(を)意味:~のに接続:な形容詞+ところを 名詞+ところを を可以省略 お休みのところ申し訳ありませんが,緊急事態でして 社長、お話のところ失礼ですが、急ぎの件がございまして お疲れのところ、わざわざお越しいただき、感謝します。 正直に答えなくてもいいところを、真実を語り、相手を怒らせた。明明是正直的回答,说了实话,反而让对方生气了。 勉強中のところ、友達が来て、遊びたいという誘惑にかられた。明明在学习,朋友来了,被想玩的诱惑驱使着去玩了。 48.ているところを見ると意味:Aの状況からするとBが考えられる接続:Vて + いるところを見ると 顔が赤くなっているところを見ると、私が言ってことは本当だな 外で遊んでいるところを見ると、宿題は終わったようだ。 二人で仲良く歩いているところを見ると、仲直りしたようだ。 猫が耳の裏まで毛繕いしてしているところを見ると、明日は雨が降りそうだ。 貸した車が泥だらけになって帰ってきているところを見ると、山道でも走っていたようだ。 49. をくだらない意味:最低でも~だ 最少也有。。 不低于。。 以上接続:数じ+をくだらない 2011年の東北大震災で、死者行方不明者は二万人をくだらない。 アメリカ同時多発テロでは死亡者は三千人、負傷者は六千人を下らない。 トヨタ自動車の一か月の生産台数は七十万台を下らないそうだ。 2018年、離婚したカップルは二十万組をくだらない。 あの子のゲームする時間は一日三時間はくだらない。は表示强调! 51. をおいて意味:~以外~ない接続:名詞+をおいて この部署の管理者は、君をおいてほかにいないよ。这个部门的管理员,除了你没有别人了。 最高の品質の車を作れるのは、匠と呼ばれるか彼らをおいてほかにいない。 高いところから街を見下ろしたいなら、東京スカイツリーをおいてほかにない。 アオザイが似合うとしたらベトナム人女性をおいてほかにいない。 お金がほかをおいて大事だと考えている人の心は貧しい。 52.~をよそに意味:~は気にしないで 不管 不在意接続:名詞+をよそに 親の期待をよそに彼はミュージシャンになると上京した。 先生の不安をよそに彼女は予定より早めに日本に行ってしまった。 宿題をする友達をよそに、漫画を見て大笑いする私。 帰りたいと言っている子供をよそに二時間以上愚痴を言っている団地妻たち。 ゴミ拾いをする人をよそにゴミを捨てる人を見ると腹が立つ。 53. ~限りに意味:~を最後に 。。内 。。最后时间以前接続:名詞+を限りに 本日を限りに内閣を総辞職します! 今秋を限りに、土曜出勤をなくします! 今年度を限りに会社の経営を全権、彼に任せ、私は引退します。 この人の面接を限りに、募集は打ち切りにしよう。这个人是最后一个了,停止招人吧。 このメッセージを限りに、あんな奴とは一切連絡しないぞ。 54. ~を踏まえて意味:~を考えて~する 考虑。。 根据。。 去做某事接続:名詞+~踏まえて コンビニはあらゆるデータを踏まえて、在庫や次の日の発注を考えないといけない。 新しいプロジェクトを始めるには社員たちの意見を踏まえて進める必要がある。 結婚するときは、両家の意見を踏まえ、よく話し合わないとうまくいかないはずだ。 親が頭ごなしに𠮟るより、子どもの気持ちも踏まえて解決策を出したほうがいい。比起家长无脑骂,考虑孩子的感受给出解决方法更好。 会長の演説を踏まえて、今後の営業活動は励みましょう。 55.~を推して、押し切って意味:~の問題があるけど 虽然有这个问题。。 忍受着。。接続:名詞+を押して 長期にわたり練習してきたので、けがを押して大会に出場した。 嫌がる彼女の反対を押して家族に挨拶に行った。 社長は病気を押して来ていただいたので予定通りの時刻に終わるように配慮しましょう。 困難を押し切って偉業を成し遂げた人の言葉は、重みがありますね。 病を押して社会貢献した彼の姿は一生忘れられないだろう。 56.~を潮に意味:潮あることをやめるのにちょうどよい時放弃有好有不好的东西的正好的时候, 借此机会 顺势 以此为契机放弃某事接続:名詞 討論中に話が変わったのを潮に席を立ち、トイレに行った。正好在讨论话题变了的时候我从座位站起来去卫生间了 あれだけ飲んだ後暴れたから、昨晩を潮に飲酒やめるんじゃない?喝了这么多酒后还发疯了,借着昨晚这样的事别喝酒了吧 タバコが原因で入院したから、これを潮にやめてほしいな 二度目に警察署に連れて行かれたのを潮に彼はストーカー行為をやめると思ったが、やめなかった。 不幸中の幸い(さいわい)にも事故で立つかったのを潮に交通ルールを守りましょう。 57.~を経て意味:经过..之后接続: 数々の困難を経て、彼は偉業を成し遂げた。 三カ国への留学経験を経て五か国語を習得した。 超人的トレーニングやプロテインの摂取を経て、かれは強靭な体を作り上げた 普段気にしない習慣が、実は何百年を経て行われていることを知ると、驚嘆した。 54.~を境に意味:あるときから 从。。时候开始接続:名詞+を境に 退職を際に都会を離れ、田舎で自給自足の生活をする。 日本は2005年を際に人口減少局面に入った。 経済成長を境に生活が豊かになる一方で、ごみ処理や空気の汚染などの環境問題も発生した。 結婚を境に生まれてくる子供のためにタバコをやめた。 食中毒が報道されたのを境に急激に客が減ったのは言うまでもない。言うまでもない。 人尽皆知 不需要说的事实 54. ~だけましだ意味:いいとは言えないが、 ほかの状況よりはまだよい接続:普通形+だけましだ 名詞/な形容詞+である+だけましだ うちの会社は彼の会社に比べ、たった一か月でもボーナスが出るだけましだ。我们公司跟他的公司比,起码一个月就发奖金了 (虽然一个月发奖金不能说好,但是比他们好) 会議なのに、彼は外出してしまったが書類をそろえてくれ打だけましだよ 息子はまた漫画を読んでいるが、帰ってきて、机の前に座っただけましよ。 みんな給料が低い低いと言っているけれど、仕事があるだけましだ。 宝くじに三百円しか当たらなかったが当たっただけましだと思おう。 55.Aた 分だけB意味:Aをしました その分bに影響する接続:Vた+分だけ 仕事をして利益を上げた分だけ給料も増えるという会社に入りたい。 勉強は頑張った分だけ結果がでる。 人生経験をした分だけ価値観は変わる。 筋肉トレーニングはやった分だけ体に現れる。 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても バイトしているといっても、せいぜい月に五日だけだ 毎日勉強しているといっても、せいぜい一時間だけだ。 割引といってもせいぜい十パーセントだけだね。 結婚記念日といってもせいぜい夕食を外に食べにいくだけだ うちの会社は夏休みがあるといってもせいぜい三日間だけだ。 57.ただ~のみだ意味:ただ~だけ接続:ただ+普通形+のみだ ただ+な形容詞/名詞+である+のみだ 突然、彼の死の知らせを聞き、私はショックのあまり、ただ呆然とするのみだった。 競技を終えた選手は晴れ晴れとした表情でただ結果を待つのみだった。 社員はただ部長の指示を聞くのみ、誰も行動を移されない。 マラソン当日の天気、選手にとってはただそれのみが心配だ。 ただ厳しいのみではいい教育とは言えない。 58.ただ~のみならず/のみか意味:Aだけではない 不仅仅接続:普通形/名詞+のみならず/のみか な形容詞/名詞+である+のみならず/のみか 彼は戦争により、体のみならず心の傷まで負ってしまった 会社の業務改善は、ただ営業部門のみならず、社員全体の努力にかかっている。 佐藤さんはただプロ野球の選手であるのみならず、歌手としても活躍しているすごいかただ。 新聞記者は政府から不正な金を受け取るのみならず、記事の内容まで政府に漏らしていたという。 彼は日本語のみならず、英語やベトナム語など十か国語を話すことができる。 59.意味:接続: 60.意味:接続: 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても 56.Aといっても、せいぜいBだけだ意味:というけれども、実際は …是这么说,但是也就。。。接続:普通形/名詞+といっても "},{"title":"激光SLAM学习 SLAM流程与回环检测","date":"2022-11-30T03:55:21.188Z","url":"/2022/11/30/SLAM/6_Mapping/","tags":[["SLAM","/tags/SLAM/"],["LOAM","/tags/LOAM/"],["机器学习","/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/"]],"categories":[["undefined",""]],"content":"点云地图构建目前基于地图做定位是各种场景定位的解决方案,架构如前面图。前面讲述的关于前端里程计的主要是对原始数据(激光雷达是点云),提取到特征后,通过构造的优化模型计算出其前后两帧之间的变化,从而实现位姿约束(即里程计)。RTK和组合导航是作为先验位置,也就是初始位姿作为一个输入,同时也能作为位姿约束输入。对于定位来说,只要有地图就是进行搜索和匹配,这部分对建图的流程和原理进行学习。剩下的部分就是组合导航和回环检测模块。 回环检测随着路径的不断延伸,机器人在建图过程中会存在一些累计误差,除了利用局部优化、全局优化等来调整之外,还可以利用回环检测来优化位姿。 回环检测是什么?回环检测,又称闭环检测,是指机器人识别曾到达某场景,使得地图闭环的能力。就是能够识别检测到它曾经到达过的地方,而不是作为新地图加入到地图中。地图生成时的误差会对定位造成非常大的影响,所以就算有RTK,纯靠RTK的定位误差也会使得地图变得糟糕。目的:它能够消除建图时产生的累计误差,提高地图一致性。方法:在历史帧中找到相似帧(位置相近且有充足共视视野的帧),给出两帧间的相对位姿。用法:在后端优化中,作为相对位姿约束边加入,加入图优化系统。 有初始相对位姿的情况下,使用ICP和NDT是这个课程中介绍过的方法。 后端优化目的:利用回环检测结果(与历史帧中相似帧的相对位姿)和惯导先验(也就是初始相对位姿)修正里程计的误差。 观测:1)连续两帧的相对位姿观测;(也就里程计,开环)2)回环匹配得到的相对位姿观测;3)组合导航提供先验位姿观测。 1,2组成基于回环;1、3组成基于先验。 LOAM MAPPING在LOAM的实现过程中,我们由前端通过线面特征的匹配得到了lidar的odometry,每一个odometry我们可以取一个关键帧来进行地图点云的一部分,从而实现地图构造。"},{"title":"SLAM在农业机器人方面应用的论文阅读笔记","date":"2022-11-06T06:56:51.571Z","url":"/2022/11/06/Agriculture/Agriculture_paper/","tags":[["Agriculture","/tags/Agriculture/"],["Machinery","/tags/Machinery/"],["Paper Reading","/tags/Paper-Reading/"]],"categories":[["undefined",""]],"content":"该文主要是关于在期刊Computers_and_electroincs in agriculture上关键词SLAM的论文,提供后续论文的一些素材。根据之前读的一篇综述文章,将后续阅读的文章根据一下几个因素进行评估: (1)机械系统?(2)最终应用方向?(3)使用什么传感器?(4)使用了什么智能算法?(5)目前的发展状况?(研究阶段或商用)(6)应用区域?属于哪个国家和大洲?(7)弥补了什么缺点?还存在那些缺点0.Advances in Agriculture Robotics: A State-of-the-Art Review and Challenges Ahead摘要一直以来,农业机器人的目的都是为了克服人口增长、城市化加速、高质量产物的高适配性,保护环境以及合格劳动力的缺少带来的挑战。这篇文章回顾了农业机器人系统在播种、种植、植物处理、收获、产量估计和表型分析方面前的土地准备执行操作的主要现有应用。总的来说,所有机器人都通过以下几个因素进行评估:机械系统,最终应用,使用什么传感器,机械臂或视觉算法,发展状况以及属于哪个国家和大洲。评估了这些相似特征后,来发掘出研究的潮流,普遍存在的隐患以及与商业环境有关的特征。论文发现了目前智慧农业四个比较创新和潮流的方向:定位系统,传感器,视觉算法以及通信技术(自动驾驶也是同样的)。作者建议农业机器人系统投资短期目标为收获监控,长期目标为整体田野的评估。作者引用了另一篇文章中对精细农业的定义:a management strategy that uses electronic information and other technologies to gather, process, and analyze spatial and temporal data for the purpose of guiding targeted actions that improve efficiency, productivity, and sustainability of agricultural operations。一种利用电子信息和其他技术来收集、处理和分析空间和时间数据,以指导有针对性的行动,提高农业操作的效率、生产力和可持续性管理策略。分析了目前与精细农业相关的三个方面,机器人(robotics)、人工智能(artificial intelligence)和物联网(internet of things)。它们可以为农业任务提供保障,如:土地平整,播种,种植,害虫控制以及收获。 内容:机器人在农业中的应用关注本人目前的研究方向是水稻种植方面的农业机器人研究,仅对里面关于水稻田的机器人应用进行分析。 (1)在种植前的土地平整应用在这里面提及到了使用UAV Octocopter(无人八旋翼直升机),使用GPS,摄像头,加速计以及指南针作为导航传感器,用全向雷达作为障碍物感知。这里介绍的是大疆的MG-1P 系列农业植保机,现在已经停产了,更新一代的是T40农业无人飞机。它的优点是可以无视地形进行作业,而受到电池容量的限制以及风雨天气的影响较大。 (2)在播种和种植方面的应用根据不同的作物种类以及作业农场规模大小的不同,所使用的机器人差异巨大。与水稻播种相关的主要是两个机器人,一个是小麦播种的,用4WD的机械系统进行播种小麦播种机器人;而另外一个值得关注的是使用了卡尔曼滤波来矫正它的定位。Design of an autonomous seed planting robot 同时根据播种的机械装置也是不同的,有使用真空管+播种马达,也有使用线性的传动器和真空马达的,或者螺线管传动。 (3)在植物处理方面的应用在播种后的阶段,需要对植物的生长进行适当的维护,保证其免受疾病和害虫的侵害,需要对其进行监控。这方面的研究多使用相机或者深度相机作为传感器进行图片识别,利用人工智能算法区分杂草/无杂草,害虫/无害虫,能够早期发现这些异常进行处理。对水稻田研究的其中一种机器人是除草机器人,它能够在移动中除去杂草,通过高精度的图像处理,识别出它们的位置。首先避免植物(水稻)的碰撞,然后通过机械的方式在田间移动,能够在田里进行移动,并进行除草。 (4)在收获方面的应用在收获方面,绝大部分的收获所用的传感器都是用的RGB相机作为收获目标的识别,对于收获任务来说,只需要获得其目标所在的位置就可以,其余的机动状态是交给locomotion system。其中大部分都是关于长在树上或者植株上的收割,如草莓,椰子,苹果等,能够从背景中识别出来并使用机械臂进行抓取和脱离,完成收割任务。然而对于小麦、水稻等,是使用待收割区域,使用收割机完成收割任务。 1.3D global mapping of large-scale unstructured orchard integrating eye-in-hand stereo vision and SLAM (1)机械系统:4轮驱动移动平台以及采集用机械臂(2)最终应用方向:用于果树园林,执行收获任务(3)使用什么传感器:眼手系统,双目相机(立体声)-6自由度机械臂(4)使用了什么智能算法:ORB-SLAM3,efficientDet-D3(5)目前的发展状况:研究阶段(6)应用区域?属于哪个国家和大洲?中国广东的果园(7)解决问题/创新点:对大范围面积的果园进行了双目相机的地图建模,同时根据该地图进行定位和目标识别。 该论文使用立体声相机作为传感器,代替使用Lidar来作为建图和目标识别。目标识别不多介绍,他用的是efficientDet-D3用于目标识别。总体流程图如下图:首先是两个系统的校准,一个是相机内参,一个是机械臂系统和相机的相对关系。校准完后进行采样作为训练集、测试集。重要的详细部分是Local Dense Mapping。文中所说它的输入是去除背景后识别的目标,也就是bounding boxes。通过双目相机中对两张图片中识别到的视差图(disparity map),得到每一个识别目标的局部视差图,将他们组成一个全局的视差图,再通过双边滤波器对边缘进行保留特征。 2.Design of a bistatic LIDAR system and simulating the performance for early detection of rice leaf blast from unmanned aircraft (1)机械系统:无人航行系统(2)最终应用方向:用于水稻田,执行植物处理方面任务,具体是疾病检测(3)使用什么传感器:LIDAR激光雷达、 EO/IR 光电红外技术(4)使用了什么智能算法:目前还没看到,是关于数据分析的(5)目前的发展状况:研究阶段(6)应用区域?属于哪个国家和大洲?未知(7)解决问题/创新点:使用激光雷达对二氧化碳浓度的检测 该论文提供了一种双基站的LIDAR以及基于无人飞行系统(UAS,Unmanned Aircraft Systems)的光电红外系统来对作物疾病的检测。通过搭建固定的激光雷达(Tx)和飞行系统上的激光雷达(Rx)组成双基站式的LIDAR系统,UAS一直面对着Tx进行接受,每个接收发送的两点组成一条线,每条线的时间,以及坐标都被记录下来。 3.A review on multirobot systems in agricultureAgricultural multirobot systems (MRSs) ,主要是对三种机器人进行分析UGV,UAV以及manipulators,我们关注UGV尤其是联合收割机在里面的review,里面对UGV的描述分为多个部分,下面逐一描述。 (1)四轮式的运动学模型(2)Multi UGV 多UGV协同"},{"title":"激光SLAM学习 LOAM代码","date":"2022-11-03T12:12:57.571Z","url":"/2022/11/03/SLAM/7_LOAM_code/","tags":[["SLAM","/tags/SLAM/"],["LOAM","/tags/LOAM/"],["机器学习","/tags/%E6%9C%BA%E5%99%A8%E5%AD%A6%E4%B9%A0/"]],"categories":[["undefined",""]],"content":"LOAM代码学习引自Github多传感器融合定位 三章 3D激光里程计2参考博客:slam中ceres的用法解析基于Aloam对特征匹配及雷达里程计的学习 引言该部分主要对ceres库在slam算法中的应用以及基本用法进行介绍和学习,作为以后自己参考的内容。Ceres``是由Google开发的开源C++通用非线性优化库(项目主页),与g2o并列为目前视觉SLAM中应用最广泛的优化算法库(VINS-Mono中的大部分优化工作均基于Ceres完成)。Ceres中的有限边界最小二乘问题建模为以下形式: \\underset{x}{min}\\frac 12 \\sum_{i}p_i(\\|f_i(x_{i1},x_{i2},...,x_{ik}) \\|^2)\\\\ s.t. l_j \\leq x_i \\leq u_j \\\\ 残差模块(residual block): p_i(\\|f_i(x_{i1},x_{i2},...,x_{ik}) \\|^2) \\\\ 损失函数(loss function):p_i(·)\\\\ 定义在单个样本上的,算的是一个样本的误差。\\\\ 参数模块(parameter blocks):{x_{i1},x_{i2},...,x_{ik}} \\\\ 代价函数(cost function):f_i(·)\\\\是定义在整个训练集上的,是所有样本误差的平均,也就是损失函数的平均。\\\\ l_j 和 u_j分别为参数模块的下界和上界Ceres的求解过程包括构建最小二乘和求解最小二乘问题两部分,其中构建最小二乘问题的相关方法均包含在Ceres::Problem类中,涉及的成员函数主要包括Problem::AddResidualBlock()和Problem::AddParameterBlock()。这里我们对于需要解决的问题,就需要对这两个函数里面的参数进行传递,并重定义它们。对LOAM来说,残差模块就是前面所对应的线面特征。 残差的含义在于两帧之间待优化变量它们的变化或者代表变化的变量。在代码中使用线面特征计算去表示其代价函数。损失函数则可以选用其他多种常见的损失函数。残差模块的概念是在ceres中才有的,下面结合代码来解释。 //新建一个损失函数为HuberLossceres::LossFunction loss_function = new ceres::HuberLoss(0.1);//新建一个参数模块为Eigen的四元数参数,LocalParameterization类的作用是解决非线性优化中的过参数化问题。所谓过参数化,即待优化参数的实际自由度小于参数本身的自由度。例如在SLAM中,当采用四元数表示位姿时,由于四元数本身的约束(模长为1),实际的自由度为3而非4。此时,若直接传递四元数进行优化,冗余的维数会带来计算资源的浪费,需要使用Ceres预先定义的QuaternionParameterization对优化参数进行重构:ceres::LocalParameterization q_parameterization =new ceres::EigenQuaternionParameterization();//新建一个Problem类,同时可以在Options中进行调整ceres::Problem::Options problem_options;ceres::Problem problem(problem_options);//通过Problem类添加参数模块,这里添加了四元数矩阵和旋转矩阵对应的参数,分别为四维(x,y,z,w)和三维(x,y,z)problem.AddParameterBlock(para_q, 4, q_parameterization);problem.AddParameterBlock(para_t, 3);//q_curr_last(x, y, z, w), t_curr_lastdouble para_q[4] = {0, 0, 0, 1};double para_t[3] = {0, 0, 0};//这里根据这个double数组来对其进行内存空间的分配//这里介绍一下Eigen::Map,括号()里面是实际数据存放的内存的指针,即para_q和para_t作为基本的指针结构传递进Map,用q_last_curr来表示,这里的意思只是重映射成一个成模板类中的类型作为分析,所以q_last_curr和para_q存储的是同一个数,t_last_curr和para_t也一样Eigen::Map q_last_curr(para_q);Eigen::Map t_last_curr(para_t); //新建一个代价函数,这里用的是面特征,这段代码是选取了面点ceres::CostFunction *cost_function = LidarPlaneFactor::Create(curr_point, last_point_a, last_point_b, last_point_c, s);//当代价函数和损失函数以及参数模块都准备好后,加入残差模块problem.AddResidualBlock(cost_function, loss_function, para_q, para_t);//使用求解器对该优化问题进行求解ceres::Solver::Options options;options.linear_solver_type = ceres::DENSE_QR;options.max_num_iterations = 4;options.minimizer_progress_to_stdout = false;ceres::Solver::Summary summary;ceres::Solve(options, &problem, &summary);通过problem类把参数模块已经传进去,求解后就可以得到参数变量的内存空间就更新了。 代码结构解读参考博客A-LOAM工程架构与代码详解代码是lidar_localization文件夹,它整个文件夹是ros中的一个package,首先看它的launch文件,启动了哪几个节点。分别启动了下面几个: scan_registration_node:原始点云的订阅和发布,每一帧线点和角点的计算,输出计算好特征的点云 front_end_node:前端输入,是激光点云的入口,输出 aloam_laser_odometry_node 基于线点和角点,计算他们帧与帧之间的关联关系 aloam_mapping_node evaluation_node这几个node中都存在一个while循环,逻辑是readdata然后检测validdata,然后updatedata,再PublishData。由上述代码可以知道,主要是四个模块。每个模块的cpp文件都由node,flow以及原始类组成。node是作为启动节点的cpp,而flow是作为流,个人理解是作为一个线程开启,具体的函数逻辑在原始的cpp中。1. scan_registration_node在原始类中,对初始点云进行计算,在while循环中分为以下几个部分:(1)Readdata:这个函数将从cloud_sub_ptr(cloud_subsriber)的ParseData中获得,该函数使用地址传递,将点云数据传递到cloud_data_buff下面。(2)hasData:该函数判断是否有数据,从序列中获取最新的一帧。(3)Update:里面有三个函数,对获取的原始数据进行处理:// filter input point cloud:CloudData::CLOUD filtered_cloud;FilterByRange(*input_cloud.cloud_ptr, filtered_cloud);这个函数是对min_range这个值外的点云进行处理,相当于不处理周围5米内的点 // sort point cloud by scan,根据每个点所在的角度来获取它在哪一条线上,根据所在线来分类点云:output_cloud.reset(new CloudData::CLOUD());SortPointCloudByScan(filtered_cloud, *output_cloud); // get feature points,这个函数是获得四种特征点的计算,包括曲率等:GetFeaturePoints(*output_cloud, corner_sharp, corner_less_sharp, surf_flat, surf_less_flat); 通过计算后输出了五个点云topic,四种特征点的点云以及filtered_cloud供后面计算残差使用 2.aloam_laser_odometry_node核心流程如下:这个函数是对从scan_registration_node里面获取的特征,包括cornerpoint和planepoint。首先对首帧进行初始化,对第二帧的点云,进行kdtree结构化构造。利用以下函数进行计算:kdtreeCornerLast->nearestKSearch(pointSel, 1, pointSearchInd, pointSearchSqDis); Parameters(参数)[in] point a given valid (i.e., finite) query point,这里指的是输入点的序列[in] k the number of neighbors to search for 这里指的是每个点要找的邻居点个数[out] k_indices the resultant indices of the neighboring points (must be resized to k a priori!) 输出的邻居点他们的序列号[out] k_sqr_distances the resultant squared distances to the neighboring points (must be resized to k a priori!) 输出的邻居点他们的距离从这函数可以看到,它找的是1个最近点,从这个点开始找所有的点,限制为往上3个点,向下3个点。面特征点也是一样的。这里找到了对应点所包含的线特征和面特征后,输入到前面所说的损失函数,进行求解。这样就完成了一次循环,再不断迭代。 构造了特征点后,我们就可以利用公式进行分析了。 3.aloam_mapping_node这部分是最后的建图部分,通过odometry_node得到了当前基于激光点云残差计算的位姿变化,从而也能计算出上一帧点云和当前点云的位姿变化, 在这个代码里,他使用了一个函数叫void process(),就是整个建图的一个死循环流程。(1)确认每个特征点都同步且不为空,为后面使用。"},{"title":"激光SLAM学习 点云特征提取与位姿优化","date":"2022-10-27T07:59:19.173Z","url":"/2022/10/27/SLAM/5_Geometry_feature/","tags":[["Deep learning","/tags/Deep-learning/"],["SLAM","/tags/SLAM/"],["特征提取","/tags/%E7%89%B9%E5%BE%81%E6%8F%90%E5%8F%96/"]],"categories":[["undefined",""]],"content":"点云线面特征提取参考博客:LOAM论文和程序代码的解读A-LOAM流程以及代码注释知乎:基于线面特征的激光里程计 按线数分割当给出的一帧点云中,所给的点不知道它属于哪根线时,可以根据激光点的坐标,计算该束激光相比于雷达水平面的倾角,根据内参倾角就可以计算得到: P = (x,y,z) \\\\ w = arctan \\frac{z}{\\sqrt{x^2+y^2}} 计算曲率根据同一条线面上前后各5个点与当前点的长度(长度指激光点到雷达的距离),计算曲率大小。 c= \\frac{1}{\\| x\\|}\\| \\sum_{i} (X - X_i) \\|这样我们可以在同一个平面内,按照曲率大小进行特征提取。 1.曲率特别大的点(sharp)这种情况下,这个线打到的实体表面应该如下图:可以由图看见,作者直观地展示曲率的大小,我用直线表示在各个点上,直线高度与曲率c成正比。越尖锐的点曲率越大,在直线上的点曲率则是,远比左右点的距离小,得到的曲率值是特别大的。而对于平面来说,他们之间的差距很小甚至没有,所以能得到其曲率为0。同样地,在不规则平面内可以显示:根据曲率值的大小,可以对点进行分类。论文中分成两类:曲率大的就是角点(sharp),曲率小的是平面点(flat),或者说一条线上的点,作为特征进行匹配。这些特征要如何用于位姿估计和优化? 基于线面特征的位姿优化LOAM 分为前端和后端,前端主要的工作对激光雷达点云进行线面特征提取,在提取之后发送给后端:里程计和建图使用。 1. 帧间关联1)点云位姿转换对于相邻两帧(即两个时间戳)之间的相对位姿,即第k+1帧与第k帧的相对位姿为 T = \\begin{bmatrix} R & t \\\\ 0 & 1 \\end{bmatrix}从第k+1帧中的点#p_i#转到第k帧坐标系: \\tilde{p_i} = Rp_i+t2)特征关联对于所有的特征点,由于一帧内的点是在不同时间内扫出来的,将一帧内所有点先重投影到每一帧的最后的时刻(去雷达畸变),这样就能得到一帧中所有特征点的信息。其中还有运动补偿,方法比较多,在这里不展开。特征点分为两类: 对于角点,一般在转折线上(例如卧室里的墙角),要计算它到折线的距离。作者认为,可以有如下假设:角点是雷达某个线束与物理世界两个平面夹角相交时的采样,那么这个线束相邻的雷达扫描线束也会与这个平面夹角相交,所以这个平面夹角的直线可以用前后两次扫描的角点进行标识。角点#p_i#在上一帧的坐标系转换为#\\tilde{p_i}#,在这个坐标系中找离它最近的线特征点a,并在相邻的线上再找一个线特征点b(代码中是上下都寻找一个,取最近的)。这两个点(指上一帧的角点以及该角点最近的点)就可以确定直线方程,就能够计算当前帧角点到该直线的距离,作为角点约束的残差函数。我的理解是这样做可以把角点作为参考点,而这个线特征点a是当前的位置,线特征点b是上一帧的位置,利用环境稳定的特征点作为参考得到计算。 对于平面点,一般在比较平坦的表面上(例如墙面),要计算它到平面的距离。与角点是差不多的,首先找上一帧中最近邻的平面点,之后在同一个扫描线数和不同的线束上各提取一个平面点,这样共得到了3个不共线的平面点,唯一确定了平面,从而计算平面点到平面的距离。 到这里线面的特征都被提取出来了,代码的具体实现在后面分析。 2. 残差函数在我们计算出线面特征后,我们下一步就是要利用这些特征之间的位姿关系计算出车辆本身的相对位姿关系。由上图和我们的计算函数可知,我们可以计算其线特征(点到直线距离)和面特征(点到平面距离),并构造关于待求变量(T,相对位姿转换矩阵,即里程计的核心)的残差函数并建立其优化目的,目的就是为了求出相对位姿,即求特征点对与T的雅可比矩阵,进行优化。我们对于点云中的点到该直线的距离(线特征)可以由下式计算 d_{\\epsilon} = \\frac{|(\\tilde{p_i}-p_j)\\times(\\tilde{p_i}-p_l)|}{|p_l-p_j|}线特征的残差雅可比计算: J_{\\epsilon} = \\frac{\\partial d_{\\epsilon} }{\\partial T } = \\frac{\\partial d_{\\epsilon} }{\\partial \\tilde{p_i}} \\frac{\\partial \\tilde{p_i}}{\\partial T }对于等式右边第二项: 对平移的雅可比: \\frac{\\partial \\tilde{p_i} }{\\partial t } = I \\\\ 对旋转的雅可比: \\frac{\\partial \\tilde{p_i} }{\\partial R } = - (Rp_i)\\hat{} 第二项的雅可比为: \\frac{\\partial \\tilde{p_i} }{\\partial T } = \\begin{bmatrix} I & -(Rp+t)\\hat{} \\\\ 0^T & 0^T \\end{bmatrix} \\\\ 对于等式右边第一项,根据外积的微分得: \\\\ \\frac{\\partial d_{\\epsilon} }{\\partial \\tilde{p_i}} = \\frac{(p_a-p_b)\\hat{}}{|p_a-p_b|}而对于点到平面的距离(面特征): d_{H} = (\\tilde{p_i}-p_j) \\cdot \\frac{|(p_l-p_j) \\times (p_m-p_j)|}{|(p_l-p_j) \\times (p_m-p_j)|}面特征的残差雅可比计算: J_{H} = \\frac{\\partial d_{H} }{\\partial T } = \\frac{\\partial d_{H} }{\\partial \\tilde{p_i}} \\frac{\\partial \\tilde{p_i}}{\\partial T } \\\\前面线特征已计算出等式右边第二项,第一项为: \\frac{\\partial d_{H} }{\\partial \\tilde{p_i}} = \\frac{|(p_l-p_j)\\times(p_m-p_j)|}{|(p_l-p_j)\\times(p_m-p_j)|}3. 里程计在代码中是直接使用ceres进行求解,上面的雅克比矩阵都直接从ceres中自动求导了,代码详见LOAM_code解析。求导完后我们就得到了相对位姿的矩阵,可以通过上一帧的位姿转换到当前帧,然后把当前帧作为下一帧的上一帧,就完成了迭代。从而得到了里程计的功能。"},{"title":"激光SLAM学习 几何基础","date":"2022-10-27T06:23:32.157Z","url":"/2022/10/27/SLAM/4_Geometry/","tags":[["Deep learning","/tags/Deep-learning/"],["SLAM","/tags/SLAM/"],["几何","/tags/%E5%87%A0%E4%BD%95/"]],"categories":[["undefined",""]],"content":"几何基础在应用激光雷达算法之前,我们先对几何基础进行学习。 向量运算及其几何意义 内积内积,即数量积,点乘。定义如下: \\vec{a} = (x_1,y_1,z_1) \\vec{b} = (x_2,y_2,z_2) \\vec{a} \\cdot \\vec{b} = x_1x_2 + y_1y_2 + z_1z_2对于几何意义,则是a在b上的投影后的积: \\vec{a} \\cdot \\vec{b} = |{a}||{b}|\\cos{\\theta} 外积外积,即向量积,叉乘。定义如下: \\vec{a} = (x_1,y_1,z_1) \\\\ \\vec{b} = (x_2,y_2,z_2)\\\\ \\vec{a} \\times \\vec{b} = \\begin{bmatrix} i & j & k \\\\ x_1 & y_1 & z_1 \\\\ x_2 & y_2 & z_2 \\end{bmatrix}x_1x_2 + y_1y_2 + z_1z_2 \\\\ = (y_1z_2 - y_2z_1)i - (x_1z_2 - x_2z_1)j + (x_1y_2-x_2y_1)k对于几何意义,外积的模长则是a和b组成的平行四边形的面积: \\vec{a} \\times \\vec{b} = \\underbrace{|{\\vec{a}}|\\sin{\\theta}}_{高} |{\\vec{b}}| 外积的方向满足右手定则,由a和b张成平面的(单位)法向量n为: \\vec{n} = \\frac{\\vec{a} \\times \\vec{b} }{|\\vec{a} \\times \\vec{b}|} 微分性质对于内积微分有: \\frac{\\partial{\\vec{a} \\cdot \\vec{b}}}{\\partial{\\vec{a}}} = \\vec{b}对于外积微分有: \\vec{a} \\times \\vec{b} = \\hat{a} b其中[a]^为a的反对称矩阵。 \\hat{a} b = \\hat{[b]}a \\\\ \\frac{\\partial{\\hat{a} b}}{\\partial{\\vec{a}}} = -\\hat{[b]} 线面特征运算 点到直线的距离(平面内)点A到直线BC的距离为平行四边形面积除以对角线长度: |\\vec{AD}| = \\frac{|\\vec{AB} \\times \\vec{AC}|}{|\\vec{BC}|} 点到平面距离(空间内)首先要求出平面BCD的法向量,再求出该点与该平面与相交的线在法向量上的投影平面BCD的单位法向量为: \\vec{n} = \\frac{\\vec{BC} \\times \\vec{BD} }{|\\vec{BC} \\times \\vec{BD}|}然后点A到平面BCD的距离就可以由AB到法向量的投影求得: \\vec{AE} =|\\vec{AB}|\\cos{\\theta} = \\vec{AB} \\cdot \\vec{n} "},{"title":"激光SLAM学习 点云畸变补偿","date":"2022-10-25T13:05:12.337Z","url":"/2022/10/25/SLAM/3_Distortion/","tags":[["Deep learning","/tags/Deep-learning/"],["SLAM","/tags/SLAM/"],["畸变补偿","/tags/%E7%95%B8%E5%8F%98%E8%A1%A5%E5%81%BF/"]],"categories":[["undefined",""]],"content":"点云畸变补偿激光雷达通过发射激光束来测量周围环境物体的距离和方位,从而判断车辆与障碍物的相对位置。当其发射的激光束足够多时,这一个个的激光点将汇集成一片点云,勾勒出其所处的三维环境信息,这便是我们常说的点云数据。对于多数激光雷达而言,尽管激光的发射与接收很快,但构成点云的每一个点仍非同一时刻生成的。一般我们会将100ms (对应典型值10Hz) 内累积的数据作为一帧点云输出。若在这100ms内,激光雷达本体或安装所在的机体发生绝对位置的变化,那么此帧点云中每一个点的坐标系就是不同的。直观上看,这一帧点云数据就会发生一定的“变形”,不能真实对应所探测到的环境信息,类似于拍照时手抖了,拍出来的照片就会糊。这便是激光雷达的自运动畸变。引自知乎Livox 览沃激光雷达 自运动畸变由于激光雷达自身所在的载体坐标系发生改变时,会导致激光雷达坐标系运动,在一定时间内扫描的一圈不能闭合,包括旋转和平移,如下图:由图可知,平移会导致圆形的破坏,导致圆心的偏移;而旋转会导致部分的点相对于起始角有角度偏移。二者均会导致获得的点云产生畸变,在输入到SLAM前,对其纠正是必要的。 补偿方法需要对每个激光点坐标作补偿,补偿量为激光点原点(当时雷达的坐标)相对于起始时刻的变化,即计算时刻0(起始时刻)到时刻i(当前时刻)发生的旋转和平移变化。数学表示如下: 假设一帧点云中,起始时刻0雷达的位姿为: T_0 = \\begin{bmatrix} R_0 & t_0 \\\\ 0 & 1 \\end{bmatrix}在时刻i(第i帧),雷达的位姿为: T_i = \\begin{bmatrix} R_i & t_i \\\\ 0 & 1 \\end{bmatrix}第i个激光点的坐标为: P_i = \\begin{bmatrix} p_{ix} & p_{iy} & p_{iz} \\end{bmatrix}经过位姿测量,补偿后的激光点的坐标为: \\vec{P_i} = T_0^{-1}T_i P_i也可以通过平均角速度$w$和速度$v$来算出来对应的$R_i$和$t_i$: R_i = w d_{time} \\\\ t_i = v d_{time}该位姿变化可以使用角速度、线速度的输入,或者imu、编码器等外接传感器来计算其相对位姿,也可以使用slam的相对位姿(效果稍差)。 "},{"title":"激光SLAM学习 正态分布变换NDT","date":"2022-10-24T14:57:19.385Z","url":"/2022/10/24/SLAM/2_NDT/","tags":[["Deep learning","/tags/Deep-learning/"],["SLAM","/tags/SLAM/"],["NDT","/tags/NDT/"]],"categories":[["undefined",""]],"content":"正态分布变换 Normal Distribution Transformation正态分布是用于描述一个变量的概率分布中的一种,在SLAM中是将点云的分布用正态分布进行描述。其基本流程如下图:其概率指的是待匹配点云与目标点云他们栅格的点统计的数目,计算了均值,协方差就可构建其相关的正态分布。 问题描述 基于NDT的问题描述和输入描述如下:点集: X = \\{x_1,x_2, ... , x_{N_x}\\}Y = \\{y_1,y_2, ... , y_{N_y}\\}其中X和Y是原始点云的子集,选取的是两个点集中能够互相关联的点集,$N_x = N_y$目标函数: max \\Psi =max \\prod_{i=1}^{N_y} f(X,T(p,y_i))目标函数由原来的点到点之间的欧式距离计算变为了联合概率。f代表的是概率密度函数,X代表的是待匹配点集,$T(P,Y_i)$代表的是其空间转换函数,其中p代表的姿态变换,用于对$y_i$进行移动。 对于2D模型:$p = p_3 = [t_x t_y \\phi _z]^T$ 对于3D模型:$p = p_6 = [t_x t_y t_z \\phi _x \\phi _y \\phi _z]^T$ 概率模型计算对于点云概率分布的计算,需要计算其均值和协方差。 均值: \\mu = \\frac{1}{N_x} \\sum_{i=1}^{N_x} x_i \\\\ 协方差: E = \\frac{N_x -1}{1} \\sum_{i=1}^{N_x} (x_i - \\mu) (x_i - \\mu)^T对于目标函数中的预测的位姿,根据初始值R和t对点进行旋转平移得到Y,获得在同一坐标系下的X和Y。 预测值: $y\\prime _i = T(p,y_i) = Ry_i + t$根据定义即可计算各点的联合概率: f(X,y\\prime _i) = \\frac{1} {\\sqrt{2\\pi}\\sqrt{|E|}} exp(-\\frac{(y\\prime _i-\\mu)^TE^{-1}(y\\prime _i-\\mu)}{2})所有点的联合概率: \\begin{equation} \\begin{split} \\Phi &= \\prod_{i=1}^{N_y} f(X,T(p,y_i)) \\\\ &= \\prod_{i=1}^{N_y} \\frac{1} {\\sqrt{2\\pi}\\sqrt{|E|}} exp(-\\frac{(y\\prime _i-\\mu)^TE^{-1}(y\\prime _i-\\mu)}{2}) \\\\ \\end{split} \\nonumber \\end{equation}取对数,最后一项为常数: ln \\Phi = \\sum_{i=1}^{N_y}(-\\frac{(y\\prime _i-\\mu)^TE^{-1}(y\\prime _i-\\mu)}{2}+ln(\\frac{1} {\\sqrt{2\\pi}\\sqrt{|E|}}))所以目标函数则可以转化为: max \\Psi = max ln\\Psi = min\\sum_{i=1}^{N_y}(y\\prime _i-\\mu)^TE^{-1}(y\\prime _i-\\mu)由该目标函数中可以定义出残差函数$f_i(p)=y\\prime _i-\\mu$,根据高斯牛顿法进行计算,残差函数关于待求参数的雅可比,便可迭代优化。 J_i = \\frac{dp}{df_i(p)}这里的p其实就是前面的姿态变换矩阵,对其求偏导,对于2D模型的求导过程如下: p = p_3 = [t_x t_y \\phi _z]^T \\\\ \\begin{equation} \\begin{split} y\\prime _i &= T(p,y_i) \\\\ &= \\begin{bmatrix} cos \\phi _z & -sin \\phi _z \\\\ sin \\phi _z & cos \\phi _z \\end{bmatrix} y_i + \\begin{bmatrix} t_x \\\\ t_y \\end{bmatrix} \\end{split} \\nonumber \\end{equation}\\\\ 雅可比矩阵J_i = \\begin{bmatrix} 1 & 0 & -y_{i1} sin \\phi _z - -y_{i2} cos \\phi _z\\\\ 0 & 1 & y_{i1} cos \\phi _z - -y_{i2} sin \\phi _z \\end{bmatrix} 三维场景下同样能求出对应的雅可比矩阵,这里用图进行表示: 代码:"},{"title":"激光SLAM学习 迭代最近邻点算法","date":"2022-10-24T07:51:41.516Z","url":"/2022/10/24/SLAM/1_ICP/","tags":[["AI","/tags/AI/"],["Deep learning","/tags/Deep-learning/"],["SLAM","/tags/SLAM/"]],"categories":[["undefined",""]],"content":"迭代最近邻点算法 Iterative Closest Point该方法为最简单暴力的匹配算法,根据问题描述中的目标函数,对目标函数进行推导。 问题描述 前端里程计的问题描述和输入描述如下:点集: X = \\{x_1,x_2, ... , x_{N_x}\\}Y = \\{y_1,y_2, ... , y_{N_y}\\}其中X和Y是原始点云的子集,选取的是两个点集中能够互相关联的点集,$N_x = N_y$目标函数: minE(R,T)=min\\frac{1}{N_y} \\sum_{i=1}^{N_y} \\|x_i - Ry_i - t\\|^2其中R和T分别为旋转矩阵和平移矩阵,E代表均方差。求得R和T使得他们的欧式距离的均方差E最小,这是最基本的目标函数。 (1)基于奇异值分解(SVD)的ICPSVD的方法首先第一步将加了几部分进来,进行转变 \\begin{equation} \\begin{split} E(R,T) &= \\frac{1}{N_y} \\sum_{i=1}^{N_y} \\|x_i - Ry_i - t + -u_x + Ru_y +u_x - Ru_y \\|^2 \\\\ &= \\frac{1}{N_y} \\sum_{i=1}^{N_y} \\|x_i -u_x - R(y_i - u_y)+ (u_x - Ru_y - t )\\|^2 \\\\ & 这里根据平方差公式展开\\\\ &= \\frac{1}{N_y} \\sum_{i=1}^{N_y} (\\|x_i -u_x - R(y_i - u_y)\\|^2 + \\|(u_x - Ru_y - t )\\|^2 \\\\ & +2(x_i -u_x - R(y_i - u_y))^T(u_x - Ru_y - t )) \\end{split} \\nonumber \\end{equation}其中$u_x$和$u_y$分别是点集X和Y的质心,即 u_x = \\frac{1}{N_x} \\sum_{i=1}^{N_x} x_i \\\\ u_y = \\frac{1}{N_y} \\sum_{i=1}^{N_y} y_i结合前面的求和可知$x_i -u_x - R(y_i - u_y)$项为0,E(R,T)变为如下 E(R,T) = \\frac{1}{N_y} \\sum_{i=1}^{N_y} (\\|x_i -u_x - R(y_i - u_y)\\|^2 + \\|(u_x - Ru_y - t )\\|^2)将其拆分为两部分: E_1(R,T) = \\frac{1}{N_y} \\sum_{i=1}^{N_y} \\|x_i -u_x - R(y_i - u_y)\\|^2 \\\\ E_2(R,T) = \\frac{1}{N_y} \\sum_{i=1}^{N_y} \\|(u_x - Ru_y - t )\\|^2 由$E_2$的性质可知,对于任意的一个R,都可以找到一个t使得$u_x - Ru_y - t = 0$,所以不需要求$E_2$,只需要求$E_1$,得到R之后,自然得到t。对$E_1$进行推导: \\begin{equation} \\begin{split} E\\prime _1(R,T) &= \\frac{1}{N_y} \\sum_{i=1}^{N_y} \\|x_i -u_x - R(y_i - u_y)\\|^2 \\\\ &= \\frac{1}{N_y} \\sum_{i=1}^{N_y} \\|x\\prime _i - R(y\\prime _i)\\|^2 \\\\ &= \\frac{1}{N_y} \\sum_{i=1}^{N_y} ( x\\prime _i^T x\\prime _i+ y\\prime _i^T R^T Ry\\prime _i - 2x\\prime _i^T Ry\\prime _i) \\end{split} \\nonumber \\end{equation} 该式中,第一项与R无关,而第二项二单位阵,只与第三项有关,则目标函数变为: \\begin{equation} \\begin{split} E\\prime _1(R,t) &= arg\\underset {R}{max} \\sum_{i=1}^{N_y} x\\prime _i^T Ry\\prime _i \\\\ &= arg\\underset {R}{max} \\sum_{i=1}^{N_y} Trace(x\\prime _i^T Ry\\prime _i) \\\\ & 由 trace(AB) = trace(BA) \\\\ &= arg\\underset {R}{max} \\sum_{i=1}^{N_y} Trace(Ry\\prime _i x\\prime _i^T ) \\\\ &= arg\\underset {R}{max} Trace(RH) \\\\ 其中H = \\sum_{i=1}^{N_y} y\\prime _i x\\prime _i^T \\end{split} \\nonumber \\end{equation} 至此,需要对该矩阵转变为正定矩阵,并进行分解定理:若存在正定矩阵$AA^T$,一定存在任意正交矩阵B,使得$Trace(AA^T) \\geq Trace(BAA^T) $意义:若能找到R,使得RH变为正定矩阵,则找到最大值,满足目标函数 对H进行奇异值分解: H = UEV^T = y\\prime _i x\\prime _i^T\\\\ 若R = VU^T \\\\ 则RH = VU^T UE V^T =VE V^T = VE^{\\frac 12} (VE^{\\frac 12})^T在这里其实由H的定义可知U即$y\\prime _i$,V即$x\\prime _i^T$。 接下来我们对实现代码进行讲解 (2)基于凸优化的ICP首先对凸优化本身进行一些基础讲解,它对什么样的问题有进行什么操作? 凸优化基础 优化任务的目标凸优化是对n维的变量$x^* \\in \\frak{R} ^n$,使得损失函数F(x)取得局部最小值: \\underset {x}{min} F(x) = \\frac 12 \\|f(x) \\|_2^2局部最小值指对任意的$|x - x^ | < \\sigma $,都有$F(x^) \\leq F(x) $, F(x)代表的是损失函数,用以衡量真实值 y和预测值 f(x)之间不一致的程度,一般越小越好。为了便于不同损失函数的比较,常将其表示为单变量的函数,即关于f(x)的表达式作为残差函数,这个残差函数可以代表预测和观测,也可以是匹配的时候的点的距离,可以由多个残差函数组成。 迭代方法的思路 给定初值$x_0$; 对于第k次迭代,寻找增量$\\Delta x_k$,使得$|x_k + \\Delta x_k |_2^2$达到极小值; 如果达到足够小的值,则停止;否则返回第2步,继续迭代。 迭代下降求解优化的方法对损失函数进行泰勒展开可以得到: F(x + \\Delta x) \\approx F(x) + J \\Delta x + \\frac 12 \\Delta x^T H \\Delta x其中J为X的一阶导(雅可比矩阵,Jacobian),H为X的二阶导(海森矩阵,Hessian) 最速下降法 只保留一阶泰勒展开,增量$\\Delta x^* = -J^T$,沿梯度的反方向取增量,保证损失函数减少。优点: 简单、迭代方便缺点:精度有限、接近目标值时会下降变慢 牛顿法 保留二阶泰勒展开,增量方程为 \\Delta x^* = argmin (F(x) + J\\Delta x + \\frac 12 \\Delta x^TH\\Delta x求其最小值即求该方程的导数为0,即 J^T + H\\Delta x = 0 \\Rightarrow H\\Delta x = -J^T优点: 更精确,每一步收敛更准确;收敛速度快缺点:当规模变大时,H矩阵的计算比较难 高斯牛顿法 原先是对其损失函数即残差函数的一个二范数求最小值,而高斯牛顿法是直接对残差函数进行泰勒展开,同时保留其一阶导求雅可比矩阵:问题变为寻找增量$\\Delta x$使得$| f(x+\\Delta x)|^2$达到最小: \\Delta x^* = arg\\underset {\\Delta x}{min} \\frac 12 \\| f(x + J\\Delta x)\\|^2同样地,需要对其求导且导数为0的情况下为最小,展开为: \\begin{equation} \\begin{split} \\frac 12 \\| f(x + J\\Delta x)\\|^2 &= \\frac 12(f(x) + J\\Delta x)^T(f(x) + J\\Delta x) \\\\ &= \\frac 12( \\| f(x) \\|_2^2 + 2f(x)J\\Delta x + \\Delta x^T J^T J \\Delta x ) \\end{split} \\end{equation}对其求导并令其为0,则得到 \\underbrace{J^T f(x)}_{g} + \\underbrace{J^T J}_{H} \\Delta x = 0 \\\\ 即 \\Delta x = H^{-1}g优点: 用$J^TJ$代替牛顿法中的H,则不需要二阶导数缺点:但是求解必须保证H矩阵是可逆的,而$J^TJ$只能保证半正定,算法稳定性变差,最终难以收敛。 在SLAM中的凸优化 基于凸优化的ICP问题,我们将原来的目标函数重新说明一下: minE(R,t)=min\\frac{1}{N_y} \\sum_{i=1}^{N_y} \\|x_i - Ry_i - t\\|^2使用矩阵T对R和t进行表示: T = \\quad \\begin{bmatrix} R & t \\\\ 0 & 1 \\end{bmatrix}目标函数变为: \\underset{T}{min} \\frac 12 \\sum_{i=1}^{N_y} \\|x_i - Ty_i\\|_2^2还有相对应的李代数变换,目前还不会先不记录了。接下来我们对实现代码进行讲解: "},{"title":"Cmd Markdown 公式指导手册","date":"2022-10-24T06:14:21.731Z","url":"/2022/10/24/tools/mathjax_tutorial_mdeditor_220713/","tags":[["Markdown","/tags/Markdown/"]],"categories":[["undefined",""]],"content":" 本文为 MathJax 在 Cmd Markdown 环境下的常用语法指引。Cmd Markdown 编辑阅读器支持 $\\LaTeX$ 编辑显示支持,例如:$\\sum_{i=1}^n a_i=0$,访问 MathJax 以参考更多使用方法。 右键点击每一个公式,选择 [Show Math As] → [TeX Commands] 以查看该公式的命令详情。 [TOC] 一、公式使用参考1.如何插入公式$\\TeX$ 可使用行中公式放在文中与其它文字混编,或单独成行的独立公式。 行中公式可以用如下方法表示: : $ 表达式 $ 独立公式可以用如下方法表示: : 表达式 自动编号的公式可以用如下方法表示:: 若需要手动编号,可在公式后使用 \\tag{编号} 语句。 : \\begin{equation} 表达式 \\label{eq:当前公式名}\\end{equation} : 自动编号后的公式可在全文任意处使用 \\eqref{eq:公式名} 语句引用。 例子: 显示: $ J\\alpha(x) = \\sum{m=0}^\\infty \\frac{(-1)^m}{m! \\Gamma (m + \\alpha + 1)} {\\left({ \\frac{x}{2} }\\right)}^{2m + \\alpha} \\text {,行内公式示例} $ 例子: 显示: J_\\alpha(x) = \\sum_{m=0}^\\infty \\frac{(-1)^m}{m! \\Gamma (m + \\alpha + 1)} {\\left({ \\frac{x}{2} }\\right)}^{2m + \\alpha} \\text{,独立公式示例,使用 \\tag 手动编号} \\tag{0.1} 例子: 显示: 在公式 \\eqref{eq:sample} 中,我们看到了这个被自动编号的公式。\\begin{equation} E=mc^2 \\text{,自动编号公式示例} \\label{eq:sample}\\end{equation} 不自动编号的公式可以用如下方法表示: : \\begin{equation} 表达式\\end{equation} 2.如何输入上下标^ 表示上标,_ 表示下标。如果上下标的内容多于一个字符,需要用 {} 将这些内容括成一个整体。上下标可以嵌套,也可以同时使用。 例子: 显示:x^{y^z}=(1+{\\rm e}^x)^{-2xy^w} 如果要在左右两边都有上下标,可以使用 \\sideset 命令;也可以简单地在符号前面多打一个上下标,此时会以行内公式渲染。本例内 \\quad 均为空格符号,为方便公式格式对比而添加,请注意辨别。详见在字符间加入空格。 例子: 显示:\\sideset{^1_2}{^3_4}\\bigotimes \\quad or \\quad {^1_2}\\bigotimes {^3_4} 3.如何输入括号和分隔符()、[] 和 | 表示符号本身,使用 \\{\\} 来表示 {} 。当要显示大号的括号或分隔符时,要用 \\left 和 \\right 命令。 一些特殊的括号:|输入|显示|输入|显示||—:|:—|—:|:—||\\langle|$\\langle$|\\rangle|$\\rangle$||\\lceil|$\\lceil$|\\rceil|$\\rceil$||\\lfloor|$\\lfloor$|\\rfloor|$\\rfloor$||\\lbrace|$\\lbrace$|\\rbrace|$\\rbrace$||\\lvert|$\\lvert$|\\rvert|$\\rvert$||\\lVert|$\\lVert$|\\rVert|$\\rVert$| @lymd 有时,我们需要在行内使用两个竖杠表示向量间的某种空间距离,可以这样写 \\lVert \\boldsymbol{X}_i - \\boldsymbol{S}_j \\rVert^2 → $\\lVert \\boldsymbol{X}_i - \\boldsymbol{S}_j \\rVert^2$ 例子: 显示:f(x,y,z) = 3y^2z \\left( 3+\\frac{7x+5}{1+y^2} \\right) 4.如何输入分数通常使用 \\frac {分子} {分母} 来生成一个分数,分数可多层嵌套。若分数只有一层,也可使用 分子 \\over 分母 命令。例内 \\quad \\mid \\, 等均为空格或分隔符号,为方便公式格式对比而添加,请注意辨别。详见在字符间加入空格。 例子: 显示:\\frac{a-1}{b-1} \\quad or \\quad {a+1 \\over b+1} 当分式 仅有两个字符时 可直接输入 \\frac ab 来快速生成一个 $\\Large\\frac ab$ 。 例子: 显示:\\frac 12,\\frac 1a,\\frac a2 \\quad \\mid \\quad \\text{2 letters only:} \\quad \\frac 12a \\,, k\\frac q{r^2} 5.如何输入开方使用 \\sqrt [根指数,省略时为2] {被开方数} 命令输入开方。本例内 \\quad 均为空格符号,为方便公式格式对比而添加,请注意辨别。详见在字符间加入空格。 例子: 显示:\\sqrt{2} \\quad or \\quad \\sqrt[n]{3} 6.如何输入省略号数学公式中常见的省略号有两种,\\ldots 表示与 文本底线 对齐的省略号,\\cdots 表示与 文本中线 对齐的省略号。 例子: 显示:f(x_1,x_2,\\underbrace{\\ldots}_{\\rm ldots} ,x_n) = x_1^2 + x_2^2 + \\underbrace{\\cdots}_{\\rm cdots} + x_n^2 7.如何输入向量使用 \\vec{向量} 来自动产生一个向量。也可以使用 \\overrightarrow 等命令自定义字母上方的符号。例内 \\quad \\mid \\, 等均为空格或分隔符号,为方便公式格式对比而添加,请注意辨别。详见在字符间加入空格。 例子: 显示:\\vec{a} \\cdot \\vec{b}=0 例子: 显示:xy \\text{ with arrows:} \\quad \\overleftarrow{xy} \\; \\mid \\; \\overleftrightarrow{xy} \\; \\mid \\; \\overrightarrow{xy} 8.如何输入积分使用 \\int_积分下限^积分上限 {被积表达式} 来输入一个积分。 例子:显示:\\int_0^1 {x^2} \\,{\\rm d}x 本例中 \\, 和 {\\rm d} 部分可省略,但加入能使式子更美观,详见在字符间加入空格及如何进行字体转换。 9.如何输入极限运算使用 \\lim_{变量 \\to 表达式} 表达式 来输入一个极限。如有需求,可以更改 \\to 符号至任意符号。 例子:显示:\\lim_{n \\to \\infty} \\frac{1}{n(n+1)} \\quad and \\quad \\lim_{x\\leftarrow{示例}} \\frac{1}{n(n+1)} 10.如何输入累加、累乘运算使用 \\sum_{下标表达式}^{上标表达式} {累加表达式} 来输入一个累加。与之类似,使用 \\prod \\bigcup \\bigcap 来分别输入累乘、并集和交集,更多符号可参考“其它特殊字符”。 此类符号在行内显示时上下标表达式将会移至右上角和右下角,如 \\sum_{i=1}^n \\frac{1}{i^2} 显示为 $\\sum_{i=1}^n \\frac{1}{i^2}$ ; 或: @woria 在行内可使用 \\sum\\limits_{下标表达式}^{上标表达式} {累加表达式} 使上下标仍在正上正下方。 如 \\sum\\limits_{i=1}^n \\frac{1}{i^2} 显示为 $\\sum\\limits_{i=1}^n \\frac{1}{i^2}$ 。 本例内 \\quad 均为空格符号,为方便公式格式对比而添加,请注意辨别。详见在字符间加入空格。 例子: 显示:\\sum_{i=1}^n \\frac{1}{i^2} \\quad and \\quad \\prod_{i=1}^n \\frac{1}{i^2} \\quad and \\quad \\bigcup_{i=1}^{2} \\Bbb{R} 11.如何输入希腊字母输入 \\小写希腊字母英文全称 和 \\首字母大写希腊字母英文全称 来分别输入小写和大写希腊字母。对于大写希腊字母与现有字母相同的,直接输入大写字母即可。 输入 显示 输入 显示 输入 显示 输入 显示 \\alpha $\\alpha$ A $A$ \\beta $\\beta$ B $B$ \\gamma $\\gamma$ \\Gamma $\\Gamma$ \\delta $\\delta$ \\Delta $\\Delta$ \\epsilon $\\epsilon$ E $E$ \\zeta $\\zeta$ Z $Z$ \\eta $\\eta$ H $H$ \\theta $\\theta$ \\Theta $\\Theta$ \\iota $\\iota$ I $I$ \\kappa $\\kappa$ K $K$ \\lambda $\\lambda$ \\Lambda $\\Lambda$ \\mu $\\mu$ M $M$ \\nu $\\nu$ N $N$ \\xi $\\xi$ \\Xi $\\Xi$ o $o$ O $O$ \\pi $\\pi$ \\Pi $\\Pi$ \\rho $\\rho$ P $P$ \\sigma $\\sigma$ \\Sigma $\\Sigma$ \\tau $\\tau$ T $T$ \\upsilon $\\upsilon$ \\Upsilon $\\Upsilon$ \\phi $\\phi$ \\Phi $\\Phi$ \\chi $\\chi$ X $X$ \\psi $\\psi$ \\Psi $\\Psi$ \\omega $\\omega$ \\Omega $\\Omega$ 部分字母有变量专用形式,以 \\var- 开头。 小写形式 大写形式 变量形式 显示 \\epsilon E \\varepsilon $\\epsilon \\mid E \\mid \\varepsilon$ \\theta \\Theta \\vartheta $\\theta \\mid \\Theta \\mid \\vartheta$ \\rho P \\varrho $\\rho \\mid P \\mid \\varrho$ \\sigma \\Sigma \\varsigma $\\sigma \\mid \\Sigma \\mid \\varsigma$ \\phi \\Phi \\varphi $\\phi \\mid \\Phi \\mid \\varphi$ 12.如何输入其它特殊字符 完整的 $\\LaTeX$ 可用符号列表可以在 这份文档 中查阅(极长,共 348 页),大部分常用符号可以参阅 这份精简版文档 查询。需要注意的是,$\\LaTeX$ 符号并不保证在 MathJax v2.2 中可用,即在 Cmd Markdown 编辑阅读器中可能并不支持所输入的特定命令。 若需要显示更大或更小的字符,在符号前插入 \\large 或 \\small 命令。MathJax 针对任意元素均提供从小至大 \\tiny \\Tiny \\scriptsize \\small *默认值 \\normalsize \\large \\Large \\LARGE \\huge \\Huge 共十种渲染大小,详见官方文档。 若找不到需要的符号,推荐使用 $\\large\\rm{Detexify}$ 来画出想要的符号 (1).关系运算符 输入 显示 输入 显示 输入 显示 输入 显示 \\pm $\\pm$ \\times $\\times$ \\div $\\div$ \\mid $\\mid$ \\nmid $\\nmid$ \\cdot $\\cdot$ \\circ $\\circ$ \\ast $\\ast$ \\odot $\\odot$ \\otimes $\\otimes$ \\oplus $\\oplus$ \\leq $\\leq$ \\geq $\\geq$ \\neq $\\neq$ \\approx $\\approx$ \\equiv $\\equiv$ \\sum $\\sum$ \\prod $\\prod$ \\coprod $\\coprod$ \\backslash $\\backslash$ (2).集合运算符 输入 显示 输入 显示 输入 显示 \\emptyset $\\emptyset$ \\in $\\in$ \\notin $\\notin$ \\subset $\\subset$ \\supset $\\supset$ \\subseteq $\\subseteq$ \\supseteq $\\supseteq$ \\cap $\\cap$ \\cup $\\cup$ \\vee $\\vee$ \\wedge $\\wedge$ \\uplus $\\uplus$ \\top $\\top$ \\bot $\\bot$ \\complement $\\complement$ (3).对数运算符 输入 显示 输入 显示 输入 显示 \\log $\\log$ \\lg $\\lg$ \\ln $\\ln$ (4).三角运算符 输入 显示 输入 显示 输入 显示 \\backsim $\\backsim$ \\cong $\\cong$ \\angle A $\\angle A$ \\sin $\\sin$ \\cos $\\cos$ \\tan $\\tan$ \\csc $\\csc$ \\sec $\\sec$ \\cot $\\cot$ (5).微积分运算符 输入 显示 输入 显示 输入 显示 \\int $\\int$ \\iint $\\iint$ \\iiint $\\iiint$ \\partial $\\partial$ \\oint $\\oint$ \\prime $\\prime$ \\lim $\\lim$ \\infty $\\infty$ \\nabla $\\nabla$ (6).逻辑运算符 输入 显示 输入 显示 输入 显示 \\because $\\because$ \\therefore $\\therefore$ \\neg $\\neg$ \\forall $\\forall$ \\exists $\\exists$ \\not\\subset $\\not\\subset$ \\not< $\\not<$ \\not> $\\not>$ \\not= $\\not=$ @xiaobanni \\vdash 显示为 $\\vdash$ (7).戴帽符号 输入 显示 输入 显示 输入 显示 \\hat{xy} $\\hat{xy}$ \\widehat{xyz} $\\widehat{xyz}$ \\bar{y} $\\bar{y}$ \\tilde{xy} $\\tilde{xy}$ \\widetilde{xyz} $\\widetilde{xyz}$ \\acute{y} $\\acute{y}$ \\breve{y} $\\breve{y}$ \\check{y} $\\check{y}$ \\grave{y} $\\grave{y}$ \\dot{x} $\\dot{x}$ \\ddot{x} $\\ddot{x}$ \\dddot{x} $\\dddot{x}$ 若需要在特定文字顶部\\底部放置内容,可使用 \\overset{顶部内容}{正常内容} 和 \\underset{底部内容}{正常内容} 命令。例内 \\qquad \\quad \\mid \\; \\, 等均为空格或分隔符号,为方便公式格式对比而添加,请注意辨别。详见在字符间加入空格。 例子: 显示: \\verb+\\overset{above}{level}+ \\qquad \\overset{xx}{ABC} \\;\\; \\mid \\quad \\overset{x^2}{\\longmapsto}\\ \\, \\mid \\quad \\overset{\\bullet\\circ\\circ\\bullet}{T} 例子: 显示:\\verb+\\underset{below}{level}+ \\qquad \\underset{xx}{ABC} \\;\\; \\mid \\quad \\underset{x^2}{\\longmapsto}\\ \\, \\mid \\quad \\underset{\\bullet\\circ\\circ\\bullet}{T} 此命令可叠加嵌套使用,生成类似化学反应式的多重条件符号,如 \\overset{H_2}{\\underset{1300℃}{\\Longleftrightarrow}}: \\rm{SrO+V^{''}_{Sr} \\overset{H_2}{\\underset{1300℃}{\\Longleftrightarrow}} Sr^{\\times}_{Sr}+2e^{'}+\\frac 12O_2(g)} $$ 和 `\\overset{Surface/bulk}{\\underset{diffusion}{\\longleftrightarrow}}`: $$ \\rm{2OH^{\\circ}_{O(STN)}+2O^{\\times}_{O(YSZ)} \\; \\overset{Surface/bulk}{\\underset{diffusion}{\\longleftrightarrow}} \\;\\; 2OH^{\\circ}_{O(YSZ)}+2O^{\\times}_{O(STN)}}在书写化学方程式时可声明 \\require{AMDcd} 语句,使用 MathJax 内置的交换图表功能,具体例子可参见下文。 (8).连线符号其它可用的文字修饰符可参见官方文档 “Additional decorations”。 输入 显示 \\fbox{a+b+c+d} 高级框选需声明 enclose 标签 $\\fbox{a+b+c+d}$ \\overleftarrow{a+b+c+d} $\\overleftarrow{a+b+c+d}$ \\overrightarrow{a+b+c+d} $\\overrightarrow{a+b+c+d}$ \\overleftrightarrow{a+b+c+d} $\\overleftrightarrow{a+b+c+d}$ \\underleftarrow{a+b+c+d} $\\underleftarrow{a+b+c+d}$ \\underrightarrow{a+b+c+d} $\\underrightarrow{a+b+c+d}$ \\underleftrightarrow{a+b+c+d} $\\underleftrightarrow{a+b+c+d}$ \\overline{a+b+c+d} $\\overline{a+b+c+d}$ \\underline{a+b+c+d} $\\underline{a+b+c+d}$ \\overbrace{a+b+c+d}^{Sample} $\\overbrace{a+b+c+d}^{Sample}$ \\underbrace{a+b+c+d}_{Sample} $\\underbrace{a+b+c+d}_{Sample}$ \\overbrace{a+\\underbrace{b+c}_{1.0}+d}^{2.0} $\\overbrace{a+\\underbrace{b+c}_{1.0}+d}^{2.0}$ \\underbrace{a\\cdot a\\cdots a}_{b\\text{ times}} $\\underbrace{a\\cdot a\\cdots a}_{b\\text{ times}}$ (9).箭头符号 推荐使用符号:|输入|显示|输入|显示|输入|显示||:—:|:—:|:—:|:—:|:—:|:—:||\\to|$\\to$|\\mapsto|$\\mapsto$|\\underrightarrow{1℃/min} | $\\underrightarrow{1℃/min}$ ||\\implies|$\\implies$|\\iff|$\\iff$|\\impliedby|$\\impliedby$| 其它可用符号:|输入|显示|输入|显示||:—:|:—:|:—:|:—:||\\uparrow|$\\uparrow$|\\Uparrow|$\\Uparrow$||\\downarrow|$\\downarrow$|\\Downarrow|$\\Downarrow$||\\leftarrow|$\\leftarrow$|\\Leftarrow|$\\Leftarrow$||\\rightarrow|$\\rightarrow$|\\Rightarrow|$\\Rightarrow$||\\leftrightarrow|$\\leftrightarrow$|\\Leftrightarrow|$\\Leftrightarrow$||\\longleftarrow|$\\longleftarrow$|\\Longleftarrow|$\\Longleftarrow$||\\longrightarrow|$\\longrightarrow$|\\Longrightarrow|$\\Longrightarrow$||\\longleftrightarrow|$\\longleftrightarrow$|\\Longleftrightarrow|$\\Longleftrightarrow$| 13.如何进行字体转换若要对公式的某一部分字符进行字体转换,可以用 {\\字体 {需转换的部分字符}} 命令,其中 \\字体 部分可以参照下表选择合适的字体。一般情况下,公式默认为斜体字 $italic$ 。 示例中 全部大写 的字体仅大写可用。 输入 全字母可用 显示 输入 仅大写可用 显示 \\rm 罗马体 $\\rm{Sample}$ \\mathcal 花体(数学符号等) $\\mathcal{SAMPLE}$ \\it 斜体 $\\it{Sample}$ \\mathbb 黑板粗体(定义域等) $\\mathbb{SAMPLE}$ \\bf 粗体 $\\bf{Sample}$ \\mit 数学斜体 $\\mit{SAMPLE}$ \\sf 等线体 $\\sf{Sample}$ \\scr 手写体 $\\scr{SAMPLE}$ \\tt 打字机体 $\\tt{Sample}$ \\cal 等同于 \\mathcal $\\cal{ABCXYZ}$ \\frak 旧德式字体 $\\frak{Sample}$ \\Bbb 等同于 \\mathbb $\\Bbb{ABCXYZ}$ @lymd \\boldsymbol{\\alpha} 用来表示向量或者矩阵的加粗斜体,如向量 $\\boldsymbol{\\vec\\alpha}$ 。 转换字体十分常用,例如在积分中: 例子: 显示:\\begin{array}{cc} \\mathrm{Bad} & \\mathrm{Better} \\ \\hline \\ \\int_0^1 x^2 dx & \\int_0^1 x^2 \\,{\\rm d}x\\end{array} 注意比较两个式子间 $dx$ 与 ${\\rm d} x$ 的不同。使用 \\operatorname 命令也可以达到相同的效果,详见定义新的运算符。 14.如何高亮一行公式使用 \\bbox[底色, (可选)边距, (可选)边框 border: 框宽度 框类型 框颜色] 命令来高亮一行公式。底色和框颜色支持详见“更改文字颜色”,边距及框宽度支持 绝对像素 px 或 相对大小 em,框类型支持 实线 solid 或 虚线 dashed。 例子: 显示: \\bbox[yellow]{ e^x=\\lim_{n\\to\\infty} \\left( 1+\\frac{x}{n} \\right)^n \\qquad (1) } 例子: 显示: \\bbox[#9ff, 5px]{ e^x=\\lim_{n\\to\\infty} \\left( 1+\\frac{x}{n} \\right)^n \\qquad (1) } 例子: 显示:$$\\bbox[#2f3542, 0.5em, border:2px solid #f1f2f6]{ \\color "},{"title":"激光SLAM学习 深蓝学院课程 简介","date":"2022-10-21T13:04:11.857Z","url":"/2022/10/21/SLAM/0_Introduction/","tags":[["AI","/tags/AI/"],["Deep learning","/tags/Deep-learning/"],["SLAM","/tags/SLAM/"]],"categories":[["undefined",""]],"content":"简介这是有关激光雷达SLAM的学习,其核心是利用激光雷达传感器以及内置的其他传感器,对周围环境进行构建地图并定位激光雷达所在坐标,即同步定位和建图(Simultaneous Localization and Mapping,SLAM),其流程框架如下图。 整体分为三个部分: • 前端匹配:通过观测点云与目标点云进行匹配得到相对位姿 目标点云:建图时为首帧,定位时为已有地图 • 匹配关键帧:在所有前端匹配帧中,选取最优的作为关键帧 • 后端优化:利用其他传感器进行约束和计算,优化生成地图 前端里程计在课程中的介绍,前端里程计的作用是为了将当前点云与已存在点云进行相对位姿的计算,在当前点云: 在当前时刻帧,激光雷达对周围环境采集的点云已存在点云 :上一帧或已建成地图的点云课程中介绍了多种前端里程计基本算法,分别为以下: 基于直接匹配的方法:整体点云直接匹配,包括ICP(Iterative Closest Point),NDT(Normal Distribution Transformation)等 基于特征:LOAM, A-LOAM, F-LOAM, LEGO-LOAM 多传感器融合里程计: LINS, LIO-SAM, LIO-mapping 基于栅格: cartographer 基于面元: suma 基于语义: segmap, suma++ 其中课程中主要对前三个进行讲解和分析,并给出实现代码和运行框架。 在其他文章中,对其前端里程计基本算法进行学习和笔记记录,包括公式推导和代码讲解。"},{"title":"深度学习笔记","date":"2022-10-19T13:45:39.211Z","url":"/2022/10/19/DeepLearningByAndrewNg/","tags":[["AI","/tags/AI/"],["Deep learning","/tags/Deep-learning/"]],"categories":[["undefined",""]],"content":"Stanford CS230(吴恩达 深度学习 Deep Learning | Autumn 2018)笔记第零课深度学习是什么?深度学习一般与神经网络是一个同义词,Deep Learning简称DL,与传统的Machine Learning(ML)不同,但是是ML的一部分,也是最难的一部分。 深度学习兴起主要是由于互联网发展以及GPU计算的能力提升,更多数据被电子化以及计算力的大幅提升,使得神经网络变得更大更能解决更多数据带来的问题和潜在的有价值的东西。 一个好的AI团队需要什么? 团队一般具备各种数据采集能力 团队能通过深度学习来对数据进行分析 普遍的自动化 本课程含五个Courses: 什么是神经元?什么是神经网络层?如何将他们堆叠起来搭建神经网络? 如何调整(tune)这些神经网络?如何改进神经网络的效果? 机器学习项目的开发流程 卷积神经网络(CNN Convolutional Neural Network) 序列模型(Sequence Model)如递归神经网络(Recurrent Neural Network) 参考课程视频:对于2中的每一个视频,先到1中看了视频在看2,效果会好一些 2中视频备注如C1M1,代表第一个Courses(一共上面5个),每个有很多modules,一般一个视频两个modules Courses In-class 第一课神经网络的有监督学习建立y(y1,y2…)到x(x1,x2,x3,x4…)的映射关系,我们给出数据包含(x,y)对神经网络进行训练,找到最佳的参数来表达y和x之间的关系。 有监督学习的x输入结构化数据:表格类型的,矩阵类型的数据非结构化数据:声音,图像,文本等 神经网络基础神经网络包含前向过程(forward propagation) 和 反向传播过程(backward propagation)即BP 简单的二元逻辑回归例子 问题模型描述:输入x∈Rnx,是输出y则是label∈{0,1},一共有m个训练样本{(x1,y1),(x2,y2)…(xm,ym)} 对于训练样本的m个输入x,进行堆叠为一个nx × m的矩阵,y同样为1 x m的矩阵 在这里我们使用$\\hat{y}$表示通过算法预测的结果,我们需要它与y形成一个概率的关系,即取值为{0~1},由于直接使用线性函数去拟合,我们输出只有0~1的情况下,有可能会输出负数,或者超过1,这里我们使用一个叫sigmoid函数对线性拟合处理,sigmoid表示为如下 $\\frac{1}{1+e^{-z}}$, 原来y = wTx + b表示为y = $\\delta$ (wTx + b) 梯度下降上述损失函数很好地描述了w和b对Y和$\\hat{y}$之间的的关系,但是我们要得到更好地使得J(w,b)更小,在这里我们提出梯度下降法来求解w和b使得J(w,b)最小。 神经网络的理解 如上图,神经网络可以理解为是一个黑箱,函数,输入图像,经过结构和参数得到里面是否有猫,有=1,无=0,这是一个基本的神经网络的模式。 神经网络模型 = 结构 + 参数 我们的目标就是要找到在结构中最佳的参数来的到最好的结果,我们可以改变这个模式中的很多东西: 输入input,将图片换成其他的数据格式 输出output,改变求解问题,如要求猫的种类(多类分类),猫的年龄(线性回归) 损失函数Loss function,根据与真值的比较定义的误差来更新 结构Architecture,一般以结构来命名神经网络如循环神经网络,卷积神经网络等 激活函数Activation function, 优化器Optiomizer, 超参数Hyperparameters,如学习率,优先的批处理等外部设置的参数 其中几个例子一、分类问题问题描述:给一张图片,要分辨出是猫或不是猫(白天或黑夜)问题分析: 输入:表示为像素矩阵的图片(二维矩阵) 输出:类型(猫或非猫) 损失函数:二元逻辑回归,目标是猫(0),不是猫是(1),设置阈值如(0.5) 结构:有很多如CNN,RCNN等 激活函数:使用sigmoid函数,使得输出保持在0~1之间 如果是多分类问题(分类几种动物)有以下几个解决方法: 单热编码,这样能在一张图片上同时出现两种动物,但这样需要使用softmax激活函数。 训练多神经网络,每一个对应一种动物,这样效率不高不能有效利用。 训练时,需要输入多张带标签的动物图片,在训练时进行带标签(编码)的训练 二、人像识别问题描述:输入人脸后,需要知道是不是对应学生(id)的问题分析: 输入: 表示为像素矩阵的图片(二维矩阵) 输出:判断是否为指定的学生,二分类,设置阈值 损失函数:输入的待认证图像与图像库中的图像进行匹配,向量化的差值基本与上面相同,但比较先进的人脸识别方法应该不是这样的,有一定的改进但总体思路是一样的。 三、风格转移问题描述:给出一张图片的内容和另一张图片的风格,生成1图片内容含2图片风格问题分析: 数据:目标content和目标style图 输入:随机白噪声或带偏置的图(或其他的) 输出:含有content和style的图 损失函数:生成的图片同时与content之间的内容差值和style图之间的style差值 四、语音识别问题描述:给出一段语音,识别出其中的激活词问题分析: 数据:很多包含或不包含(正负样本)激活词的样本集,有两种方式: ①:找很多人录音,手动标记; ②:收集正样本和负样本插入到背景噪音中,可以程序化生成样本并自动标记 输入:一段待识别的语音 输出:对每个时序输出0或1来识别激活词 损失函数:编码后的语音与激活词之间的距离 结构:RNN,LSTM结构 虽然以上方法很好地定义了其中很多内容,但关键影响效果的是结构和它的参数调整能否有效"},{"title":"有关一些文件处理","date":"2022-10-19T13:45:39.158Z","url":"/2022/10/19/tools/DataFile%20Dealing/","categories":[["undefined",""]],"content":"Introduction由于利用mahjong-helper处理麻将牌谱,整理一下几种人工智能数据格式在python中的处理方式。 xls和xlsxpython中对于这两种文件有三个库可以用,xlwt,xlrd和openpyxl,这里以xlrd为例,其他两个大同小异。 excel文档有三个概念,workbook(文档),sheet(表单),cell(单元格),以下是一个demo遍历每一个单元格: csvcsv跟上面的不一样,它默认有表头,并且只能存一张表,用的是pandas的read_csv函数来读的,返回的是pandas的DataFrame对象。 hdf5这个是最复杂的文件结构,它用的是类Unix的文件组织结构来组织文件。在python中用的是h5py的库"},{"title":"Mahjong AI","date":"2022-10-19T13:45:38.565Z","url":"/2022/10/19/mahjong%20AI/","tags":[["AI","/tags/AI/"],["日麻","/tags/%E6%97%A5%E9%BA%BB/"]],"categories":[["undefined",""]],"content":"简介这是一个关于日本麻将人工智能算法的笔记,期望以后能进行推进开发实用。 相关文献 NaoKi Mizukami 水上直紀 多人数性を分割した教師付き学習による四人麻雀プログラムの実現原版 中文版 NaoKi Mizukami 水上直紀 Building a Computer Mahjong Player Based on Monte Carlo Simulation and Opponent Models原版 中文版 NaoKi Mizukami 水上直紀 期待最終順位に基づくコンピュータ麻雀プレイヤの構築原版 Ryouhei KITAGAWA 北川竜平 麻雀の牌譜からの打ち手評価関数の学習原版 NaoKi Mizukami 水上直紀 牌譜を用いた対戦相手のモデル化とモンテカルロ法によるコンピュータ麻雀プレイヤの構築 NaoKi Mizukami 水上直紀 強化学習を用いた効率的な和了を行う麻雀プレイヤ NaoKi Mizukami 水上直紀 多人数不完全情報ゲームにおける仮想自己対戦を用いた強化学習 NaoKi Mizukami 水上直紀 降りるべき局面の認識による1 人麻雀プレイヤの4 人麻雀への適用 感谢译者 零之审判(北京大学数学科学学院 学士毕业) 译者注 译者关于这几篇论文的看法以及理解,很值得一看 感谢本博客基于的是mahjong-helper的代码。该平台支持天凤和雀魂,查看和分析牌谱,实时获取当前数据,并进行分析,同时跨平台支持linux,windows和mac。~日麻杂谈群375865038~ 我在其中添加该算法,使用的是该平台的雀魂平台上进行试验。 日本麻将术语暂时不写了,是日麻基本规则 基于有监督的单人麻将程序 这部分讲述三篇水上直紀大佬写的三篇文章中,关于单人麻将的算法以及它们的基本原理,本人理解有限,希望能复现他们的工作(希望能改进)。 单人麻将的规则所以基本就是一直摸切摸切,有点像第一代雀魂的AI,不会鸣牌(因为单人麻将不能鸣牌),一直摸直到流局或立直。 基于平均感知器的算法这是第一篇文章中的单人麻将的算法,利用的是基于平均感知器的算法来减少向听达成自摸。平均感知器是基于条件随机场的的全局化以最大熵准则建模的函数的一个有监督模型。[1] 算法流程文章中使用的特征量提取模型,是用的2007年北川论文中的特征量。引用译者的翻译: 特征类 特征个数 面子手、七对子、国士无双向听数 15+7+14=36 3色(万、筒、索)中不使用n色(n=1˜ 3)的n和向听数 3×16=48 色的个数(1˜ 4)及各色向听数的组合 12+78+364+1365=1819 各色牌中最多的数量 15 各色牌中最多的数量+字牌数 15 2到8的数牌量 15 面子和不含有幺九的连续2张牌的搭子和面子候补的组合 6+12+72=90 各字牌的枚数和役牌的枚数和是否是宝牌的组合 5×6×2=60 数牌的数字-5的绝对值和枚数和是否是宝牌的组合 5×5×2=50 各色牌中是否有1˜ 9的组合 512 连续的n个数牌中各牌数量的组合(n=2˜ 6) 100+500+1860+8634+23760=34854 我们来分析一下某几个特征量是怎么算出来的,例如第一行中的国士无双向听数,最简单的就是0向听˜13向听,那就是一共14种情况,即特征个数。七对子也是0˜7向听等。 对于所有牌谱中的手牌(局面),当轮到主视角时,手牌有14张,我们来计算切掉每一张牌后,剩下的13张牌所组成的特征量的得分。 $f(x,w)=\\sum_{i=1}^{n}x_iw_i$ 一共有14张牌得分,计算出得分最高的切牌$\\widehat{t}$的得分以及实际切牌$t*$的得分,如果不相同则以实际切牌的为准,并更新权重,根据两个切牌的特征向量,原权重加上实际切牌的权重再减去最高得分切牌权重,更新公式如下 $w^{‘}=w+x{t*}-x\\widehat{t}$ 遍历三遍输入训练数据后,输出权重,根据得分最高的来打牌。 有监督训练集由于使用的是牌谱的有监督学习,且是单人麻将,文章中采用的牌谱是天凤凤凰桌所有局中,第一个立直的人直到立直的所有切牌数据作为训练数据,一共有170万个局面(手牌状况)。但是作者并没有公开这些数据,复现这个方法需要大量的牌谱,而且是顶尖选手的牌谱。 攻防判断——识别是否弃和该部分是识别当前的局面是否应该弃和,在这篇文章中,采用的是二分类法,用了SVM的分类器根据局面上提取的特征来判断是否弃和。同时,如果一个局面被标记为弃和后,之后的所有局面都应标记为弃和。而兜牌是不被标记为弃和的,只是进攻的一个手段。 同时文章提及是否弃和是一个比较主观的定义,是有一些局面的判断是非常难判断的。但考虑到人类玩家弃和的思考方式,采用安全度来判断是否弃和: 标记好数据后,使用SVM分类器,判断是否弃和的特征向量如下,共7+3*8+3=34维。 特征类 数量 自身状态 向听数 1 七对子向听数 1 是否立直 1 是否坐庄 1 副露数 1 副露的宝牌数 1 手牌宝牌数 1 对手状态 是否立直 1 副露数 1 副露可见的宝牌数 1 是否坐庄 1 想切的牌对该玩家安全度 4 场上状况 牌山剩余量 1 杠的数量 1 牌河里宝牌数量 1 加入程序鸣牌的能力鸣牌程序训练跟第一部分单人程序大致相同,使用鸣牌局面的牌谱来进行训练,同样使用平均感知器算法来对局面的所有特征向量来分类,下表是跟单人麻将差不多的特征向量: 特征类 特征个数 副露数 5 是否可能立直 2 各色的1˜9数牌数量变换到0,1,2以上的牌型 19472 副露里选择n(1˜2)个副露的种类组合 136+9316=9452 手牌里有3张以上相同牌的数量和2张以上相同牌的数量的组合 5×7=35 手牌里有3张以上相同牌的数量+碰的个数和2张以上相同牌的数量的组合,还有是否吃牌 5×7+1=36 手牌和副露中断幺牌数量和向听数 16+16=32 连续的各色的3张数牌里的有无和3张里是否包含幺九和是否包含吃的组合 512×2×2=2048 包含吃的各色里幺九的有无 512 各色牌中最多的数量+该色和字牌的副露数×3 16 各色牌中最多的数量+字牌个数+该色和字牌的副露数×3 16 做特定色染手的向听数 16 役牌对子数 8 役牌刻子数 6 宝牌个数(0,1,2,3以上)和2˜8数牌中宝牌数量 4+4=8 副露数和向听数的组合 5×15=75 向听数和有役、有门清限定役、没役和巡目的组合 2×3×19=114 有役和是否是门清限定役和没有役 3 是否鸣了幺九牌和加入幺九牌时向听数减少的量(0,1,2以上) 2×3=6 手牌里不使用幺九牌的向听数增加的量(0,1,2以上) 3 加上所有副露的风牌后其数量(0,1,2,3以上)的组合 4×4×4×4=256 加上所有副露的三元牌后其数量(0,1,2,3以上)的组合 4×4×4=64 副露数和向听数和加入已经切出的牌是否减少向听数的组合 5×4×2=40 结合单人麻将,攻防判断和鸣牌打法有了不鸣牌,攻防判断以及鸣牌的打法,就可以基本训练出电脑程序打麻将的逻辑所有部分 结合前面三个部分可以完成这个流程,完成打麻将的策略。 总结这个论文的程序基本提供了一种有监督的方法来训练程序对门清状态的打牌,攻防判断和鸣牌的打法学习。但仍有很多不足,在文中认为弃和后,不会再次副露。训练集都是能和牌的局面,那么在手牌难以和牌的时候进行错误鸣牌,文中也说能通过在训练样本中加入没有和牌的局面解决。 References [1]: 平均感知器 [2]: 手牌特征量分析 北川竜平、三輪 誠 、近山 隆. 麻雀の牌譜からの打ち手評価関数の学習. Proceedings of the 12thGame Programming Workshop, 2007"}]