eBoard ๐Ÿ‰  โ‘ โ‘งโ‘จ
Written for SIA 2017/2018
eagle_DynamixelBoard.h
Go to the documentation of this file.
1 #ifndef EAGLE_EBOARD_HELPLIB_DYNAMIXELBOARD
2 #define EAGLE_EBOARD_HELPLIB_DYNAMIXELBOARD
3 
26  struct DynamixelBoard {
30  inline DynamixelBoard(SoccerBoard&);
31  //inline ~DynamixelBoard(void) {}
32  #if EBOARD_USE_UTILITY > 0x0
33  inline void changeId(optVAL_t);
36  inline void changeMotorID(optVAL_t);
38  inline void ledOn(optVAL_t);
40  inline void ledOff(optVAL_t);
41  #endif
42  inline void action(void);
44 
46  friend struct AX12Servo;
47  protected:
54  };
57  for(optVAL_t i = 0; i < EBOARD_SPI_SERVO_MAX; i++ ) {this->connected[i] = NULL;} //wanna use nullptr... wanna have c++11^^
58  }
59  //inline ~DynamixelBoard(void) {}
60  #if EBOARD_USE_UTILITY > 0x0
61  void DynamixelBoard::changeId(optVAL_t) {}
62  void DynamixelBoard::changeMotorID(optVAL_t) {}
63  void DynamixelBoard::ledOn(optVAL_t) {}
64  void DynamixelBoard::ledOff(optVAL_t) {}
65  #endif
66  void DynamixelBoard::action(void) {
67  for(optVAL_t i = 0; (i < EBOARD_SPI_SERVO_MAX && !STOP); i++ ){
68  if(this->connected[i] != NULL)
69  (*connected[i]).setPosition((*connected[i]).storedPos,(*connected[i]).storedSpe);
70  }
71  }
72 
73 
74  void AX12Servo::storePosition(int pos, int speed){
75  if(this->id < EBOARD_SPI_SERVO_MAX) _conBoard->connected[this->id] = this;
76  this->storedPos=pos;this->storedSpe=speed;
77  }
78  AX12Servo::AX12Servo(DynamixelBoard &dBoard, optVAL_t servoID): _conBoard( &dBoard),id(servoID-1), actSpe(0x96) {
79  //#if EBOARD_DEBUG_MODE > 0x0
80  // assert(servoID<EBOARD_SPI_SERVO_MAX);
81  //#endif
82  }
84 #endif
[COPY&PASTE] This is the SoccerBoard ghost struct :D
[COPY&PASTE] This is the AX12Servo ghost struct :D
void storePosition(int pos, int speed=0x3FF)
This saves the Servo Position.
int actSpe
stores the actual &#39;would use speed&#39; of the AX12Servo
AX12Servo * connected[EBOARD_SPI_SERVO_MAX]
stores the pointers to the registerd AX12Servo
int storedPos
stores the position the Servo should go to DynamixelBoard::action()
#define EBOARD_SPI_SERVO_MAX
Definition: eBoard.h:294
optVAL_t id
stores the id of the AX12Servo obejct
DynamixelBoard(SoccerBoard &)
The constructor.
static bool STOP
Definition: eBoard.h:186
int storedSpe
stores the Speed of the Servo DynamixelBoard::action()
[COPY&PASTE] This is the DynamixelBoard ghost struct :D
DynamixelBoard * _conBoard
void action(void)
will force every AX12Servo to drive to AX12Servo::storedPos with AX12Servo::storedSpeed ...
AX12Servo(void)
The constructor.
void setPosition(int pos, int speed=0x3FF)
This moves the Servo to the new position.
DynamixelBoard dBoard(board)
the dBoard object
int optVAL_t
Definition: eBoard.h:196