Printing the Internal Temperature of a Motor

How do you find the motor temperature using VEX Pro program? It would also be helpful if it could be given in lemlib or pros. Also, how is the rounding command used in VEX Pro to create a rounding value to the nearest 1 rather than 5 or 10 for a more specific graph?

1 Like

For pros (in Celsius)

void opcontrol() {
  pros::Motor motor (1);
 
  double temp =  motor.get_temperature();


}

For VEXCode (in Celsius)


double temp = motor.temperature( temperatureUnits:: celsius):
1 Like

I don’t really know if a dedicated VEXCode round command but…

For practically anything C++ (PROS and VEXCode)

#include <iostream>
#include <cmath>
#include <stdexcept>

double roundToDecimalPlaces(double value, int decimalPlaces) {
    if (decimalPlaces < 0) {
        throw std::invalid_argument("decimalPlaces must be non-negative");
    }
    double factor = std::pow(10.0, decimalPlaces);
    return std::round(value * factor) / factor;
}

You can then do:

double pi_rounded = roundToDecimalPlaces(3.141592653589793238462643383, 1);
1 Like

Can you please post how you can do this in vscode. Thx!

@connor did. The vex extension uses the same APIs as VEXcode, and PROS is really only using VScode these days.

5 Likes

If you mean installing VEXCode Pro:

  1. Install VSCode
  2. Install VEX Extension and accept any possible toolchain downloads that may pop up
  3. An extra button will appear on the left sidebar with a “V” that if you click you can create a project using their competition template.

If you mean installing PROS from Purdue:

  1. Install VSCode
  2. Install PROS Extension and accept the toolchain downloads that will pop up
  3. An extra button will appear on the left sidebar with a purdue sigbots icon that if you click you can find a button to create a project following respective instructions

As for my code above, you can simply copy and paste the motor temperature command and replace “motor” with the motor you are using.

As I am understanding it, I get that you’re likely jumping into new hoops that you’ve never jumped into before and you may be confused about wording of things. If you need any clarification don’t hesitate to ask. :slight_smile:

2 Likes