Beautiful Soup
Generate bs4
1 | soup = bs4.BeautifulSoup(text) |
find node
1 | soup.find("div", attrs={"id":"..."}) |
siblings
1 | soup.find("...").next_sibling |
with Regular Expression
1 | soup(class_=re.compile('item-')) |
1 | soup = bs4.BeautifulSoup(text) |
1 | soup.find("div", attrs={"id":"..."}) |
1 | soup.find("...").next_sibling |
1 | soup(class_=re.compile('item-')) |
File Path: catkin_ws/src/test/script/env_pkl_generator.py
1 | cd ~ |
It will open Gazebo and RViz and display the robotic arm on both sofware.
1 | cd ~ |
向日葵
识别吗
341 866 266
ge6v9Q
Shader是一种计算机程序,它用于在图形渲染管线中处理顶点和像素。在Unity中,Shader可以用来控制物体的渲染方式,包括颜色、纹理、透明度等。Shader的工作流程是将材料(如纹理、数据、颜色等)通过加工展现在材质上的过程。
Unity中有多种类型的Shader,可以根据不同的情况使用。例如,在三维网格上使用的方式和图片上使用的方式会有区别。
一个Unity Shader通常由以下几个部分组成:
Properties:这部分定义了Shader中可供用户在材质检查器中编辑的属性。例如,可以定义一个颜色属性,让用户可以在材质检查器中更改物体的颜色。
SubShader:每个Shader至少包含一个SubShader。SubShader定义了Shader的实际渲染操作。如果Shader需要支持多种不同的渲染硬件或渲染质量设置,可以在Shader中定义多个SubShader。
Pass:每个SubShader至少包含一个Pass。Pass定义了一次渲染操作,包括顶点和片段着色器的代码。可以在一个SubShader中定义多个Pass来实现多次渲染操作。
CGPROGRAM:这部分包含了顶点和片段着色器的代码。可以使用Cg/HLSL语言来编写着色器代码,并使用内置的变量和函数来访问物体的信息。
1 | Shader "Custom/SimpleColor" { |
如果希望根据物体的标签来控制物体的颜色,可以在Shader中使用材质属性来实现。首先,需要在脚本中获取物体的标签信息,并根据标签信息设置物体材质的颜色属性。然后,在Shader中,可以使用这个颜色属性来控制物体的渲染颜色。
下面是一个简单的示例,它展示了如何在脚本中设置材质的颜色属性,并在Shader中使用该属性来控制物体的颜色:
1 | // 脚本中设置材质的颜色属性 |
Implement Build-in Command in C
A shell built-in command is contained in the shell itself (implemented by shell author) and runs on the same shell without creating a new process, e.g. cd
, pwd
, exit
, alias
.
By contrast: For a regular(linux) command, it is run from a binary file (found in $PATH or specified file) by forking the existing process in a subshell, e.g.
ls
,cat
,rm
.
Assume we have already got the parsed arguments
char * parsedArgs[MAXPARSE]
.
For example, a input
char * input = "cd .."
can be parsed aschar * parsedArgs[MAXPARSE] = {"cd", ".."}
Then, we just need to judge whether parsedArgs[0]
is contained in our build-in command set {"exit", "cd", "pwd" ...}
(by using strcmp
)
In this project (as of milestone 2) , we need to implement exit
, pwd
, cd
.
exit
In Bash, exit
is a built-in command used to terminate the current shell session (same in our mumsh).
Each running shell is a process, so we can use the exit()
in stdlib.h
to terminate the shell process, achieving the goal of exiting the shell.
1 | void exec_exit(){ |
pwd
Running a crude (or minimal?) shell and have no idea where you are? Just type pwd
and it will print the name of the current/working directory.
In C, we can implement the similar functionality using the getcwd()
in unistd.h
.
if success,
getcwd()
will return the pointer to the result, else ( e.g. no enough space) returnNULL
1 | void exec_pwd(){ |
However, the working directory is not guaranteed to be shorter than 1024, so we may need to dynamically allocate the buffer to suit the length.
1 | int size = 100; |
cd
cd
is used for changing working directory.
In C, we can implement the similar functionality using the chdir()
in unistd.h
.
if success,
chdir()
will return 0, else ( e.g. no such directory) return -1
1 | void exec_cd(char * path){ |
Very straight forward, but if we want to implement more advanced features of the cd
command such as changing to the home directory or the previous directory, we would need to handle these cases manually.
For example, you could check if the argument is
~
or-
, and then callchdir()
with the appropriate path
Only contain the control over control surface (on control over throttle)
Function: KeepPitch()
Control the angle of horizontal tail (elevator)
First keep the angle of elevator same with AoA(攻角), to avoid the disturbance of the horizontal tail on the attitide of the aircraft.
1 | aircraft.PitchAngle = aircraft.AoA; |
这里的aircraft.PitchAngle指的是飞机升降舵的角度(下片为正)
根据当前俯仰角,俯仰速度,和目标俯仰角,调整升降舵面的角度
1 | aircraft.PitchAngle += 5 * (p - aircraft.Pitch) / Mathf.Exp(10 * aircraft.PitchSpeed * Mathf.Sign(p - aircraft.Pitch)); |
与俯仰角类似(分别控制滚转舵面以及偏航舵面),不过不需要第一步
Control the thrust of aircraft to change the angle of gliding
保持飞机的俯仰角不变(5度仰角)
1 | KeepPitch(5f); |
计算当前下滑角
1 | float velAngle = 90 - Vector3.Angle(aircraft.rb.velocity, Vector3.up); |
根据下滑角更改油门大小
1 | aircraft.Thrust += (p - velAngle)/500f; |
通过调整飞机的下滑角来使飞机在竖直面上接近并维持在理想的下滑道
1 | Vector3 approachDirection = Vector3.ProjectOnPlane(route.Destination - transform.position, route.direction); |
1 | ThrustKeepGliding(-3 + Mathf.Clamp(approachDirection.y / 10f, -5,5)); |
通过调整飞机的偏航舵面角度(进而影响飞机的y轴rotation)来使飞机在水平面上接近并维持在理想的航道上
1 | Vector3 approachDirection = Vector3.ProjectOnPlane(route.Destination - transform.position, route.direction); |
1 | KeepYaw(-8 + Mathf.Clamp(distance / 10f, -50, 50)); |
基本的策略以及阐述完毕,那么所谓的理想下滑道到底应该怎么得到呢?
理想下滑道是一个射线,包含一个终点(飞机着陆的终点)和一个方向(飞机接近的方向)
1 | public class Target_Route |
理想航道的偏航角和下滑角已知(分别为-8(平行于着陆跑道)和-3)
通过迭代飞机着陆所需时间来求得下滑道终点的位置
1 | route.Destination = CV.transform.position; |
trip generation, modal choice, routine choice
Path planning, Maneuver regulation
Parking
central command center send instructions
Some win, some lose
plan trip independently, selfish
little communication
Sometime efficient, sometime inefficient
static, in form of map
enable the route to be adapted to changing traffic conditions
$v[t]$
$R>= 0$
$u[t]$(accel)
$v[t+dt] = v[t]+u[t]*dt$
Specify the control input $u[t]$ for all t in $[0,T]$
not a good idea for autonomous driving.
In practice, we need to consider the uncertainty of the system.
We should have:
$$
v[t+dt]=v[t]+u[t]dt+w(t)
$$
Where w(t) is the noise term capturing the uncertainty of the system.
Specify the control input $u[t]$ as a function of the state $v[t]$
able to adapt to the uncertainty of the system.
Compare the state $v[t]$ with the desired state $v_desired[t]$
Essentially, we need a mapping from state to control input
like map speed to acceleration
$$
v[t+dt]=v[t]+mu[v[t]]dt+w(t)
$$
the $u[t]$ has linear relationship with $v[t]$
$$
\mu[v] = k[v-v_{desired}]
$$
linear time-invariant
exponential convergence is stronger than asymptotic convergent
if LTI system is asymptotic convergent, it is also exponential convergent
$$
x[t+1]=ax[t]+bu[t]
$$
given:
$v_{desired}, \delta$
determine:
$u[t]$ $t = 0,1,2$
state
$v[t]$
$v[t+1] = v[t] + u[t]\delta + w[t]$
select $u[t]$ so that $w[t]$ will not accumulate
$u[t]=\mu(v[t]) = kv[t]$
$$
v[t+1] = f(v[t],u[t])
$$
Remember the review question
Overview:
track means asymptotic convergent
$x[t]$ and $x_{desired}[t]$
$\lim_{t\rightarrow\infty}|x[t]-x_{desired}[t] | = 0$
state of system:$[x[t], v[t]]^T$
if successful:
$$
[x[t], v[t]]^T \rightarrow [x_{desired}[t], v_{desired}[t]]^T
$$
$$
u[t] = -k_1(x[t]-x_{desired}[t])-k_2(v[t]-v_{desired}[t])
$$
$$
k_1,k_2>0
$$