How would you get individual temperatures of motors in a four-motor Drivetrain? It only sends the average with the Drivetrain.temperature method.
Enable Expert Robot Configuration
go to robot-config.cpp Find the names of the individual drive motors
go to robot-config.h
it will say something like
extern drivetrain Drivetrain;
after that, add
extern motor RightF;
extern motor RightB;
extern motor LeftF;
extern motor LeftB;
Of course, replacing those with the actual names. Then, you can use them just like normal motors in the actual file. If you conventionally do not use expert robot configuration, it would be best to do this at the end after everything has been configured
These temperatures give percent units. How would you convert that to Celsius or Fahrenheit?
Alternately, RightF.temperature(temperatureUnits::celsius)
will return the temperature in degrees C. Or pass temperatureUnits::fahrenheit
to get degrees F.
In the robot-config.cpp
file, the motors that are defined to the Drivetrain are named:
motor leftMotorA = motor(PORT18, ratio18_1, true);
motor leftMotorB = motor(PORT14, ratio18_1, true);
motor_group LeftDriveSmart = motor_group(leftMotorA, leftMotorB);
motor rightMotorA = motor(PORT17, ratio18_1, false);
motor rightMotorB = motor(PORT13, ratio18_1, false);
motor_group RightDriveSmart = motor_group(rightMotorA, rightMotorB);
drivetrain Drivetrain = drivetrain(LeftDriveSmart, RightDriveSmart, 319.19, 295, 40, mm, 1);
Wouldn’t this mean that when I’m defining an extern variable for the motors, they would be called leftMotorA
, leftMotorB
, rightMotorA
, and rightMotorB
?
Yes, that is what they should be called – good catch.