home *** CD-ROM | disk | FTP | other *** search
- //**********************************************************************
- // DIVE Laboratories, Inc.
- // Copyright(c) 1995
- // All rights reserved.
- // FILE: SENSOR.HPP
- //
- // DESCRIPTION
- // This file provides the function prototypes for the sensorClass
- //
- // Author: M. Doucet
- //
- // Modification History:
- // 7/6/95 Created
- //
- //**********************************************************************
- #ifndef _SENSOR_HPP
- #define _SENSOR_HPP
-
- #ifdef AMBER_DEBUG_LIB
- #define _DEBUG
- #endif
- #ifdef WIN32
- #include <windows.h> // includes basic windows functionality
- #endif
- #ifdef AMBER_DEBUG_LIB
- #undef _DEBUG
- #endif
-
- #include "slink.hpp"
- #include "vector.hpp"
- #include "channel.hpp"
- #include "geometry.hpp"
- #include "quat.hpp"
-
- typedef enum {_NOME, _LBD, _LBU, _MBD, _MBU, _RBD, _RBU, _MM} mouseEventEnum;
- typedef enum {NO_COM, COM1, COM2, COM3, COM4} portEnumType;
- typedef enum {NO_ANGLES, ABSOLUTE_ANGLES, DELTA_ANGLES} sensorAngleEnumType;
- typedef enum {NO_POSITIONS, ABSOLUTE_POSITIONS, DELTA_POSITIONS} sensorPositionEnumType;
-
- class sensorClass {
-
- private:
-
- channelClass *ch;
- geometryClass *geo;
- sLinkClass channelList;
- sLinkClass geometryList;
-
- I3 rotConstraint, posConstraint;
- V3 rotSwitch, tranSwitch;
-
- vectorClass frame[3], translation;
- quatClass quat, qi, bias;
-
- int rIndex, pIndex, filterSize, filterLastWeight;
-
- V3 rot, rBuf[20], rTot, lastRot;
- V3 loc, pBuf[20], pTot, lastLoc;
-
- sensorAngleEnumType sensorAngle;
- sensorPositionEnumType sensorPosition;
-
- protected:
-
- // Port information that is used by the driver
- //
- #ifdef INDIGO2
- int hCom;
- #else
- void *hCom;
- #endif
- char in[255], out[255];
- portEnumType commPort;
- int baudRate;
- unsigned long actual;
- unsigned long avail, msg;
- int isOpen, isAlive;
- float linearScaling, rotationalScaling;
-
- // Opening and closing of the sensor
- //
- int sOpen();
- void sClose();
-
- public:
-
- // Filter functions
- //
- void setFilterSize(int fs=5);
- void setFilterLastWeight(int fw=2);
-
- // Attaching channels and geometries
- //
- void attachChannel(channelClass *ch);
- void removeChannel(channelClass *ch);
-
- void attachGeometry(geometryClass *geo);
- void removeGeometry(geometryClass *geo);
-
- // Angular and linear constraints
- //
- void setRotConstraint(int axis);
- void setPosConstraint(int axis);
- void clearRotConstraint(int axis);
- void clearPosConstraint(int axis);
- void clearAllConstraints();
-
- // Switch directions
- void switchRotation(int axis);
- void switchTranslation(int axis);
-
- // Angle and position updating (angles must be in radians)
- //
- void updateAngles(V3 angle);
- void updatePositions(V3 pos);
- void update();
- void getAngles(V3 angle, int smoothed=FALSE);
- void getPositions(V3 pos, int smoothed=FALSE);
-
- // Scaling
- //
- void setRotationalScaling(float val);
- void setLinearScaling(float val);
- float getRotationalScaling();
- float getLinearScaling();
-
- // Rotate frame orientation
- //
- void rotate(int axis, float rads);
- void setBias(quatClass q);
-
- virtual void mouseEvent(mouseEventEnum event, I2 point, void *wnd) = 0;
-
- sensorClass(portEnumType port,
- int baud,
- sensorAngleEnumType sa,
- sensorPositionEnumType sp,
- int useMouseHook);
-
- ~sensorClass();
-
- };
-
- #endif
-