Ravens Robotics FRC 2015
Public Member Functions | Private Attributes | List of all members
MecanumDrive Class Reference

#include <MecanumDrive.h>

Inheritance diagram for MecanumDrive:
RobotComponent

Public Member Functions

 MecanumDrive ()
 
virtual ~MecanumDrive ()
 
virtual void ComponentInit ()
 
virtual void Sense ()
 
virtual void DoWork ()
 
virtual void SetSmoothAccel (bool enable)
 
bool isSmoothAccel () const
 
void setSmoothAccel (bool smoothAccel)
 
bool isGyroEnabled () const
 
void setGyroEnabled (bool gyroEnabled)
 
- Public Member Functions inherited from RobotComponent
 RobotComponent ()
 
virtual ~RobotComponent ()
 

Private Attributes

Joystick * m_DriveStick
 joystick controller More...
 
RobotDrive * m_Drive
 drive instance More...
 
SmoothAxism_ValueX
 left/right speed [-1.0..1.0] More...
 
SmoothAxism_ValueY
 fwd/bkwd speed, inverted [-1.0..1.0] More...
 
SmoothAxism_ValueRotate
 Rate of rotation [-1.0..1.0]. More...
 
Gyro * m_Gyro
 Gyroscope instance to measure robot's heading. More...
 
JoystickButton * m_GyroButton
 Button to dis/enable gyro. More...
 
bool m_GyroButtonIsPressed
 Button state. More...
 
bool m_gyroEnabled
 Gyroscope enablement. More...
 
float m_gyroAngle
 Gyroscope angle measurement. More...
 
bool m_SmoothAccel
 State of smooth acceleration capability. More...
 

Detailed Description

The MecanumDrive RobotComponent provides control of 4 Talon motor control units for mecanum-equipped wheels.

Read more about mecanum wheels on wikipedia.

UranusOmniDirectionalRobotPodnar.png

Definition at line 24 of file MecanumDrive.h.

Constructor & Destructor Documentation

MecanumDrive::MecanumDrive ( )
MecanumDrive::~MecanumDrive ( )
virtual

Definition at line 25 of file MecanumDrive.cpp.

References m_Drive, m_DriveStick, m_Gyro, m_GyroButton, m_ValueRotate, m_ValueX, and m_ValueY.

Member Function Documentation

void MecanumDrive::ComponentInit ( )
virtual

Called once, to perform initialization that isn't appropriate for constructor.

Reimplemented from RobotComponent.

Definition at line 39 of file MecanumDrive.cpp.

References m_Drive, m_DriveStick, m_Gyro, m_GyroButton, m_GyroButtonIsPressed, m_SmoothAccel, m_ValueRotate, m_ValueX, m_ValueY, and SetSmoothAccel().

Referenced by Robot::RobotInit().

void MecanumDrive::DoWork ( )
virtual

Component-specific worker function. Operate the Drive, using values retrieved by Sense().

Cartesian motion drive method for Mecanum wheeled robots is used. There are 4 wheels on the robot, arranged so that the front and back wheels are toed in 45 degrees. By controlling the revolutions of each wheel independently, it is possible to translate the robot on a cartesian plane, and to rotate it separately.

This is designed to be directly driven by joystick axes.

  • Left stick controls cartesian translation
  • right stick controls rotation
  • Pressing down on right stick (Button 9) enables or disables gyro; when gyro is enabled, cartesian motion is relative to the field instead of the robot's POV.

Reimplemented from RobotComponent.

Definition at line 103 of file MecanumDrive.cpp.

References SmoothAxis::GetValue(), m_Drive, m_gyroAngle, m_ValueRotate, m_ValueX, and m_ValueY.

Referenced by Robot::TeleopPeriodic().

bool MecanumDrive::isGyroEnabled ( ) const
inline

Check if Gyroscope is enabled.

Returns
Returns true if enabled.

Definition at line 100 of file MecanumDrive.h.

References m_gyroEnabled.

Referenced by Sense().

bool MecanumDrive::isSmoothAccel ( ) const
inline

Check if Smooth Acceleration is enabled.

Returns
Returns true if enabled.

Definition at line 77 of file MecanumDrive.h.

References m_SmoothAccel.

void MecanumDrive::Sense ( )
virtual

Component-specific sensory input collector. Read joystick positions and button states.

Reimplemented from RobotComponent.

Definition at line 68 of file MecanumDrive.cpp.

