mirror of
https://github.com/pybricks/pybricks-api.git
synced 2026-09-11 17:14:41 +00:00
22 lines
554 B
Python
22 lines
554 B
Python
# ThisHub = TechnicHub PrimeHub EssentialHub
|
|
from pybricks.hubs import ThisHub
|
|
from pybricks.tools import wait
|
|
from pybricks.parameters import Axis
|
|
|
|
# Initialize the hub.
|
|
hub = ThisHub()
|
|
|
|
# Get the acceleration or angular_velocity along a single axis.
|
|
# If you need only one value, this is more memory efficient.
|
|
while True:
|
|
|
|
# Read the forward acceleration.
|
|
forward_acceleration = hub.imu.acceleration(Axis.X)
|
|
|
|
# Read the yaw rate.
|
|
yaw_rate = hub.imu.angular_velocity(Axis.Z)
|
|
|
|
# Print the yaw rate.
|
|
print(yaw_rate)
|
|
wait(100)
|