组装好小车,安装系统,正确且完整的配置好环境后,可以进行下面的操作进行小车的进一步配置操作。下面的内容与clone下来的github工程中的内容为对照,进行了注解翻译以及内容及操作进一步的注解。
黑色部分代码为代码块,其余部分为Markdown文本。
Execute the following block of code by selecting it and clicking ctrl + enter to create an NvidiaRacecar class.
- 通过选择下面的代码块,并且按Ctrl + 回车键,创建一个NvidiaRacecar类。
from jetracer.nvidia_racecar import NvidiaRacecar
car = NvidiaRacecar()
The NvidiaRacecar implements the Racecar class, so it has two attributes throttle and steering.
- NvidiaRacecar实现了Racecar类,因此它有两个属性throttle和steering。
We can assign values in the range [-1, 1] to these attributes. Execute the following to set the steering to 0.4.
- 我们可以在[- 1,1]范围内为这些属性赋值。执行以下操作将转向器设置为0.4。默认的是设置为0.4,但下面的代码中我设置的是0,这样一来,就可以校准小车的转向,让前轮处于正直方向时固定前轮。
If the car does not respond, it may still be in manual mode. Flip the manual override switch on the RC transmitter.
- 如果汽车没有反应,它可能仍然处于手动模式。拨动遥控发射机上的手动控制开关。运行teleoperation.ipynb代码文档,可以使遥控手柄上的两个摇杆与小车的转向角度和速度链接起来,从而手动控制小车。
car.steering = 0
- 设置小车转向值为0即直行
The NvidiaRacecar
class has two values steering_gain
and steering_bias
that can be used to calibrate the steering.
NvidiaRacecar
类有两个值steering_gain
和steering_bias
,可以用来校准转向。
We can view the default values by executing the cells below.
- 可以通过下面的输出其值来查看默认值
print(car.steering_gain)
- 输出结果:-0.65
小车转向增益,与转向值是线性倍数关系
print(car.steering_offset)
- 输出结果:0.0
steering_offset为小车转向偏置,转向后小车转向值再加上小车偏置
The final steering value is computed using the equation
- 最后的转向值是用公式计算的
𝑦=𝑎×𝑥+𝑏
Where,
𝑎 is car.steering_gain
𝑏 is car.steering_offset
𝑥 is car.steering
𝑦 is the value written to the motor driver
- 计算公式是y=𝑎×𝑥+𝑏
其中,
𝑎 是 car.steering_gain
𝑏 是 car.steering_offset
𝑥 是 car.steering
𝑦 是 写入到转向电机驱动器的值
You can adjust these values calibrate the car so that setting a value of 0 moves forward, and setting a value of 1 goes fully right, and -1 fully left.
- 您可以调整这些值校准小车,以便将值设置为0向前移动,将值设置为1完全向右移动,将值设置为-1完全向左移动。
To set the throttle of the car to 0.2, you can call the following.
- 要将小车的油门设置为0.2,可以调用以下命令。
Give JetRacer lots of space to move, and be ready on the manual override, JetRacer is fast
- 给JetRacer足够的移动空间,并准备好手动控制,JetRacer是快速的0.4左右的速度不是特别快(实际油门是油门值(0.4)乘以油门增益(默认值0.8)=0.32),走路的速度,但是相较于其他类型的智能小车来说已经是快速的了,并且可以将速度值设置为1,使用最大速度。
car.throttle = 0.4
The throttle also has a gain value that could be used to control the speed response. The throttle output is computed as
𝑦=𝑎×𝑥
Where,
𝑎 is car.throttle_gain
𝑥 is car.throttle
𝑦 is the value written to the speed controller
- 油门也有一个增益值,可以用来控制速度响应。节流输出计算如下
𝑦=𝑎×𝑥
其中,
𝑎 是 car.throttle_gain
𝑥 是 car.throttle
𝑦 是 写入速度控制器中的值
Execute the following to print the default gain
- 执行下面的代码查看默认的油门增益值
print(car.throttle_gain)
- 输出结果:0.8
Set the following to limit the throttle to half
- 执行下面的设置来限制油门值为其总值的一半
car.throttle_gain =0.5
- 小车的速度增益,速度值的线性倍数
Please note the throttle is directly mapped to the RC car. When the car is stopped and a negative throttle is set, it will reverse. If the car is moving forward and a negative throttle is set, it will brake.
- 请注意油门是直接映射到遥控车。当小车停下来并设置负油门时,它就会反转。如果小车向前行驶,并且设置了负油门,它就会刹车。
That’s it for this notebook!
- 文档结束。