libkovan  1
The kovan standard library
motors.hpp
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright 2012 KISS Institute for Practical Robotics *
3  * *
4  * This file is part of libkovan. *
5  * *
6  * libkovan is free software: you can redistribute it and/or modify *
7  * it under the terms of the GNU General Public License as published by *
8  * the Free Software Foundation, either version 2 of the License, or *
9  * (at your option) any later version. *
10  * *
11  * libkovan is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14  * GNU General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU General Public License *
17  * along with libkovan. Check the LICENSE file in the project root. *
18  * If not, see <http://www.gnu.org/licenses/>. *
19  **************************************************************************/
20 
29 #ifndef _MOTORS_HPP_
30 #define _MOTORS_HPP_
31 
32 #include "port.hpp"
33 #include "sensor.hpp"
34 #include "export.h"
35 
43 {
44 public:
49  Motor(const port_t& port) throw();
50 
51  void clearPositionCounter();
52 
53  void moveAtVelocity(const short& velocity);
54  void moveToPosition(const short& speed, const int& goalPos);
55  void moveRelativePosition(const short& speed, const int& deltaPos);
56 
57 #ifndef SWIG
58  void setPidGains(const short& p, const short& i, const short& d, const short& pd, const short& id, const short& dd);
59  void pidGains(short& p, short& i, short& d, short& pd, short& id, short& dd) const;
60 #endif
61 
62  void freeze();
63 
68  bool isMotorDone() const;
69 
75  void blockMotorDone() const;
76 
82  void forward();
83 
89  void backward();
90 
95  void motor(int percent);
96 
100  void off();
101 
106  const port_t& port() const;
107 
108 private:
109  port_t m_port;
110 };
111 
117 class EXPORT_SYM BackEMF : public Sensor<int>
118 {
119 public:
120  BackEMF(const unsigned char& port);
121  virtual int value() const;
122  unsigned char port() const;
123 
124 private:
125  unsigned char m_port;
126 };
127 
128 #endif
The base class for all sensors of any type.
Definition: sensor.hpp:45
A motor object that is associated with a physical motor port.
Definition: motors.hpp:42
Base sensor classes.
virtual T value() const =0
VF EXPORT_SYM int freeze(int motor)
int port_t
Definition: port.hpp:14
Allows the reading of the back emf values for each motor.
Definition: motors.hpp:117
#define EXPORT_SYM
Definition: export.h:7
VF EXPORT_SYM void motor(int motor, int percent)
VF EXPORT_SYM void off(int motor)