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 
12 //=====================================================================================================================================================
13 // AX12Servo
14 //=====================================================================================================================================================
15 
16  //-------------------------------------------------------------------------------------------------------------------------------------------------
17  // cheat :D
18  //-------------------------------------------------------------------------------------------------------------------------------------------------
19 
21  struct DynamixelBoard;
23 
24  //-------------------------------------------------------------------------------------------------------------------------------------------------
25  // class
26  //-------------------------------------------------------------------------------------------------------------------------------------------------
51  struct AX12Servo {
56  AX12Servo(void);
63  AX12Servo(DynamixelBoard &dBoard, optVAL_t servoID); //if borders => setPosLimit
64 
66 
67  #if EBOARD_USE_UTILITY > 0x0
68 
75  inline void setID(optVAL_t newID);
83  inline void changeMotorID(optVAL_t newID); //this should change the hardwareaddress...
89  inline void setPositionMode(void);
95  inline void setSpeedMode(void);
101  inline void setSpeed(optVAL_t);
103  inline void ledOff(void);
105  inline void ledOn(void);
107  inline void setTorque(uint16_t);
108  #endif
109 
117  void setPosition(int pos, int speed=0x3FF);
125  inline void storePosition(int pos, int speed = 0x3FF);
131  inline optVAL_t getPosition(void);
139  inline bool isMoving(void);
152 
153  //bool posMode; //we don't care wich mode we are in ^^
154 
157  private:
159  int actPos;
161  int actSpe;
162 
163  }; //shield //set limits auto register for begin
164 
166 
167  //-------------------------------------------------------------------------------------------------------------------------------------------------
168  // definitions
169  //-------------------------------------------------------------------------------------------------------------------------------------------------
170 
171  AX12Servo::AX12Servo(void) {}
172 
173  #if EBOARD_USE_UTILITY > 0x0
174  void AX12Servo::setID(optVAL_t newID) {this->id = newID;_servoHandler.SetServoLimit(this->id,_servoHandler.upperLimit_temp);}
175  void AX12Servo::changeMotorID(optVAL_t newID) {this->id = newID; _servoHandler.SetID(this->id, newID);} //this -should- *does now* change the hardwareaddress...
176  //IF needed: _servoHandler.setID(this->id, newID);
177  void AX12Servo::setPositionMode(void) {}
178  void AX12Servo::setSpeedMode(void) {}
179  void AX12Servo::setSpeed(optVAL_t) {} //i won't use the rotate functions...
180  void AX12Servo::ledOff(void) {} //noone needs the AX12-Servo LED
181  void AX12Servo::ledOn(void) {} //really.... noone ^^
182  void AX12Servo::setTorque(uint16_t) {} //which damn register? xD
183  #endif
184 
185  void AX12Servo::setPosition(int pos, int speed) {
186  #if EBOARD_CLAMP > 0x0
187  if(pos>1023 || speed > 1023) return;
188  this->actPos=pos; this->storedPos=pos; this->storedSpe = speed;
189  speed = speed*600/1023 - 300;
190  pos = pos *600/1023 - 300;
191 
192  #else
193  if(pos>300 || speed > 300) return;
194  this->actPos=pos; this->storedPos=pos; this->storedSpe = speed;
195  #endif
196  if(speed != actSpe){ _servoHandler.setVelocity(speed); this->actSpe=speed;}
197  _servoHandler.write(this->id,pos);
198  }
200  return this->actPos; //when moving... false value;
201  }
202  bool AX12Servo::isMoving(void) {return false;} //we don't know^^
204 #endif
int actPos
stores the actual pos or move-to pos of the AX12Servo
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.
void SetServoLimit(int ID, int upperLimit)
(probably) set the posLimit for only one servo (will be overwritten by write() => writePos()) ...
void setVelocity(int velocity)
Sets the default speed of servos.
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
void SetID(int ID, int newID)
change the ID of a special Servo
int storedSpe
stores the Speed of the Servo DynamixelBoard::action()
This is the DynamixelBoard ghost struct :D.
int upperLimit_temp
stores the posLimit value send with write()
DynamixelBoard * _conBoard
void write(int ID, int Pos)
Moves a Servo to a certain position.
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
ServoCds55 _servoHandler
this is the "to_use" instance of ServoCds55
int optVAL_t
Definition: eBoard.h:133