惯性#
介绍#
GO Brain 包含一个内置惯性传感器,可以让机器人跟踪其方向、航向和加速度。
以下是所有方法的列表:
Orientation — Return and set the robot’s orientation.
get_heading— Returns the current heading.get_rotation— Returns the current rotation.get_yaw— Returns the current yaw.get_roll— Returns the current roll.get_pitch— Returns the current pitch.calibrate— Calibrates the Inertial Sensor for stable heading tracking.reset_heading— Sets the heading of the Inertial Sensor to 0.reset_rotation— Sets the rotation of the Inertial Sensor to 0.set_heading— Sets the Inertial Sensor’s heading to a specified value.set_rotation— Sets the Inertial Sensor’s rotation to a specified value.
Motion — Return the acceleration of the robot.
get_acceleration— Returns the linear acceleration along the x-, y-, or z-axis.
方向#
get_heading#
get_heading 以度为单位返回惯性传感器的当前航向。
**注意:**如果配置了代码库、超级跑车或传动系统,则此命令变为 drivetrain.get_heading()。
用法:
inertial.get_heading()
参数 |
描述 |
|---|---|
该方法没有参数。 |
get_rotation#
get_rotation 返回惯性传感器的当前旋转角度(以度为单位)。
**注意:**如果配置了代码库、超级跑车或传动系统,则此命令变为 drivetrain.get_rotation()。
用法:
inertial.get_rotation()
参数 |
描述 |
|---|---|
该方法没有参数。 |
get_yaw#
get_yaw 返回惯性传感器的当前偏航角(以度为单位)。
**注意:**如果配置了代码库、超级跑车或传动系统,则此命令变为 drivetrain.get_yaw()。
用法:
inertial.get_yaw()
参数 |
描述 |
|---|---|
该方法没有参数。 |
get_roll#
get_roll 返回惯性传感器的当前滚动角度(以度为单位)。
**注意:**如果配置了代码库、超级跑车或传动系统,则此命令变为 drivetrain.get_roll()。
用法:
inertial.get_roll()
参数 |
描述 |
|---|---|
该方法没有参数。 |
get_pitch#
get_pitch 以度为单位返回惯性传感器的当前俯仰角。
**注意:**如果配置了代码库、超级跑车或传动系统,则此命令变为 drivetrain.get_pitch()。
用法:
inertial.get_pitch()
参数 |
描述 |
|---|---|
该方法没有参数。 |
calibrate#
calibrate calibrates the Inertial Sensor. All subsequent lines of code will wait for the calibration to complete before executing. Calibration is an internal procedure that measures and compensates for sensor noise and drift over a specified period. During this time, the Brain must remain completely still (i.e., on a stable surface without any external movement). Movement during calibration will produce inaccurate results.
**注意:**如果配置了代码库、超级跑车或动力系统,则此方法将不可用。
用法:
inertial.calibrate()
参数 |
描述 |
|---|---|
该方法没有参数。 |
reset_heading#
reset_heading 将惯性传感器的航向重置为 0 度。
**注意:**如果配置了代码库、超级跑车或动力系统,则此方法将不可用。
用法:
inertial.reset_heading()
参数 |
描述 |
|---|---|
该方法没有参数。 |
reset_rotation#
reset_rotation 将惯性传感器的旋转重置为 0 度。
**注意:**如果配置了代码库、超级跑车或动力系统,则此方法将不可用。
用法:
inertial.reset_rotation()
参数 |
描述 |
|---|---|
该方法没有参数。 |
set_heading#
set_heading 将惯性传感器的航向设置为指定值。
**注意:**如果配置了代码库、超级跑车或传动系统,则此命令变为 drivetrain.set_heading()。
用法:
inertial.set_heading(heading)
参数 |
描述 |
|---|---|
|
以度为单位设置的航向值。 |
set_rotation#
set_rotation 将惯性传感器的旋转设置为指定值。
**注意:**如果配置了代码库、超级跑车或传动系统,则此命令变为 drivetrain.set_rotation()。
用法:
inertial.set_rotation(rotation)
参数 |
描述 |
|---|---|
|
用于新旋转的度数值。 |
运动#
get_acceleration#
get_acceleration 返回惯性传感器的加速度。
用法:
inertial.get_acceleration(axis)
参数 |
描述 |
|---|---|
|
The axis to return the acceleration from:
|
# Build Used: Super Code Base 2.0
def main():
# Display the acceleration after moving
drivetrain.set_drive_velocity(100)
console.print("Resting: ")
console.print(inertial.get_acceleration(X), precision=2)
console.new_line()
wait(1, SECONDS)
drivetrain.drive_for(FORWARD, 500, MM, wait=False)
wait(0.20, SECONDS)
console.print("Startup: ")
console.print(inertial.get_acceleration(X), precision=2)
# Start threads — Do not delete
start_thread(main)