维克多汽车#
介绍#
VEX Victor 电机控制器 是一款传统的电机控制器,它接收来自主机的 3 线 PWM 信号来控制无法直接插入智能端口的 VEXpro/EDR 直流电机。
本页面以 victor_motor 作为 Victor 电机控制器的示例名称。请根据需要将其替换为您自己配置的名称。
以下是可用方法列表:
spin– 使电机正转或反转,直到停止。stop– 立即停止电机。set_velocity– 告诉电机旋转的速度。set_reversed– 设置电机反转其旋转方向。
构造函数 – 手动初始化 Victor 电机控制器。
MotorVictor– 创建一个 Victor 电机控制器。
旋转#
spin 使用 当前电机速度 使连接的电机沿指定方向旋转。
Usage:
victor_motor.spin(direction, velocity, units)
参数 |
描述 |
|---|---|
|
电机旋转方向:
|
|
Optional. The velocity to spin with from 0% to 100% when using |
|
可选。速度单位:
|
停止#
stop 立即停止连接的电机。
Usage:
victor_motor.stop()
参数 |
描述 |
|---|---|
此方法没有参数。 |
设置速度#
set_velocity 告诉电机旋转的速度。百分比越高,电机旋转速度越快;百分比越低,电机旋转速度越慢。
每个项目开始时,每个连接的电机默认以 50% 的速度旋转。
Usage:
victor_motor.set_velocity(value, units)
范围 |
描述 |
|---|---|
|
The velocity to spin with from 0% to 100% when using |
|
可选。速度单位:
|
set_reversed#
set_reversed 将电机反转,使 FORWARD 方向顺时针旋转。此方法与构造 MotorVictor 时将 reverse 参数设置为 True 效果相同。
Usage:
victor_motor.set_reversed(value)
参数 |
描述 |
|---|---|
|
电机方向是否反转:
|
构造函数#
构造函数用于创建 MotorVictor 对象,这些对象是配置 Victor 电机控制器所必需的。
MotorVictor#
MotorVictor 创建一个 Victor 电机控制器。
Usage:
MotorVictor(port, reverse)
范围 |
描述 |
|---|---|
|
The 3-Wire Port that the Victor Motor Controller is connected to:
|
|
Optional. Sets whether the motor’s spin should be reversed.
|
# Create a Victor Motor Controller in Port A
victor_motor = MotorVictor(brain.three_wire_port.a)