References isGyroEnabled(), m_DriveStick, m_Gyro, m_gyroAngle, m_GyroButton, m_GyroButtonIsPressed, m_gyroEnabled, m_ValueRotate, m_ValueX, m_ValueY, and SmoothAxis::SetTarget().

Referenced by Robot::TeleopPeriodic().

void MecanumDrive::setGyroEnabled ( bool  gyroEnabled)

Set Gyroscope enablement. Usage:

drive->setGyroEnabled(true); // Enable Gyroscope.
Parameters
[in]gyroEnabledSet true to enable.

Definition at line 111 of file MecanumDrive.cpp.

References m_Gyro, and m_gyroEnabled.

void MecanumDrive::SetSmoothAccel ( bool  enable)
virtual

Enable / Disable smooth acceleration capability.

Parameters
[in]enableSet true to enable.

Usage:

drive->SetSmoothAccel(true); // Enable smooth acceleration.

Definition at line 125 of file MecanumDrive.cpp.

References m_SmoothAccel, m_ValueRotate, m_ValueX, m_ValueY, and SmoothAxis::setEnabled().

Referenced by ComponentInit().

void MecanumDrive::setSmoothAccel ( bool  smoothAccel)
inline

Set Smooth Acceleration feature.

Usage:

drive->SetSmoothAccel(true); // Enable smooth acceleration.
Parameters
[in]smoothAccelSet true to enable.

Definition at line 91 of file MecanumDrive.h.

References m_SmoothAccel.

Member Data Documentation

RobotDrive* MecanumDrive::m_Drive
private

drive instance

Definition at line 117 of file MecanumDrive.h.

Referenced by ComponentInit(), DoWork(), MecanumDrive(), and ~MecanumDrive().

Joystick* MecanumDrive::m_DriveStick
private

joystick controller

Definition at line 116 of file MecanumDrive.h.

Referenced by ComponentInit(), MecanumDrive(), Sense(), and ~MecanumDrive().

Gyro* MecanumDrive::m_Gyro
private

Gyroscope instance to measure robot's heading.

Definition at line 121 of file MecanumDrive.h.

Referenced by ComponentInit(), MecanumDrive(), Sense(), setGyroEnabled(), and ~MecanumDrive().

float MecanumDrive::m_gyroAngle
private

Gyroscope angle measurement.

Definition at line 125 of file MecanumDrive.h.

Referenced by DoWork(), MecanumDrive(), and Sense().

JoystickButton* MecanumDrive::m_GyroButton
private

Button to dis/enable gyro.

Definition at line 122 of file MecanumDrive.h.

Referenced by ComponentInit(), MecanumDrive(), Sense(), and ~MecanumDrive().

bool MecanumDrive::m_GyroButtonIsPressed
private

Button state.

Definition at line 123 of file MecanumDrive.h.

Referenced by ComponentInit(), MecanumDrive(), and Sense().

bool MecanumDrive::m_gyroEnabled
private

Gyroscope enablement.

Definition at line 124 of file MecanumDrive.h.

Referenced by isGyroEnabled(), MecanumDrive(), Sense(), and setGyroEnabled().

bool MecanumDrive::m_SmoothAccel
private

State of smooth acceleration capability.

Definition at line 126 of file MecanumDrive.h.

Referenced by ComponentInit(), isSmoothAccel(), MecanumDrive(), SetSmoothAccel(), and setSmoothAccel().

SmoothAxis * MecanumDrive::m_ValueRotate
private

Rate of rotation [-1.0..1.0].

Definition at line 118 of file MecanumDrive.h.

Referenced by ComponentInit(), DoWork(), MecanumDrive(), Sense(), SetSmoothAccel(), and ~MecanumDrive().

SmoothAxis* MecanumDrive::m_ValueX
private

left/right speed [-1.0..1.0]

Definition at line 118 of file MecanumDrive.h.

Referenced by ComponentInit(), DoWork(), MecanumDrive(), Sense(), SetSmoothAccel(), and ~MecanumDrive().

SmoothAxis * MecanumDrive::m_ValueY
private

fwd/bkwd speed, inverted [-1.0..1.0]

Definition at line 118 of file MecanumDrive.h.

Referenced by ComponentInit(), DoWork(), MecanumDrive(), Sense(), SetSmoothAccel(), and ~MecanumDrive().


The documentation for this class was generated from the following files: