cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mtsIntuitiveDaVinci.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 
6  Author(s): Anton Deguet, Nicolas Padoy
7  Created on: 2010-04-06
8 
9  (C) Copyright 2010-2011 Johns Hopkins University (JHU), All Rights 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 
20 #ifndef _mtsIntuitiveDaVinci_h
21 #define _mtsIntuitiveDaVinci_h
22 
23 // cisst library headers
34 
35 // Always include last
37 
52 // forward declarations
54 
55 namespace mtsIntuitiveDaVinciUtilities {
56  void StreamCallbackInternal(void * userData);
57  void EventCallbackInternal(int manipulatorId,
58  int eventId,
59  int* arguments,
60  void * userData);
61 };
62 
63 
64 class CISST_EXPORT mtsIntuitiveDaVinci: public mtsTaskPeriodic { //mtsTaskFromSignal {
65 
67 
68  friend void mtsIntuitiveDaVinciUtilities::StreamCallbackInternal(void * userData);
69  friend void mtsIntuitiveDaVinciUtilities::EventCallbackInternal(int manipulatorId,
70  int eventId,
71  int* arguments,
72  void * userData);
73  public:
74 
76  mtsIntuitiveDaVinci(const std::string & name, unsigned int rateInHz);
77 
80 
81  void SetSourceHost(const std::string _ipaddress, const unsigned int _port = 5002, const unsigned int _password = 0x1111);
82  void SetSourceLogFile(const std::string _filename);
84  void SetOutputLogFile(const std::string filename);
86  void StartLogging(void);
88  void StopLogging(void);
89 
90  void Configure(const std::string & CMN_UNUSED(filename) = "") {};
91  void Startup(void);
92  void Run(void);
93  void Cleanup(void);
94 
96  inline bool IsAPIConnected(void) const {
97  return this->Connected;
98  }
99 
102  typedef enum {
103  MTML1 = 0,
114  NUMBER_MANIPULATORS
115  } ManipulatorIndexType;
116 
117  typedef enum {
118  MTM_TYPE = 0,
122  NUMBER_MANIPULATOR_TYPES
123  } ManipulatorType;
124 
125  protected:
126 
128  class ArmData {
129  public:
130  ArmData(void);
140  };
141 
143  class MasterArmData: public ArmData {
144  public:
145  MasterArmData(void);
148  bool Selected;
149  static const double SelectAngle;
154  bool Clutched;
155  static const double ClutchAngle;
156  };
157 
159  class SlaveArmData: public ArmData {
160  public:
161  SlaveArmData(void);
165  };
166 
169  {
170  public:
171  ConsoleData(void);
177 
180 
183 
186  bool Clutched;
187 
190 
194 
197  };
198 
199  class EventData {
200  public:
201  EventData(void);
205  };
206 
208  ArmData * Arms[(ECM1 - MTML1) + 1];
209 
211  MasterArmData * MasterArms[(MTMR2 - MTML1) + 1];
212 
214  SlaveArmData * SlaveArms[(ECM1 - PSM1) + 1];
215 
217  SlaveArmData * CameraArms[(ECM1 - ECM1) + 1];
218 
221  ConsoleData * Consoles[(CONSOLE2 - CONSOLE1) + 1];
222 
225 
227  bool Connect(void);
228 
230  bool Disconnect(void);
231 
232  bool ConfigureStream(void);
233  void StreamCallback(void);
234 
235  bool ConfigureEvents(void);
236  void EventCallback(ManipulatorIndexType index, int eventId, int* eventArgs);
237 
238  bool StartStream(void);
239 
240  void StopStream(void);
241 
243  void LogSystemConfiguration(cmnLogLevel logLevel = CMN_LOG_LEVEL_INIT_VERBOSE) const;
244  void LogManipulatorConfiguration(ManipulatorIndexType index,
245  cmnLogLevel logLevel = CMN_LOG_LEVEL_INIT_VERBOSE) const;
246  void LogToolConfiguration(ManipulatorIndexType index,
247  cmnLogLevel logLevel = CMN_LOG_LOD_INIT_VERBOSE) const;
248  void LogManipulatorsAndToolsConfiguration(cmnLogLevel logLevel = CMN_LOG_LOD_INIT_VERBOSE) const;
249 
250  public:
252  static const std::string & ManipulatorIndexToString(ManipulatorIndexType manipulatorIndex);
253 
255  static size_t GetNumberOfJoints(ManipulatorIndexType manipulatorIndex);
256 
258  static size_t GetNumberOfSetupJoints(ManipulatorIndexType manipulatorIndex);
259 
261  static ManipulatorType GetManipulatorType(ManipulatorIndexType manipulatorIndex);
262 
264  return this->Events.EventNames;
265  }
266 
267  protected:
270  void SetupEventInterfaces(void);
271  void SetupArmsInterfaces(void);
272  void SetupMastersInterfaces(void);
273  void SetupSlavesInterfaces(void);
274  void SetupCameraInterfaces(void);
275  void SetupConsoleInterfaces(void);
276  void SetupAllInterfaces(void);
278 
279  bool Connected;
280 
281  unsigned int RateInHz;
282  std::string IPAddress;
283  unsigned int Port;
284  unsigned int Password;
285  std::string SourceLogFileName;
287  std::string OutputLogFileName;
288 };
289 
290 
292 
293 
294 #endif // _mtsIntuitiveDaVinci_h
Definition: prmPositionJointGet.h:35
Defines a function object to use a void command (mtsCommandVoid)
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
bool UseLogFile
Definition: mtsIntuitiveDaVinci.h:286
Definition: prmVelocityJointGet.h:39
mtsFunctionVoid HeadIn
Definition: mtsIntuitiveDaVinci.h:173
std::string IPAddress
Definition: mtsIntuitiveDaVinci.h:282
ManipulatorType
Definition: mtsIntuitiveDaVinci.h:117
CMN_DECLARE_SERVICES_INSTANTIATION(mtsIntuitiveDaVinci)
Definition: mtsIntuitiveDaVinci.h:111
static const double SelectAngle
Definition: mtsIntuitiveDaVinci.h:149
mtsInterfaceProvided * ProvidedInterface
Definition: mtsIntuitiveDaVinci.h:132
vctDynamicVector< mtsFunctionWrite * > WriteFunctions
Definition: mtsIntuitiveDaVinci.h:203
prmVelocityCartesianGet VelocityCartesian
Definition: mtsIntuitiveDaVinci.h:136
mtsInterfaceProvided * CameraProvidedInterface
Definition: mtsIntuitiveDaVinci.h:188
mtsInterfaceProvided * ProvidedInterface
Definition: mtsIntuitiveDaVinci.h:202
mtsInterfaceProvided * StandbyProvidedInterface
Definition: mtsIntuitiveDaVinci.h:178
#define CMN_UNUSED(argument)
Definition: cmnPortability.h:479
bool Clutched
Definition: mtsIntuitiveDaVinci.h:186
Defines a task with a Run method trigger by signals (any queued command or event).
prmVelocityJointGet TorqueJoint
Definition: mtsIntuitiveDaVinci.h:139
Definition: mtsIntuitiveDaVinci.h:110
EventData Events
Definition: mtsIntuitiveDaVinci.h:224
mtsFunctionWrite Clutch
Definition: mtsIntuitiveDaVinci.h:151
unsigned int Password
Definition: mtsIntuitiveDaVinci.h:284
mtsInterfaceProvided * ClutchProvidedInterface
Definition: mtsIntuitiveDaVinci.h:184
Definition: mtsIntuitiveDaVinci.h:121
#define CMN_LOG_LEVEL_INIT_VERBOSE
Definition: cmnLogLoD.h:60
Definition: mtsFunctionVoid.h:36
mtsInterfaceProvided * ClutchEventProvidedInterface
Definition: mtsIntuitiveDaVinci.h:150
mtsInterfaceProvided * MastersAsMiceProvidedInterface
Definition: mtsIntuitiveDaVinci.h:191
vctDynamicVector< std::string > EventNames
Definition: mtsIntuitiveDaVinci.h:204
mtsFunctionWrite Clutch
Definition: mtsIntuitiveDaVinci.h:185
Definition: mtsIntuitiveDaVinci.h:120
Definition: mtsIntuitiveDaVinci.h:112
bool IsAPIConnected(void) const
Definition: mtsIntuitiveDaVinci.h:96
virtual void Startup(void)
Definition: mtsComponent.h:262
Definition: mtsIntuitiveDaVinci.h:109
mtsStateTable * StateTable
Definition: mtsIntuitiveDaVinci.h:131
mtsFunctionWrite MastersAsMice
Definition: mtsIntuitiveDaVinci.h:192
short cmnLogLevel
Definition: cmnLogLoD.h:55
mtsInterfaceProvided * ProvidedInterface
Definition: mtsIntuitiveDaVinci.h:172
mtsFloat DeviceTimestamp
Definition: mtsIntuitiveDaVinci.h:134
Cartesian Velocity move parameters.
Definition: mtsIntuitiveDaVinci.h:105
prmPositionCartesianGet PositionCartesianRCM
Definition: mtsIntuitiveDaVinci.h:162
ManipulatorIndexType
Definition: mtsIntuitiveDaVinci.h:102
prmPositionCartesianGet PositionCartesian
Definition: mtsIntuitiveDaVinci.h:135
mtsInterfaceProvided * SelectEventProvidedInterface
Definition: mtsIntuitiveDaVinci.h:146
bool Selected
Definition: mtsIntuitiveDaVinci.h:148
Definition: prmVelocityCartesianGet.h:38
mtsFunctionWrite FollowMode
Definition: mtsIntuitiveDaVinci.h:196
mtsFunctionVoid ClutchQuickTap
Definition: mtsIntuitiveDaVinci.h:175
Definition: mtsStateTable.h:67
mtsFunctionWrite Ready
Definition: mtsIntuitiveDaVinci.h:182
static const double ClutchAngle
Definition: mtsIntuitiveDaVinci.h:155
mtsInterfaceProvided * FollowModeProvidedInterface
Definition: mtsIntuitiveDaVinci.h:195
#define CMN_LOG_LOD_RUN_WARNING
Definition: cmnLogLoD.h:94
void EventCallbackInternal(int manipulatorId, int eventId, int *arguments, void *userData)
Definition: mtsIntuitiveDaVinci.h:128
Cartesian position move parameters.
Definition: mtsIntuitiveDaVinci.h:104
mtsFunctionVoid HeadOut
Definition: mtsIntuitiveDaVinci.h:174
unsigned int Port
Definition: mtsIntuitiveDaVinci.h:283
mtsInterfaceProvided * ReadyProvidedInterface
Definition: mtsIntuitiveDaVinci.h:181
Definition: mtsIntuitiveDaVinci.h:199
std::string SourceLogFileName
Definition: mtsIntuitiveDaVinci.h:285
#define CMN_DECLARE_SERVICES(hasDynamicCreation, lod)
Definition: cmnClassRegisterMacros.h:116
Joint velocity query parameters.
bool Connected
Definition: mtsIntuitiveDaVinci.h:279
Defines a periodic task.
Definition: mtsInterfaceProvided.h:96
unsigned int RateInHz
Definition: mtsIntuitiveDaVinci.h:281
mtsFunctionWrite Camera
Definition: mtsIntuitiveDaVinci.h:189
mtsFunctionVoid DataUpdated
Definition: mtsIntuitiveDaVinci.h:133
#define CMN_LOG_LOD_INIT_VERBOSE
Definition: cmnLogLoD.h:91
Definition: mtsIntuitiveDaVinci.h:107
void StreamCallbackInternal(void *userData)
Definition: mtsIntuitiveDaVinci.h:119
virtual void Run(void)=0
Definition: mtsIntuitiveDaVinci.h:106
Definition: mtsIntuitiveDaVinci.h:108
mtsFunctionVoid CameraQuickTap
Definition: mtsIntuitiveDaVinci.h:176
prmPositionJointGet PositionJoint
Definition: mtsIntuitiveDaVinci.h:137
Definition: mtsIntuitiveDaVinci.h:168
Definition: mtsIntuitiveDaVinci.h:113
Button Event payload.
Definition: mtsIntuitiveDaVinci.h:143
prmPositionCartesianGet PositionCartesianSetup
Definition: mtsIntuitiveDaVinci.h:163
Definition: mtsFunctionWrite.h:37
Definition: mtsTaskPeriodic.h:80
ConsoleData Console
Definition: mtsIntuitiveDaVinci.h:220
mtsFunctionWrite Select
Definition: mtsIntuitiveDaVinci.h:147
vctDynamicVector< std::string > GetEventNames(void)
Definition: mtsIntuitiveDaVinci.h:263
prmPositionJointGet PositionJointSetup
Definition: mtsIntuitiveDaVinci.h:164
const int CMN_NO_DYNAMIC_CREATION
Definition: cmnClassRegisterMacros.h:328
bool ClutchRestAngleNeedsUpdate
Definition: mtsIntuitiveDaVinci.h:152
mtsFunctionWrite Standby
Definition: mtsIntuitiveDaVinci.h:179
Definition: mtsIntuitiveDaVinci.h:64
bool Clutched
Definition: mtsIntuitiveDaVinci.h:154
virtual void Cleanup(void)
Definition: mtsComponent.h:267
std::string OutputLogFileName
Definition: mtsIntuitiveDaVinci.h:287
Definition: mtsIntuitiveDaVinci.h:159
double ClutchRestAngle
Definition: mtsIntuitiveDaVinci.h:153
prmVelocityJointGet VelocityJoint
Definition: mtsIntuitiveDaVinci.h:138
bool MastersAsMiced
Definition: mtsIntuitiveDaVinci.h:193
void Configure(const std::string &CMN_UNUSED(filename)="")
Definition: mtsIntuitiveDaVinci.h:90
Definition: prmPositionCartesianGet.h:37