Bionic Bruins Wiki

The official wiki of the Bionic Bruins

User Tools

Site Tools


Action disabled: register
building:drives:x

Table of Contents

X Drive

x drive motion

Like the basic drive, the x drive relies on omni wheels. It has the unique ability to drive in all four directions, plus rotation. This is achived through its 45º placement of the wheels, which when powered correctly, cancel out to produce motion in any given direction. Note the diagram to the right: the left and right wheels produce vectors of A and B, which sum up to the resulting vector R.

While being more agile, x drives suffer from a loss of torque when compared to more conventional drives. To see this principle in action, check out this video.

Code

Coding an x drive is a little more complicated than a conventional drive. A typical x drive control scheme uses the right joystick to pan (forwards backwards left and right) and the x axis on the left joystick for rotation. Example code using this control scheme is shown below.

#include "vex.h"
 
using namespace vex;
 
controller Controller;
 
// front left, front right, back left, back right
motor FL = motor(PORT1);
motor FR = motor(PORT2);
motor BL = motor(PORT3);
motor BR = motor(PORT4);
 
int main() {
    while (true) {
        // get controller inputs 
        int forwards = Controller.Axis2.position();
        int sideways = Controller.Axis1.position();
        int rotation = Controller.Axis4.position();
 
        // set motor velocities
        FL.setVelocity(rotation + forwards + sideways, percentUnits::pct);
        FR.setVelocity(rotation - forwards + sideways, percentUnits::pct);
        BL.setVelocity(rotation + forwards - sideways, percentUnits::pct);
        BR.setVelocity(rotation - forwards - sideways, percentUnits::pct);
    }
}

Example

building/drives/x.txt · Last modified: 2019/09/06 15:09 (external edit)