cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsLoPoMoCo.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5  Author(s): Ankur Kapoor, Tian Xia
6  Created on: 2004-04-30
7 
8  (C) Copyright 2004-2011 Johns Hopkins University (JHU), All Rights
9  Reserved.
10 
11  --- begin cisst license - do not edit ---
12 
13  This software is provided "as is" under an open source license, with
14  no warranty. The complete license can be found in license.txt and
15  http://www.cisst.org/cisst/license.txt.
16 
17  --- end cisst license ---
18  */
19 
25 #ifndef _mtsLoPoMoCo_h
26 #define _mtsLoPoMoCo_h
27 
30 
31 #include <vector>
32 #include <string>
33 #include <ostream>
34 
35 // Always include last!
37 
38 // forward declarations
39 class osaLoPoMoCoBoardIO;
40 
45 
47 
50  std::vector<osaLoPoMoCoBoardIO *> Board;
51 
53  std::vector<int> StartAxis;
54 
56  std::vector<int> EndAxis;
57 
59  std::vector<unsigned int> MaxAxis;
60 
62  std::vector<int> BaseAddress;
63 
65  int numberOfAxes;
66  int numberOfBoards;
67 
68  //std::string RelativePathToConfigFiles;
69 
72  mtsShortVec MotorVoltages;
73 
75  mtsShortVec EncoderPeriods;
76 
78  mtsShortVec EncoderFrequencies;
79 
81  mtsDoubleVec FrequencyToRPSRatio;
82 
84  // anton mtsDoubleVec CountsToDeg;
85 
87  mtsDoubleVec CountsToMotorCurrents;
88 
90  mtsDoubleVec CountsToPotFeedback;
91 
93  mtsDoubleVec MotorSpeedToCounts;
94 
96  mtsDoubleVec PositiveSlope;
97 
99  mtsDoubleVec PositiveIntercept;
100 
102  mtsDoubleVec NegativeSlope;
103 
105  mtsDoubleVec NegativeIntercept;
106 
108  mtsDoubleVec VoltageToCounts;
109 
110  // TODO: Tian: ankur mixes unsigned short and int, is this a problem?
116  inline int MapAxisToBoard(unsigned short axisIndex) {
117  return axisIndex/4;
118  }
119 
120  void ConfigureOneBoard(const std::string & filename, const int boardIndex);
121  void parseInputArgument(const std::string &inputArgument, std::string &relativeFilePath, std::string &fileName);
122 
123 public:
124 
126  enum {NB_AXIS = 4};
127 
129  mtsLoPoMoCo(const std::string& deviceName, unsigned int numberOfBoards);
130 
132  virtual ~mtsLoPoMoCo();
133 
138  virtual void Configure(const std::string &filename);
139 
140 protected:
141  /*******************************************
142  * Start of the Read Commands, no parameters
143  *******************************************/
146  //mtsCommandBase::ReturnType LatchEncoders(void);
147  void LatchEncoders(void);
148 
152  //mtsCommandBase::ReturnType StartMotorCurrentConv(void);
153  void StartMotorCurrentConv(void);
154 
157  //mtsCommandBase::ReturnType StartPotFeedbackConv(void);
158  void StartPotFeedbackConv(void);
159  void StartPotFeedbackConvFast(void);
160 
163  void EnableAll(void);
166  void DisableAll(void);
167 
168  /*******************************
169  * Start of the Read Commands
170  *******************************/
174  // type is Long
175  void GetPositions(mtsLongVec & Positions) const;
176 
181  // type is Short
182  void GetVelocities(mtsShortVec & Velocities) const;
183 
187  // type is short
188  void GetMotorCurrents(mtsShortVec & MotorCurrents) const;
189 
193  // type is short
194  void GetPotFeedbacks(mtsShortVec & PotFeedbacks) const;
195 
196  /*******************************
197  * Start of the Write Commands
198  *******************************/
203  // type is short
204  void SetMotorVoltages(const mtsShortVec & MotorVoltages);
205 
210  // type is short
211  void SetCurrentLimits(const mtsShortVec & CurrentLimits);
212 
216  // type is Long (raw positions or encoder counts)
217  void SetPositions(const mtsLongVec & Positions);
218 
221  // type is void
222  void LoadMotorVoltages(void);
223 
227  // type is void
228  void LoadCurrentLimits(void);
229 
233  void LoadMotorVoltagesCurrentLimits(void);
234 
237  // type is shor to double
238  void FrequencyToRPS(const mtsShortVec & fromData, mtsDoubleVec & toData) const;
239 
242  // type is short to double
243  void ADCToMotorCurrents(const mtsShortVec & fromData, mtsDoubleVec & toData) const;
244 
247  // type is short to double
248  void ADCToPotFeedbacks(const mtsShortVec & fromData, mtsVector <double> & toData) const;
249 
252  // type is DOUBLE TO SHORT
253  void MotorVoltagesToDAC(const mtsDoubleVec & fromData, mtsShortVec & toData) const;
254 
257  // type is double to short
258  void CurrentLimitsToDAC(const mtsDoubleVec & fromData, mtsShortVec & toData) const;
259 
262  void Enable(const mtsShort & axisIndex);
263 
266  void Disable(const mtsShort & axisIndex);
267 
270  void ResetEncoders(const mtsShort & axisIndex);
271 
272  /* set digital output */
273  void SetDigitalOutput(const mtsIntVec & DigitalOutput);
274 
275  /* get digital input */
276  void GetDigitalInput(mtsIntVec & DigitalInput) const;
277 
278  /* get latched index:
279  might only be available in Version 0xCCDD FPGA (MR-Robot) */
280  void GetLatchedIndex(mtsShortVec & latchedIndex) const;
281 };
282 
284 
285 #endif // _mtsLoPoMoCo_h
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Definition: mtsLoPoMoCo.h:44
Declaration of mtsComponent.
Definition: mtsComponent.h:150
CMN_DECLARE_SERVICES_INSTANTIATION(mtsLoPoMoCo)
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
Definition: mtsGenericObjectProxy.h:45
const int CMN_NO_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:328
virtual void Configure(const std::string &filename="")
#define CMN_LOG_ALLOW_DEFAULT
Definition: cmnLogLoD.h:76