惯性#
介绍#
GO Brain 包含一个内置惯性传感器,可以让机器人跟踪其方向、航向和加速度。
以下是所有方法的列表:
方向
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.
运动
get_acceleration– Returns the linear acceleration along the x, y, or z axis.
方向#
get_heading#
get_heading 以度为单位返回惯性传感器的当前航向。
Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_heading().
用法:
inertial.get_heading()
参数 |
描述 |
|---|---|
该方法没有参数。 |
get_rotation#
get_rotation 返回惯性传感器的当前旋转角度(以度为单位)。
Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_rotation().
用法:
inertial.get_rotation()
参数 |
描述 |
|---|---|
该方法没有参数。 |
get_yaw#
get_yaw 返回惯性传感器的当前偏航角(以度为单位)。
Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_yaw().
用法:
inertial.get_yaw()
参数 |
描述 |
|---|---|
该方法没有参数。 |
get_roll#
get_roll 返回惯性传感器的当前滚动角度(以度为单位)。
Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_roll().
用法:
inertial.get_roll()
参数 |
描述 |
|---|---|
该方法没有参数。 |
get_pitch#
get_pitch 以度为单位返回惯性传感器的当前俯仰角。
Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.get_pitch().
用法:
inertial.get_pitch()
参数 |
描述 |
|---|---|
该方法没有参数。 |
calibrate#
calibrate 校准惯性传感器。所有后续行都将等待校准完成后再执行。校准是一个内部过程,用于测量并补偿指定时间段内的传感器噪声和漂移。在此期间,Brain 必须保持完全静止(即,在稳定的表面上,没有任何外部运动)。校准期间的移动会导致结果不准确。
Note: If a Code Base, Super Car, or Drivetrain is configured, this method becomes unavailable.
用法:
inertial.calibrate()
参数 |
描述 |
|---|---|
该方法没有参数。 |
reset_heading#
reset_heading 将惯性传感器的航向重置为 0 度。
Note: If a Code Base, Super Car, or Drivetrain is configured, this method becomes unavailable.
用法:
inertial.reset_heading()
参数 |
描述 |
|---|---|
该方法没有参数。 |
reset_rotation#
reset_rotation 将惯性传感器的旋转重置为 0 度。
Note: If a Code Base, Super Car, or Drivetrain is configured, this method becomes unavailable.
用法:
inertial.reset_rotation()
参数 |
描述 |
|---|---|
该方法没有参数。 |
set_heading#
set_heading 将惯性传感器的航向设置为指定值。
Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.set_heading().
用法:
inertial.set_heading(heading)
参数 |
描述 |
|---|---|
|
以度为单位设置的航向值。 |
set_rotation#
set_rotation 将惯性传感器的旋转设置为指定值。
Note: If a Code Base, Super Car, or Drivetrain is configured, this command becomes drivetrain.set_rotation().
用法:
inertial.set_rotation(rotation)
参数 |
描述 |
|---|---|
|
用于新旋转的度数值。 |
运动#
get_acceleration#
get_acceleration 返回惯性传感器的加速度。
用法:
inertial.get_acceleration(axis)
参数 |
描述 |
|---|---|
|
返回加速度的轴:
|
# 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)