Rauno U
/
Miisu
Six crescent shaped legs
SyncGroup.cpp@47:4f418a4b0051, 2016-06-21 (annotated)
- Committer:
- sim642
- Date:
- Tue Jun 21 14:43:44 2016 +0000
- Revision:
- 47:4f418a4b0051
- Parent:
- 18:1437610bea8b
Byte based communication
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sim642 | 18:1437610bea8b | 1 | #include "SyncGroup.hpp" |
sim642 | 18:1437610bea8b | 2 | #include "Math.hpp" |
sim642 | 18:1437610bea8b | 3 | |
sim642 | 18:1437610bea8b | 4 | float SyncGroup::update(EncoderMotor *motor, float factor) |
sim642 | 18:1437610bea8b | 5 | { |
sim642 | 18:1437610bea8b | 6 | factors[motor] = factor; |
sim642 | 18:1437610bea8b | 7 | return getMinimum(motor); |
sim642 | 18:1437610bea8b | 8 | } |
sim642 | 18:1437610bea8b | 9 | |
sim642 | 18:1437610bea8b | 10 | float SyncGroup::getMinimum(EncoderMotor *exclude) |
sim642 | 18:1437610bea8b | 11 | { |
sim642 | 18:1437610bea8b | 12 | float factor = 1.f; |
sim642 | 18:1437610bea8b | 13 | for (std::map<EncoderMotor*, float>::iterator it = factors.begin(); it != factors.end(); ++it) |
sim642 | 18:1437610bea8b | 14 | { |
sim642 | 18:1437610bea8b | 15 | if (it->first != exclude) |
sim642 | 18:1437610bea8b | 16 | factor = ::min(factor, it->second); |
sim642 | 18:1437610bea8b | 17 | } |
sim642 | 18:1437610bea8b | 18 | return factor; |
sim642 | 18:1437610bea8b | 19 | } |