坦克驾驶模式教程

问题:如何使用坦克驾驶模式使我的机器通过两个操纵杆驱动?

Solution: There are four components to consider when setting up tank drive for your robot. The first thing you will want to do is make sure the tank drive.vi is used instead of the arcade drive.vi or whichever drive VI you were utilizing previously. The second item to consider is how you want your joysticks to map to the direction you want to drive. In tank drive, the left joystick is used to control the left motors and the right joystick is used to control the right motors. For example, if you want to make your robot turn right by pushing up on the left joystick and down on the right joystick you will need to set your joystick’s accordingly in LabVIEW (this is shown in more detail below). Next, you will want to confirm the PWM lines that you are wired into, are the same ones your joysticks will be controlling. Lastly, make sure your motor controllers match the motor controllers specified in LabVIEW. The steps below will discuss these ideas in more detail:

  1. 打开LabVIEW并双击“FRC roboRIO Project”

../../../../_images/roboRIO-project.png
  1. 为项目命名,添加团队编号,然后选择Arcade Drive Robot roboRIO。您可以选择其他选项,但是,本教程将讨论如何为该项目设置坦克驾驶模式。

  2. 在“项目资源管理器”窗口中,打开Robot Main.vi

  3. 按下Ctrl+E即可查看框图。它应如下图所示:

../../../../_images/block-diagram.png
  1. 双击启用Teleop的案例结构内部的“ Teleop” vi。查看其框图。您将要在此处进行两项更改:

  • 用tank drive.vi替换Arcade Drive。右键单击程序框图>> WPI机器库>>机器驱动器>>,然后单击Tank Drive VI,可以找到该文件。

  • 找到位于Get Values.vi之后的索引数组函数。您将需要创建两个数字常量,并将每个常量连接到索引输入之一。您可以通过查看FRC®Driver Station中的USB Devices选项卡来确定每个索引的值。移动两个操纵杆以确定它们绑定到的数字(索引)。您可能希望对每个操纵杆使用Y轴索引。这是因为,当您希望电动机前进时,向上推操纵杆很直观;而当电动机反向时,推下操纵杆很直观。如果为每个轴选择X轴索引,则必须向左或向右移动操纵杆(X轴方向)才能使电机转动。在我的设置中,我为左电机Y轴控制选择了索引1,为右电机Y轴控制选择了索引5。你可以在LabVIEW中看到如下图所示的调整:

../../../../_images/block-diagram-2.png
  1. 接下来,您将要返回到“ Robot Main.vi”并双击“ Begin.vi”。

  2. 在该VI中首先要确认的是,您的左右电机连接到LabVIEW中与PDP(配电面板)上相同的PWM线。

  3. 在该VI中要确认的第二件事是“ Open 2 Motor.vi”已选择了正确的电机控制器(Talon,Jaguar,Victor等)。

例如,我正在使用Jaguar电动机控制器,并且电动机已连接到PWM 8和9。下图显示了我需要进行的更改:

../../../../_images/block-diagram-3.png
  1. 保存所有已进行调整的Vi,现在就可以使用坦克驾驶模式来驱动机器了!