INTRODUCTION
Overview
Download and Install
Quick Start
Documentation
Publications

NONFRAMEWORK CODE
Driver Interfaces
Drivers
Libraries
Utilities

FRAMEWORK CODE
Interfaces
Components
Libraries
Utilities

Full Software Listings

DEVELOPER
Tutorials
Examples
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         

rxdata.h

00001 /*
00002  * Orca-Robotics Project: Components for robotics 
00003  *               http://orca-robotics.sf.net/
00004  * Copyright (c) 2004-2009 Alex Brooks, Alexei Makarenko, Tobias Kaupp
00005  *
00006  * This copy of Orca is licensed to you under the terms described in
00007  * the LICENSE file included in this distribution.
00008  *
00009  */
00010 
00011 #ifndef SEGWAYRMP_RXDATA_H
00012 #define SEGWAYRMP_RXDATA_H
00013 
00014 #include <vector>
00015 
00016 #include "rawrxdata.h"
00017 #include "unitconverter.h"
00018 
00019 namespace segwayrmpacfr {
00020 
00021 class CanPacket;
00022 
00023 //
00024 // @brief Holds data received by the host from the RMP.
00025 //        The actual data is stored in a RmpRawData structure.
00026 //        Public member functions return the data in sane units.
00027 //
00028 // This thing is supposed to have a lifetime longer than an individual CAN packet.
00029 // Since different CAN packets hold different kinds of data, this thing acts
00030 // as an accumulator.
00031 //
00032 class RxData
00033 {
00034 
00035 public: 
00036 
00037     // Data is empty on construction.
00038     RxData( RmpModel rmpModel );
00039 
00040     // Adds the information contained in a single CAN packet
00041     void addPacket( const CanPacket &pkt ) { rawData_.addPacket(pkt); }
00042     // Did all the packets arrive?
00043     bool isComplete() const { return rawData_.isComplete(); }
00044 
00045     //
00046     // Functions for retreiving the data in sane units.
00047     // Should only be called when the data structure is full.
00048     //
00049     // All units are S.I.
00050     //
00051 
00052     // Get all status flags
00053     std::vector<StatusFlag> statusFlags() const;
00054     // Is there a warning condition?
00055     bool isWarn() const;
00056     // Is there an error condition?
00057     bool isFault() const;
00058 
00059     // Not sure how to interpret the build ID, so just report it as-is.
00060     int16_t buildId() const
00061         {
00062             return rawData_.build_id; 
00063         }
00064 
00065     // roll/pitch/yaw
00066     double pitchAngle() const 
00067         {
00068             return converter_.angleInRadians(rawData_.pitch);
00069         }
00070     double pitchRate() const 
00071         {
00072             return converter_.angularRateInRadians(rawData_.pitch_dot);
00073         }
00074     double rollAngle() const
00075         {
00076             return converter_.angleInRadians(rawData_.roll);
00077         }
00078     double rollRate() const
00079         {
00080             return converter_.angularRateInRadians(rawData_.roll_dot);
00081         }
00082     double yaw() const
00083         {
00084             // Note special case: angle specified in revolutions
00085             return converter_.angleInRadiansFromRevCounts(rawData_.yaw);
00086         }
00087     double yawRate() const
00088         {
00089             // take the additive inverse, since the RMP reports
00090             // clockwise angular velocity as positive.
00091             return -converter_.angularRateInRadians(rawData_.yaw_dot);
00092         }
00093     
00094     // wheels
00095     double leftWheelDisplacement() const
00096         {
00097             return converter_.distanceInM(rawData_.left_wheel_displacement);
00098         }
00099 
00100     double rightWheelDisplacement() const
00101         {
00102             return converter_.distanceInM(rawData_.right_wheel_displacement);
00103         }
00104     double leftWheelVelocity() const
00105         {
00106             return converter_.speedInMperS(rawData_.left_wheel_velocity);
00107         }
00108     double rightWheelVelocity() const
00109         {
00110             return converter_.speedInMperS(rawData_.right_wheel_velocity);
00111         }
00112 
00113     // values based on wheels
00114     double foreAftDisplacement() const
00115         {
00116             return converter_.distanceInM(rawData_.foreaft_displacement);
00117         }
00118     double leftMotorTorque() const
00119         {
00120             return converter_.torqueInNM(rawData_.left_torque);
00121         }
00122     double rightMotorTorque() const
00123         {
00124             return converter_.torqueInNM(rawData_.right_torque);
00125         }
00126 
00127     // other gear
00128     int servoFrames()
00129         {
00130             return rawData_.servo_frames;
00131         }
00132     double uiBatteryVoltage()
00133         {
00134             return converter_.uiVoltageInVolts(rawData_.ui_battery_voltage);
00135         }
00136     // We only know the minimum of the two main batteries.
00137     double baseBatteryVoltage()
00138         {
00139             return converter_.baseVoltageInVolts(rawData_.base_battery_voltage);
00140         }
00141     OperationalMode operationalMode()
00142         {
00143             return converter_.operationalModeAsEnum(rawData_.operational_mode);
00144         }
00145     GainSchedule gainSchedule()
00146         {
00147             return converter_.gainScheduleAsEnum(rawData_.controller_gain_schedule);
00148         }
00149 
00150 //     double receivedVelocityCommand()
00151 //         {
00152 //             return converter_.
00153 //         }
00154 
00155 
00156     // Prints out in human-readable form
00157     std::string toString() const { return rawData_.toString(); }
00158 
00159     // Allow direct access to the raw data
00160     const RawRxData rawData() const { return rawData_; }
00161 
00162 private: 
00163 
00164     // Stores the data in the RMP's native representation
00165     RawRxData rawData_;
00166 
00167     // Convert between units
00168     UnitConverter converter_;
00169 };
00170 
00171 }
00172 
00173 #endif
 

Webmaster: Tobias Kaupp (tobasco at users.sourceforge.net)


Generated for Orca Robotics by  doxygen 1.4.5