Dynamixel  2.9.5
RoadNarrows Robotics Dynamixel Package
DynaServoEX106P.h
Go to the documentation of this file.
1 ////////////////////////////////////////////////////////////////////////////////
2 //
3 // Package: Dynamixel
4 //
5 // Library: librnr_dynamixel
6 //
7 // File: DynaServoEX106P.h
8 //
9 /*! \file
10  *
11  * $LastChangedDate: 2015-01-12 10:56:06 -0700 (Mon, 12 Jan 2015) $
12  * $Rev: 3845 $
13  *
14  * \ingroup dyna_lib_hdrs
15  *
16  * \brief EX-106+ Dynamixel Servo Class Interface.
17  *
18  * \author Robin Knight (robin.knight@roadnarrows.com)
19  *
20  * \copyright
21  * \h_copy 2011-2017. RoadNarrows LLC.\n
22  * http://www.roadnarrows.com\n
23  * All Rights Reserved
24  */
25 /*
26  * @EulaBegin@
27  *
28  * Unless otherwise stated explicitly, all materials contained are copyrighted
29  * and may not be used without RoadNarrows LLC's written consent,
30  * except as provided in these terms and conditions or in the copyright
31  * notice (documents and software) or other proprietary notice provided with
32  * the relevant materials.
33  *
34  * IN NO EVENT SHALL THE AUTHOR, ROADNARROWS LLC, OR ANY
35  * MEMBERS/EMPLOYEES/CONTRACTORS OF ROADNARROWS OR DISTRIBUTORS OF THIS SOFTWARE
36  * BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR
37  * CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS
38  * DOCUMENTATION, EVEN IF THE AUTHORS OR ANY OF THE ABOVE PARTIES HAVE BEEN
39  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  * THE AUTHORS AND ROADNARROWS LLC SPECIFICALLY DISCLAIM ANY WARRANTIES,
42  * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
43  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN
44  * "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE NO OBLIGATION TO
45  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
46  *
47  * @EulaEnd@
48  */
49 ////////////////////////////////////////////////////////////////////////////////
50 
51 #ifndef _DYNA_SERVO_EX106P_H
52 #define _DYNA_SERVO_EX106P_H
53 
54 #include "rnr/rnrconfig.h"
55 #include "rnr/log.h"
56 
57 #include "Dynamixel/Dynamixel.h"
58 #include "Dynamixel/EX.h"
59 #include "Dynamixel/DynaError.h"
60 #include "Dynamixel/DynaComm.h"
61 #include "Dynamixel/DynaServo.h"
63 
64 
65 
66 // ---------------------------------------------------------------------------
67 // EX-106+ Extended Data Types
68 // ---------------------------------------------------------------------------
69 
70 /*!
71  * \ingroup dyna_lib_types
72  * \defgroup dyna_lib_types_ex106p EX-106+ Extended Data Types
73  *
74  * \{
75  */
76 /*! \} */
77 
78 /*!
79  * \ingroup dyna_lib_types_ex106p
80  * \brief Dynamixel EX-106+ Driver Mode Configuration Extension Structure.
81  */
82 typedef struct
83 {
84  bool m_bDriveModeIsMaster; ///< master (slave) servo
85  bool m_bDriveModeIsNormal; ///< normal (reverse) rotation to each other
87 
88 /*!
89  * \ingroup dyna_lib_types_ex106p
90  * \brief Dynamixel EX-106+ Sensed Electrical Current State Extension Structure.
91  */
92 typedef struct
93 {
94  uint_t m_uSensedCurrentMilliAmps; ///< sensed current milli-amperes
95  uint_t m_uSensedCurrentTorqueDir; ///< sensed applied torque direction
97 
98 
99 // ---------------------------------------------------------------------------
100 // EX-106+ Dynamixel Servo Base Class
101 // ---------------------------------------------------------------------------
102 
103 /*!
104  * \ingroup dyna_lib_classes
105  *
106  * \brief EX-106+ Dynamixel Servo Class.
107  *
108  * The DynaServoEX106P class provides the specific interface to the EX-106+
109  * Dynamixel servos
110  */
112 {
113 public:
114  /*! modem number */
116 
117  /*!
118  * \brief Bare-bones initialization constructor.
119  *
120  * May be used be derived classes to avoid undue communication and
121  * initializaton overhead.
122  *
123  * \param comm Dynamixel bus communication instance.
124  *
125  */
127  {
128  }
129 
130  /*!
131  * \brief Initialization constructor.
132  *
133  * \param comm Dynamixel bus communication instance.
134  * \param nServoId Servo Id.
135  * \param uModelNum Servo model number.
136  * \param uFwVer Servo firmware version.
137  */
139  int nServoId,
140  uint_t uModelNum = DYNA_MODEL_NUM,
141  uint_t uFwVer = DYNA_FWVER_NA);
142 
143  /*!
144  * \brief Destructor.
145  */
146  virtual ~DynaServoEX106P();
147 
148 
149  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
150  // Attribute Functions
151  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
152 
153  /*!
154  * \brief Get servo extended configuration.
155  *
156  * \return Reference to shadowed configuration extension data.
157  */
159  {
160  return m_cfgExt;
161  }
162 
163  /*!
164  * \brief Get servo extended state.
165  *
166  * \return Reference to shadowed state extension data.
167  */
169  {
170  return m_stateExt;
171  }
172 
173 
174  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
175  // Servo Move Functions
176  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
177 
178  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
179  // Servo Read/Write Functions
180  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
181 
182  /*!
183  * \brief Read from the servo configuration EEPROM the drive mode.
184  *
185  * If this servo is the master in a linked pair of servos, both servos'
186  * configuration data are read.
187  *
188  * \note Drive mode requires the paired EX-106+'s to be connected via the
189  * synchronization cable.
190  *
191  * \par Control Table:
192  * \ref dyna_ex106p_memmap_drive_mode.
193  *
194  * \param [out] pIsMaster This servo is [not] the master.
195  * \param [out] pIsNormal Servos [don't] rotate in same directions.
196  *
197  * \copydoc doc_return_std
198  */
199  virtual int CfgReadDriveMode(bool *pIsMaster, bool *pIsNormal);
200 
201  /*!
202  * \brief Write to the servo configuration EEPROM the new drive mode.
203  *
204  * If this servo is the master in a linked pair of servos, both servos'
205  * configuration data are written appropriately.
206  *
207  * \note Drive mode requires the paired EX-106+'s to be connected via the
208  * synchronization cable.
209  *
210  * \par Control Table:
211  * \ref dyna_ex106p_memmap_drive_mode.
212  *
213  * \param pIsMaster This servo is [not] the master.
214  * \param pIsNormal Servos [don't] rotate in same directions.
215  *
216  * \copydoc doc_return_std
217  */
218  virtual int CfgWriteDriveMode(bool bIsMaster, bool bIsNormal);
219 
220  /*!
221  * \brief Read from the servo configuration EEPROM the sensed current data.
222  *
223  * If this servo is the master in a linked pair of servos, both servos'
224  * configuration data are read.
225  *
226  * \par Control Table:
227  * \ref dyna_ex106p_memmap_drive_mode.
228  *
229  * \param [out] pMillAmps Sensed mAmps.
230  * \param [out] pTorqueDir Sensed applied torque direction.
231  *
232  * \copydoc doc_return_std
233  */
234  virtual int ReadSensedCurrent(uint_t *pMilliAmps, uint_t *pTorqueDir);
235 
236  /*!
237  * Read a raw value from the servo EEPROM/RAM control table.
238  *
239  * \warning
240  * The shadowed configuration and state data are not update.\n
241  * Linked servos are not kept in sync.
242  *
243  * \param uAddr Control table address.
244  * \param [out] pVal Read raw value.
245  *
246  * \copy doc_return_std
247  */
248  virtual int Read(uint_t uAddr, uint_t *pVal);
249 
250  /*!
251  * Write a raw value to the servo EEPROM/RAM control table.
252  *
253  * \warning The shadowed configuration and state data are not updated and will
254  * hence be out of sync.
255  *
256  * \warning Any linked master-slave servos may get out of sync and may result
257  * in physical damage.
258  *
259  * \param uAddr Control table address.
260  * \param uVal Raw value to write.
261  *
262  * \copy doc_return_std
263  */
264  virtual int Write(uint_t uAddr, uint_t uVal);
265 
266  /*!
267  * \brief Synchronize the shadowed configuration to the servo control table
268  * EEPROM configuration.
269  *
270  * \copydoc doc_return_std
271  */
272  virtual int SyncCfg();
273 
274  /*!
275  * \brief Synchronize the shadowed state data to the servo control table RAM
276  * state.
277  *
278  * \copydoc doc_return_std
279  */
280  virtual int SyncState();
281 
282  /*!
283  * \brief Dump contents of the servo EEPROM and RAM control tables.
284  */
285  virtual void Dump();
286 
287 protected:
288  DynaEX106PCfgExt_T m_cfgExt; ///< configuration extension data
289  DynaEX106PStateExt_T m_stateExt; ///< state extension data
290 
291  /*!
292  * \brief Initialize servo class instance.
293  *
294  * \param nServoId Servo Id.
295  * \param uFwVer Servo firmware version.
296  */
297  void Init(int nServoid, uint_t uFwVer);
298 
299  /*!
300  * \brief Initialize servo fixed specification data.
301  */
302  void InitSpec();
303 
304  /*!
305  * \brief Initialize servo configuration data.
306  */
307  void InitCfg();
308 
309  /*!
310  * \brief Initialize servo state data.
311  */
312  void InitState();
313 
314  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
315  // Linking Fuctions
316  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
317 
318  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
319  // Field Packing Functions
320  // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
321 
322  /*!
323  * \brief Pack drive mode.
324  *
325  * \param bIsMaster This servo is [not] the master.
326  * \param bIsNormal Servos [don't] rotate in same directions.
327  *
328  * \return Returns packed value.
329  */
330  uint_t PackDriveMode(bool bIsMaster, bool bIsNormal);
331 
332  /*!
333  * \brief Unpack drive mode.
334  *
335  * \param uVal Packed field.
336  * \param [out] pIsMaster This servo is [not] the master).
337  * \param [out] pIsNormal Servos [don't] rotate in same directions.
338  *
339  * \copydoc doc_return_std
340  */
341  int UnpackDriveMode(uint_t uVal, bool *pIsMaster, bool *pIsNormal);
342 
343  /*!
344  * \brief Unpack sensed current.
345  *
346  * \param uVal Packed field.
347  * \param [out] pMilliAmps Sensed mAmps.
348  * \param [out] pTorqueDir Sensed torque direction. See \ref dyna_servo_dir.
349  *
350  * \copydoc doc_return_std
351  */
352  int UnpackSensedCurrent(uint_t uVal, uint_t *pMilliAmps, uint_t *pTorqueDir);
353 };
354 
355 
356 #endif // _DYNA_SERVO_EX106P_H
RoadNarrows Dynamixel Bus Communications Abstract Base Class Interface.
Dynamixel EX-106+ Sensed Electrical Current State Extension Structure.
void InitSpec()
Initialize servo fixed specification data.
DynaServoEX106P(DynaComm &comm)
Bare-bones initialization constructor.
#define DYNA_FWVER_NA
firmware version not available
Definition: Dynamixel.h:136
uint_t m_uSensedCurrentTorqueDir
sensed applied torque direction
Generic Dynamixel Servo Base Class Interface.
void Init()
Initialize servo class instance.
virtual int CfgReadDriveMode(bool *pIsMaster, bool *pIsNormal)
Read from the servo configuration EEPROM the drive mode.
DynaEX106PCfgExt_T m_cfgExt
configuration extension data
EX-106+ Dynamixel Servo Class.
RoadNarrows EX Series Dynamixel Declarations.
virtual const DynaEX106PCfgExt_T & GetConfigurationExt()
Get servo extended configuration.
void InitCfg()
Initialize servo configuration data.
virtual int CfgWriteDriveMode(bool bIsMaster, bool bIsNormal)
Write to the servo configuration EEPROM the new drive mode.
#define DYNA_MODEL_NUM_EX106P
EX-106+.
Definition: EX.h:75
Generic Dynamixel Servo Base Class.
int UnpackDriveMode(uint_t uVal, bool *pIsMaster, bool *pIsNormal)
Unpack drive mode.
static const int DYNA_MODEL_NUM
DynaEX106PStateExt_T m_stateExt
state extension data
RoadNarrows Dynamixel Archetype Servo Abstract Base Class.
virtual int ReadSensedCurrent(uint_t *pMilliAmps, uint_t *pTorqueDir)
Read from the servo configuration EEPROM the sensed current data.
RoadNarrows Dynamixel Top-Level Package Header File.
virtual int Write(uint_t uAddr, uint_t uVal)
virtual ~DynaServoEX106P()
Destructor.
void InitState()
Initialize servo state data.
uint_t PackDriveMode(bool bIsMaster, bool bIsNormal)
Pack drive mode.
virtual void Dump()
Dump contents of the servo EEPROM and RAM control tables.
virtual int Read(uint_t uAddr, uint_t *pVal)
int UnpackSensedCurrent(uint_t uVal, uint_t *pMilliAmps, uint_t *pTorqueDir)
Unpack sensed current.
virtual const DynaEX106PStateExt_T & GetStateExt()
Get servo extended state.
virtual int SyncCfg()
Synchronize the shadowed configuration to the servo control table EEPROM configuration.
bool m_bDriveModeIsMaster
master (slave) servo
uint_t m_uSensedCurrentMilliAmps
sensed current milli-amperes
bool m_bDriveModeIsNormal
normal (reverse) rotation to each other
Dynamixel EX-106+ Driver Mode Configuration Extension Structure.
RoadNarrows Dynamixel Library Error and Logging Routines.
virtual int SyncState()
Synchronize the shadowed state data to the servo control table RAM state.
Dynamixel Bus Communications Abstract Base Class.
Definition: DynaComm.h:80