eBoard ๐Ÿ‰  โ‘ โ‘งโ‘จ
Written for SIA 2017/2018
eagle_AX12Servo.h
Go to the documentation of this file.
1 #ifndef EAGLE_EBOARD_HELPLIB_AX12SERVO
2 #define EAGLE_EBOARD_HELPLIB_AX12SERVO
3 
5  struct DynamixelBoard;
7 
32  struct AX12Servo {
37  AX12Servo(void);
44  AX12Servo(DynamixelBoard &dBoard, optVAL_t servoID); //if borders => setPosLimit
45 
47 
48  #if EBOARD_USE_UTILITY > 0x0
49 
56  inline void setID(optVAL_t newID);
64  inline void changeMotorID(optVAL_t newID); //this should change the hardwareaddress...
70  inline void setPositionMode(void);
76  inline void setSpeedMode(void);
82  inline void setSpeed(optVAL_t);
84  inline void ledOff(void);
86  inline void ledOn(void);
88  inline void setTorque(uint16_t);
89  #endif
90 
98  void setPosition(int pos, int speed=0x3FF);
106  inline void storePosition(int pos, int speed = 0x3FF);
112  inline optVAL_t getPosition(void);
120  inline bool isMoving(void);
133 
134  //bool posMode; //we don't care wich mode we are in ^^
135 
138  private:
140  int actPos;
142  int actSpe;
143 
144  }; //shield //set limits auto register for begin
145 
147  AX12Servo::AX12Servo(void) {}
148  #if EBOARD_USE_UTILITY > 0x0
149  void AX12Servo::setID(optVAL_t newID) {this->id = newID;_servoHandler.SetServoLimit(this->id,_servoHandler.upperLimit_temp);}
150  void AX12Servo::changeMotorID(optVAL_t newID) {this->id = newID; _servoHandler.SetID(this->id, newID);} //this -should- *does now* change the hardwareaddress...
151  //IF needed: _servoHandler.setID(this->id, newID);
152  void AX12Servo::setPositionMode(void) {}
153  void AX12Servo::setSpeedMode(void) {}
154  void AX12Servo::setSpeed(optVAL_t) {} //i won't use the rotate functions...
155  void AX12Servo::ledOff(void) {} //noone needs the AX12-Servo LED
156  void AX12Servo::ledOn(void) {} //really.... noone ^^
157  void AX12Servo::setTorque(uint16_t) {} //which damn register? xD
158  #endif
159 
160  void AX12Servo::setPosition(int pos, int speed) {
161  #if EBOARD_CLAMP > 0x0
162  if(pos>1023 || speed > 1023) return;
163  this->actPos=pos; this->storedPos=pos; this->storedSpe = speed;
164  speed = speed*600/1023 - 300;
165  pos = pos *600/1023 - 300;
166 
167  #else
168  if(pos>300 || speed > 300) return;
169  this->actPos=pos; this->storedPos=pos; this->storedSpe = speed;
170  #endif
171  if(speed != actSpe){ _servoHandler.setVelocity(speed); this->actSpe=speed;}
172  _servoHandler.write(this->id,pos);
173  }
175  return this->actPos; //when moving... false value;
176  }
177  bool AX12Servo::isMoving(void) {return false;} //we don't know^^
179 #endif
int actPos
stores the actual pos or move-to pos of the AX12Servo
[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 'would use speed' of the AX12Servo
optVAL_t getPosition(void)
This "kind of" returns the Servo-Position.
bool isMoving(void)
Use this if you wan't to have a nice way of writing false.
int storedPos
stores the position the Servo should go to DynamixelBoard::action()
optVAL_t id
stores the id of the AX12Servo obejct
int storedSpe
stores the Speed of the Servo DynamixelBoard::action()
[COPY&PASTE] This is the DynamixelBoard ghost struct :D
DynamixelBoard * _conBoard
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