elektron.hpp
Go to the documentation of this file.
00001 /*
00002  * elektronv2.hpp
00003  *
00004  *  Created on: May 22, 2012
00005  *      Author: mwalecki
00006  */
00007 
00008 #ifndef ELEKTRON_HPP_
00009 #define ELEKTRON_HPP_
00010 
00011 #include <stdint.h>
00012 #include <termios.h>
00013 #include <cstdlib>
00014 #include <cstdio>
00015 #include <unistd.h>
00016 #include <fcntl.h>
00017 #include <sys/types.h>
00018 #include <sys/stat.h>
00019 #include <string>
00020 #include <fstream>
00021 #include <inttypes.h>
00022 
00023 #include "nfv2.h"
00024 
00025 // baudrate
00026 #define BAUD B115200
00027 // port
00028 #define PORT = "/dev/ttyUSB0"
00029 
00030 // wheel diameter in SI units [m]
00031 #define WHEEL_DIAM 0.1
00032 // axle length in SI units [m]
00033 #define AXLE_LENGTH 0.355
00034 
00035 // regulator rate in SI units [Hz]
00036 #define REGULATOR_RATE 100
00037 
00038 // maximum velocity, in internal units
00039 #define MAX_VEL 5500
00040 // number of encoder ticks per single wheel rotation
00041 #define ENC_TICKS 4000
00042 
00043 
00044 
00045 
00046 class Elektron {
00047 public:
00048         Elektron(const std::string& port, int baud = BAUD);
00049         ~Elektron();
00050 
00051         void update();
00052 
00053         void setVelocity(double lvel, double rvel);
00054         void getVelocity(double &lvel, double &rvel);
00055 
00056         void updateOdometry();
00057         void getRawOdometry(double &linc, double &rinc);
00058         void getOdometry(double &x, double &y, double &a);
00059         void setOdometry(double x, double y, double a);
00060         
00061         void setScale(double ls, double rs);
00062 
00063         bool isConnected();
00064 
00065         double m_per_tick;
00066         double robot_axle_length;
00067         double enc_ticks;
00068 
00069 private:
00070         // #### serial port
00071         // ####
00072         int fd;
00073         struct termios oldtio;
00074         bool connected;
00075         
00076         // #### NFv2
00077         // ####
00078         void addToCommandArray(uint8_t command);
00079         void clearCommandArray(void);
00080     uint8_t txBuf[256];
00081     uint8_t txCnt;
00082     uint8_t rxBuf[256];
00083     uint8_t rxCnt;
00084     uint8_t commandArray[256];
00085     uint8_t commandCnt;
00086     uint8_t txAddr;
00087     
00088     // #### Elektron params
00089     // ####
00090         double lin_scale;
00091         double rot_scale;
00092 };
00093 
00094 #endif /* ELEKTRON_HPP_ */


elektron_base
Author(s): Konrad Banachowicz
autogenerated on Mon Oct 6 2014 10:26:31