cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
osaPuck.h
Go to the documentation of this file.
1 /*
2 
3  Author(s): Simon Leonard
4  Created on: Dec 02 2009
5 
6  (C) Copyright 2009 Johns Hopkins University (JHU), All Rights
7  Reserved.
8 
9 --- begin cisst license - do not edit ---
10 
11 This software is provided "as is" under an open source license, with
12 no warranty. The complete license can be found in license.txt and
13 http://www.cisst.org/cisst/license.txt.
14 
15 --- end cisst license ---
16 */
17 
18 #ifndef _osaPuck_h
19 #define _osaPuck_h
20 
21 #include <sawCANBus/osaCANBus.h>
22 #include <sawBarrett/Barrett.h>
23 
25 
27 
37 
38 public:
39 
41 
45  enum ID { PUCK_ID1=1, // ID for a 4/7 DOF WAM
46  PUCK_ID2=2,
47  PUCK_ID3=3,
48  PUCK_ID4=4,
49  PUCK_ID5=5,
50  PUCK_ID6=6,
51  PUCK_ID7=7,
52  SAFETY_MODULE_ID=10, // ID for WAM safety module
53  PUCK_IDF1=11, // ID for BH 280
54  PUCK_IDF2=12,
55  PUCK_IDF3=13,
56  PUCK_IDF4=14 };
57 
59 
62  static const Barrett::Value STATUS_RESET = 0;
63  static const Barrett::Value STATUS_READY = 2;
64 
66 
69  static const Barrett::Value MODE_IDLE = 0;
70  static const Barrett::Value MODE_TORQUE = 2;
71  static const Barrett::Value MODE_POSITION = 3;
72  static const Barrett::Value MODE_PID = 3;
73  static const Barrett::Value MODE_VELOCITY = 4;
74  static const Barrett::Value MODE_TRAPEZOIDAL = 5;
75 
77  enum Errno{ ESUCCESS, EFAILURE };
78 
79 private:
80 
81  std::string LogPrefix();
82 
83 
85 
90  osaCANBus* canbus;
91 
93  osaPuck::ID id;
94 
96  Barrett::Value cntprev;
97 
99  Barrett::Value ipnm;
100 
102  Barrett::Value grpidx;
103 
105  Barrett::Value imax;
106 
108  Barrett::Value encpos;
109 
111  Barrett::Value mcurrent;
112 
113  Barrett::Value groupA, groupB, groupC;
114 
116 
119  static osaCANBusFrame::ID CANID( osaPuck::ID id );
120 
122 
130  static bool IsSetFrame( const osaCANBusFrame& canframe );
131 
133 
141  osaPuck::Errno PackProperty( osaCANBusFrame& canframe,
142  Barrett::Command command,
143  Barrett::ID id,
144  Barrett::Value val = 0 );
145 
146 public:
147 
149  osaPuck();
150 
152 
158  osaPuck( osaPuck::ID id, osaCANBus* can, bool createfilter=true );
159 
161  osaPuck::ID GetID() const;
162 
164 
173  static osaPuck::ID OriginID( osaCANBusFrame::ID id );
174 
176 
185  static osaPuck::ID OriginID( const osaCANBusFrame& canframe );
186 
188 
197  static osaPuck::ID DestinationID( osaCANBusFrame::ID id );
198 
200 
209  static osaPuck::ID DestinationID( const osaCANBusFrame& canframe );
210 
212 
220  Barrett::Value GroupIndex() const ;
221 
223  Barrett::Value IpNm() const ;
224 
226  Barrett::Value CountsPerRevolution() const ;
227 
229 
235  osaPuck::Errno InitializeMotor();
236 
237 
239 
243  osaPuck::Errno InitializeSM();
244 
245 
246  osaPuck::Errno SetMode( Barrett::Value mode );
247  osaPuck::Errno GetMode( Barrett::Value& mode );
248 
249  osaPuck::Errno GetGroupA();
250  osaPuck::Errno GetGroupB();
251  osaPuck::Errno GetGroupC();
252 
253  osaPuck::Errno SetGroupA( Barrett::Value A );
254  osaPuck::Errno SetGroupB( Barrett::Value B );
255  osaPuck::Errno SetGroupC( Barrett::Value C );
256 
257  osaPuck::Errno GetStatus( Barrett::Value& status );
258 
259  osaPuck::Errno GetCountsPerRev();
260  osaPuck::Errno GetIpNm();
261  osaPuck::Errno GetGroupIndex();
262  osaPuck::Errno GetMembership();
263 
264 
265  osaPuck::Errno IgnoreFault( Barrett::Value fault );
266 
267  osaPuck::Errno SetVelocityWarning( Barrett::Value vw );
268  osaPuck::Errno SetVelocityFault( Barrett::Value vf );
269 
270  osaPuck::Errno SetTorqueWarning( Barrett::Value tw );
271  osaPuck::Errno SetTorqueFault( Barrett::Value tf );
272 
274 
279  osaPuck::Errno GetProperty( Barrett::ID id, Barrett::Value& value );
280 
282 
289  osaPuck::Errno SetProperty( Barrett::ID propid,
290  Barrett::Value propval,
291  bool verify );
292 
294  osaPuck::Errno Reset();
295 
297  osaPuck::Errno Ready();
298 
299  osaPuck::Errno SetPosition( double q );
300  osaPuck::Errno GetPosition( Barrett::Value& position );
301 
303 
309  osaPuck::Errno UnpackCANFrame( const osaCANBusFrame& canframe,
310  Barrett::ID& id,
311  Barrett::Value& value );
312 
313 };
314 
315 // Increment operator for pucks id
316 osaPuck::ID operator++( osaPuck::ID& pid, int i );
317 
318 
320 
326 
327 #endif
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Command
Definition: Barrett.h:25
unsigned short ID
The id of a CAN frame.
Definition: osaCANBusFrame.h:25
Implements a Barrett puck.
Definition: osaPuck.h:36
osaPuck::ID operator++(osaPuck::ID &pid, int i)
Errno
Error values.
Definition: osaPuck.h:77
ID
Define the ID of a puck.
Definition: osaPuck.h:45
int64_t Value
Define the value of a property (4-6 bytes)
Definition: Barrett.h:28
CAN frame implementation.
Definition: osaCANBusFrame.h:16
Generic CAN bus.
Definition: osaCANBus.h:15
Definition: osaPuck.h:77
osaPuck osaSafetyModule
Define the safety module.
Definition: osaPuck.h:325
ID
Definition: Barrett.h:36