brian.motors.Motor
Motor class objects
A class to manage and control motor operations.
limits
Configure various controller limits.
Returns:
MotorLimits object that can be used for configuring the limits.
motor_type
Check what motor type was this object initialized with.
Returns:
Properties and default settings of the connected motor type.
__init__
Tries to autodetect a motor, connected to the given port and initialize a new motor class.
Arguments:
port
: Motor port to use.
Raises:
MotorInitializationFailedError
: If autodetect fails (motor is not connected, unknown type of the connected motor).MotorPortAlreadyInUse
: When trying to create new Motor on a port that is already in use.
__del__
close_motor
is_connected
Check if something is connected to the port.
Returns:
True if a non-empty port was detected; False otherwise.
is_ready
Check if a correct motor is connected to the port and is ready to be controlled.
Returns:
True if a motor is connected, and it is the correct type; False otherwise.
current_angle
reset_angle
Set the accumulated angle to the provided position.
Assuming that the motor will not move, current_angle() will start returning the value in newValue.
Arguments:
new_value
: New motor position in degrees.
current_speed
Query the current motor rotational speed.
Returns:
Motor axle speed in degrees/second.
current_torque
Query the current estimated motor torque.
Returns:
Motor torque in milli-newton-meters.
is_stalled
Check if the motor is currently stalled.
Returns:
True if the motor is exceeding some limit, False otherwise.
coast
brake
hold
Actively brake the motor at the current position.
This will actively control the motor to stay at the current position.
run_unregulated
Run the motor at a given fraction of the maximum available voltage.
Arguments:
fraction
: Value between -1.0 and +1.0 that determines the duty cycle.
run_at_voltage
Run the motor at the given voltage.
Arguments:
volts
: Desired voltage on the motors, in volts. Useful range is -battery voltage to +battery voltage (this is cca. -8V to +8V). The maximum range accepted by this function is -12V to +12V.
run_at_speed
Run the motor at a constant speed.
Arguments:
deg_per_sec
: Desired rotational speed, in degrees per second.
rotate_by_angle
Turn the motor to a new position, relative to the current position.
Arguments:
angle
: Angle to rotate by, in degrees.speed
: Speed to use for the maneuver, in degrees per second. If the provided speed is negative, absolute value is used.timeout
: How long to wait for the maneuver to complete, in milliseconds. If zero, the function will return immediately. If the timeout expires, the motor is not stopped.
Returns:
Whether the wait-for-end was successful or why it ended, if it ended early.
rotate_to_angle
Turn the motor to a new position, relative to the zero position.
Arguments:
position
: Angle to rotate to, in degrees.speed
: Speed to use for the maneuver, in degrees per second. If the provided speed is negative, absolute value is used.timeout
: How long to wait for the maneuver to complete, in milliseconds. If zero, the function will return immediately. If the timeout expires, the motor is not stopped.
Returns:
Whether the wait-for-end was successful or why it ended, if it ended early.
rotate_to_angle_without_speed_control
Try to get as fast as possible to the specified position.
This will ignore any speed and acceleration limits - you must provide these yourself by periodically calling this function with new positions.
Arguments:
position
: Angle to rotate to relative to the zero position, in degrees.
movement_done
Check whether the last invoked position command has completed.
Returns:
True if the motor has reached the goal. True if the maneuver had to be interrupted (e.g., motor was unplugged). False if the motor is still moving.
wait_for_movement
Wait for the motor to complete the last position command.
Arguments:
timeout
: How long to wait for the maneuver to complete, in milliseconds. If zero, the function will return immediately. If the timeout expires, the motor is not stopped.
Returns:
Whether the wait-for-end was successful or why it ended, if it ended early.