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 
12 //=====================================================================================================================================================
13 // Dynamixel-Board
14 //=====================================================================================================================================================
15 
16  //-------------------------------------------------------------------------------------------------------------------------------------------------
17  // class
18  //-------------------------------------------------------------------------------------------------------------------------------------------------
19 
43  struct DynamixelBoard {
47  inline DynamixelBoard(SoccerBoard&);
48  //inline ~DynamixelBoard(void) {}
49  #if EBOARD_USE_UTILITY > 0x0
50  inline void changeId(optVAL_t);
53  inline void changeMotorID(optVAL_t);
55  inline void ledOn(optVAL_t);
57  inline void ledOff(optVAL_t);
58  #endif
59  inline void action(void);
61 
63  friend struct AX12Servo;
64  protected:
71  };
72 
73  //-------------------------------------------------------------------------------------------------------------------------------------------------
74  // definitions
75  //-------------------------------------------------------------------------------------------------------------------------------------------------
76 
79  for(optVAL_t i = 0; i < EBOARD_SPI_SERVO_MAX; i++ ) {this->connected[i] = NULL;} //wanna use nullptr... wanna have c++11^^
80  }
81 
82  //inline ~DynamixelBoard(void) {}
83  #if EBOARD_USE_UTILITY > 0x0
84  void DynamixelBoard::changeId(optVAL_t) {}
85  void DynamixelBoard::changeMotorID(optVAL_t) {}
86  void DynamixelBoard::ledOn(optVAL_t) {}
87  void DynamixelBoard::ledOff(optVAL_t) {}
88  #endif
89 
90  void DynamixelBoard::action(void) {
91  for(optVAL_t i = 0; (i < EBOARD_SPI_SERVO_MAX && !STOP); i++ ){
92  if(this->connected[i] != NULL)
93  (*connected[i]).setPosition((*connected[i]).storedPos,(*connected[i]).storedSpe);
94  }
95  }
96 
97  void AX12Servo::storePosition(int pos, int speed){
98  if(this->id < EBOARD_SPI_SERVO_MAX) _conBoard->connected[this->id] = this;
99  this->storedPos=pos;this->storedSpe=speed;
100  }
101 
102  AX12Servo::AX12Servo(DynamixelBoard &dBoard, optVAL_t servoID): _conBoard( &dBoard),id(servoID-1), actSpe(0x96) {
103  //#if EBOARD_DEBUG_MODE > 0x0
104  // assert(servoID<EBOARD_SPI_SERVO_MAX);
105  //#endif
106  }
107 
109 #endif
This is the SoccerBoard ghost struct :D.
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:266
optVAL_t id
stores the id of the AX12Servo obejct
DynamixelBoard(SoccerBoard &)
The constructor.
static bool STOP
Definition: eBoard.h:123
int storedSpe
stores the Speed of the Servo DynamixelBoard::action()
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:137