I agree with John, keep it simple, just send the same velocity or other commands to both motors.
I had started working on a “motor group” class a few weeks ago, may or may not include something like this into a future VCS sdk, we don’t want to take all the fun away from teams. However, the beginnings were along these lines.
namespace vex {
class motor_group {
private:
std::vector<vex::motor> _motors;
void _addMotor() {};
template <typename... Args>
void _addMotor( vex::motor m1, Args... m2 ) {
_motors.push_back(m1);
_addMotor( m2... );
}
public:
motor_group() {};
template <typename... Args>
motor_group( vex::motor m1, Args... m2 ) {
_motors.push_back(m1);
_addMotor( m2... );
}
~motor_group() {};
void spin( directionType dir ) {
for ( auto m: _motors) {
m.spin( dir );
}
};
void rotateTo( double rotation, rotationUnits units, double velocity, velocityUnits units_v ) {
// start movement
for ( auto m: _motors) {
m.rotateTo( rotation, units, velocity, units_v, false );
}
// wait for all to finish
// needs timeout adding.....
bool isSpinning = true;
while( isSpinning == true ) {
isSpinning = false;
for ( auto m: _motors) {
isSpinning |= m.isSpinning();
}
this_thread::sleep_for(10);
}
};
};
}
you would create motors in the usually way
motor m1( vex::PORT1 );
motor m2( vex::PORT2 );
then create an instance of a motor group
vex::motor_group mg( m1, m2 );
and then use the group in the same way as a motor.
mg.rotateTo( 4, rotationUnits::rev, 50, velocityUnits::rpm );
I only created the two methods, all others would be similar.
anyone want to finish it off ?