cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
osaGroup.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 _osaGroup_h
19 #define _osaGroup_h
20 
21 #include <vector>
22 #include <sawBarrett/osaPuck.h>
23 
25 
27 
34 public:
35 
37  enum ID{
38 
40 
44  BROADCAST = 0x00,
45 
47 
51  UPPERARM = 0x01,
52 
54 
57  FOREARM = 0x02,
58 
60 
65  POSITION = 0x03,
66 
68  UPPERARM_POSITION = 0x04,
69 
71  FOREARM_POSITION = 0x05,
72 
74  PROPERTY = 0x06,
75 
76  HAND = 0x07,
77 
78  HAND_POSITION = 0x08,
79 
80  LASTGROUP = 0x09
81 
82  };
83 
85 
88  enum Status{ RESET=0, READY=2 };
89 
91  enum Errno{ ESUCCESS, EFAILURE };
92 
93 private:
94 
95  std::string LogPrefix();
96 
98  std::vector< osaPuck > pucks;
99 
101  osaCANBus* canbus;
102 
104  osaGroup::ID id;
105 
107 
115  static bool IsSetFrame( const osaCANBusFrame& canframe );
116 
118 
126  osaGroup::Errno PackProperty( osaCANBusFrame& canframe,
127  Barrett::Command command,
128  Barrett::ID propid,
129  Barrett::Value propval = 0 );
130 
132  static const osaCANBusFrame::ID GROUP_CODE = 0x0400;
133 
134 
135  osaGroup::Errno PackCurrents( osaCANBusFrame& frame,
136  const vctFixedSizeVector<double,4>& I );
137 
139  // positions on group 3
140  osaGroup::Errno GetProperty( Barrett::ID id,
141  std::vector<Barrett::Value>& values );
142 
144  osaGroup::Errno SetProperty( Barrett::ID id,
145  Barrett::Value value,
146  bool verify );
147 
148 public:
149 
151 
157  osaGroup( osaGroup::ID id, osaCANBus* canbus, bool createfilter=true );
158 
160 
164  static osaCANBusFrame::ID CANID( osaGroup::ID groupid );
165 
167  osaGroup::ID GetID() const;
168 
170  static osaGroup::ID OriginID( osaCANBusFrame::ID canid );
171 
173  static osaGroup::ID OriginID( const osaCANBusFrame& canframe );
174 
176  static osaGroup::ID DestinationID( osaCANBusFrame::ID canid );
177 
179  static osaGroup::ID DestinationID( const osaCANBusFrame& canframe );
180 
182  static bool IsDestinationAGroup( const osaCANBusFrame canframe );
183 
185  void AddPuckToGroup( osaPuck::ID pid );
186 
187  bool Clear() const { return pucks.empty(); }
188 
190  osaPuck First() const { return pucks.front(); }
191  osaPuck Last() const { return pucks.back(); }
192 
193  bool IsEmpty() const { return pucks.empty(); }
194 
195 
196  osaGroup::Errno Initialize();
197 
198  osaGroup::Errno Reset();
199 
200  osaGroup::Errno Ready();
201 
202  osaGroup::Errno GetStatus( std::vector<Barrett::Value>& status );
203 
204 
205  osaGroup::Errno GetPositions( vctDynamicVector<double>& q );
206  osaGroup::Errno SetTorques( const vctFixedSizeVector<double,4>& tau );
207 
208  osaGroup::Errno SetMode( Barrett::Value mode );
209 
210 
211 
212 };
213 
214 // Increment operator for pucks id
215 osaGroup::ID operator++( osaGroup::ID& gid, int i );
216 
217 #endif
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
Command
Definition: Barrett.h:25
A logical group of pucks.
Definition: osaGroup.h:33
Errno
Error codes used by osaGroup.
Definition: osaGroup.h:91
unsigned short ID
The id of a CAN frame.
Definition: osaCANBusFrame.h:25
Implements a Barrett puck.
Definition: osaPuck.h:36
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
Definition: osaGroup.h:91
osaGroup::ID operator++(osaGroup::ID &gid, int i)
osaPuck First() const
Return the puck ID of the first member.
Definition: osaGroup.h:190
bool IsEmpty() const
Definition: osaGroup.h:193
CAN frame implementation.
Definition: osaCANBusFrame.h:16
Generic CAN bus.
Definition: osaCANBus.h:15
Status
Define the status of a group.
Definition: osaGroup.h:88
ID
The ID used to identify each group.
Definition: osaGroup.h:37
osaPuck Last() const
Definition: osaGroup.h:191
bool Clear() const
Definition: osaGroup.h:187
ID
Definition: Barrett.h:36