Skip to content

Commit ac5ec75

Browse files
committed
Consolidating different APIs writing to the RUN_TIME register within a single API. Now everything is consistent.
The wise programmer is told about Tao and follows it. The average programmer is told about Tao and searches for it. The foolish programmer is told about Tao and laughs at it. If it were not for laughter, there would be no Tao. The highest sounds are hardest to hear. Going forward is a way to retreat. Great talent shows itself late in life. Even a perfect program still has bugs.
1 parent 3f757d3 commit ac5ec75

File tree

4 files changed

+11
-19
lines changed

4 files changed

+11
-19
lines changed

src/Braccio++.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ BraccioClass::BraccioClass()
2525
, _is_motor_connected{false}
2626
, _motors_connected_mtx{}
2727
, _motors_connected_thd{}
28-
, runTime{SLOW}
2928
, _customMenu{nullptr}
3029
{
3130

@@ -163,6 +162,7 @@ bool BraccioClass::begin(voidFuncPtr customMenu)
163162
}
164163

165164
servos.begin();
165+
servos.setTime(SmartServoClass::BROADCAST, SLOW);
166166
servos.setPositionMode(PositionMode::IMMEDIATE);
167167

168168
_motors_connected_thd.start(mbed::callback(this, &BraccioClass::motorConnectedThreadFunc));
@@ -202,12 +202,12 @@ Servo BraccioClass::get(int const id)
202202
void BraccioClass::moveTo(float const a1, float const a2, float const a3, float const a4, float const a5, float const a6)
203203
{
204204
servos.setPositionMode(PositionMode::SYNC);
205-
servos.setPosition(1, a1, runTime);
206-
servos.setPosition(2, a2, runTime);
207-
servos.setPosition(3, a3, runTime);
208-
servos.setPosition(4, a4, runTime);
209-
servos.setPosition(5, a5, runTime);
210-
servos.setPosition(6, a6, runTime);
205+
servos.setPosition(1, a1);
206+
servos.setPosition(2, a2);
207+
servos.setPosition(3, a3);
208+
servos.setPosition(4, a4);
209+
servos.setPosition(5, a5);
210+
servos.setPosition(6, a6);
211211
servos.synchronize();
212212
servos.setPositionMode(PositionMode::IMMEDIATE);
213213
}

src/Braccio++.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,6 @@ class BraccioClass
114114
void setMotorConnectionStatus(int const id, bool const is_connected);
115115
void motorConnectedThreadFunc();
116116

117-
speed_grade_t runTime; //ms
118-
119117
voidFuncPtr _customMenu;
120118

121119
const int BTN_LEFT = 3;
@@ -177,7 +175,7 @@ class Servo
177175
inline bool engaged() { return _servos.isEngaged(_id); }
178176

179177
inline Servo & move() { return *this; }
180-
inline Servo & to (float const angle) { _servos.setPosition(_id, angle, _speed); return *this; }
178+
inline Servo & to (float const angle) { _servos.setPosition(_id, angle); return *this; }
181179
inline Servo & in (std::chrono::milliseconds const len) { _servos.setTime(_id, len.count()); return *this; }
182180

183181
inline float position() { return _servos.getPosition(_id); }
@@ -191,8 +189,6 @@ class Servo
191189

192190
SmartServoClass & _servos;
193191
int const _id;
194-
int const _speed = 100;
195-
196192
};
197193

198194
struct __callback__container__ {

src/lib/motors/SmartServo.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void SmartServoClass::begin()
175175
_positionMode = PositionMode::IMMEDIATE;
176176
}
177177

178-
void SmartServoClass::setPosition(uint8_t const id, float const angle, uint16_t const speed)
178+
void SmartServoClass::setPosition(uint8_t const id, float const angle)
179179
{
180180
if (!isValidAngle(angle))
181181
return;
@@ -184,7 +184,6 @@ void SmartServoClass::setPosition(uint8_t const id, float const angle, uint16_t
184184
if (isValidId(id))
185185
{
186186
_targetPosition[idToArrayIndex(id)] = angleToPosition(angle);
187-
_targetSpeed[idToArrayIndex(id)] = speed;
188187
if (_positionMode==PositionMode::IMMEDIATE) {
189188
writeWordCmd(id, REG(SmartServoRegister::TARGET_POSITION_H), angleToPosition(angle));
190189
}
@@ -212,15 +211,13 @@ void SmartServoClass::synchronize()
212211
_txPacket.length = MAX_TX_PAYLOAD_LEN;
213212
_txPacket.instruction = CMD(SmartServoOperation::SYNC_WRITE);
214213
_txPacket.payload[0] = REG(SmartServoRegister::TARGET_POSITION_H);
215-
_txPacket.payload[1] = 4;
214+
_txPacket.payload[1] = 2;
216215
int index = 2;
217216

218217
for (int i = MIN_MOTOR_ID; i <= MAX_MOTOR_ID; i++) {
219218
_txPacket.payload[index++] = i;
220219
_txPacket.payload[index++] = _targetPosition[idToArrayIndex(i)] >>8;
221220
_txPacket.payload[index++] = _targetPosition[idToArrayIndex(i)];
222-
_txPacket.payload[index++] = _targetSpeed[idToArrayIndex(i)]>>8;
223-
_txPacket.payload[index++] = _targetSpeed[idToArrayIndex(i)];
224221
}
225222
sendPacket();
226223
}

src/lib/motors/SmartServo.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SmartServoClass
2626

2727
inline void setPositionMode(PositionMode const mode) { _positionMode = mode; }
2828

29-
void setPosition(uint8_t const id, float const angle, uint16_t const speed);
29+
void setPosition(uint8_t const id, float const angle);
3030

3131
float getPosition(uint8_t const id);
3232

@@ -120,7 +120,6 @@ class SmartServoClass
120120
uint8_t _rxBuf[MAX_RX_PAYLOAD_LEN];
121121
uint8_t _rxLen;
122122
uint16_t _targetPosition[NUM_MOTORS];
123-
uint16_t _targetSpeed[NUM_MOTORS];
124123
PositionMode _positionMode;
125124
};
126125

0 commit comments

Comments
 (0)