维克多汽车#

介绍#

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)

参数

描述

direction

电机旋转方向:

  • FORWARD – 默认为逆时针
  • REVERSE – 默认为顺时针

velocity

Optional. The velocity to spin with from 0% to 100% when using PERCENT. This can be an integer or decimal (float). If the velocity is not specified or previously set, the default velocity is 50%.

units

可选。速度单位:

  • PERCENT
  • RPM (默认)– 每分钟转数
  • VelocityUnits.DPS – 每秒度数

停止#

stop 立即停止连接的电机。

Usage:
victor_motor.stop()

参数

描述

此方法没有参数。

设置速度#

set_velocity 告诉电机旋转的速度。百分比越高,电机旋转速度越快;百分比越低,电机旋转速度越慢。

每个项目开始时,每个连接的电机默认以 50% 的速度旋转。

Usage:
victor_motor.set_velocity(value, units)

范围

描述

velocity

The velocity to spin with from 0% to 100% when using PERCENT. This can be an integer or decimal (float).

units

可选。速度单位:

  • PERCENT
  • RPM (默认)– 每分钟转数
  • VelocityUnits.DPS – 每秒度数

set_reversed#

set_reversed 将电机反转,使 FORWARD 方向顺时针旋转。此方法与构造 MotorVictor 时将 reverse 参数设置为 True 效果相同。

Usage:
victor_motor.set_reversed(value)

参数

描述

value

电机方向是否反转:

  • True — 反转电机方向。4
  • 假False 默认方向

构造函数#

构造函数用于创建 MotorVictor 对象,这些对象是配置 Victor 电机控制器所必需的。

MotorVictor#

MotorVictor 创建一个 Victor 电机控制器。

Usage:
MotorVictor(port, reverse)

范围

描述

port

The 3-Wire Port that the Victor Motor Controller is connected to:

  • On the V5 Brain – Ports.PORTx where x is the number of the port.
  • On a 3-Wire Expander – expander.a where expander is the name of the expander instance.

reverse

Optional. Sets whether the motor’s spin should be reversed.

  • True – FORWARD will spin clockwise
  • False (default) – FORWARD will spin counterclockwise

# Create a Victor Motor Controller in Port A
victor_motor = MotorVictor(brain.three_wire_port.a)