Getting motor name and port number?

  1. last week

    13666A

    Jan 11 13666A

    Hi, I am trying to create a function that will print out information about a motor to the brain screen. I would like to simply call the function with a single vex::motor object and have it get the name (the one defined in robot-config.h) and which port it is plugged into. Is there any way to do this?

  2. eggplant

    Jan 11 Wisconsin 9144B

    There's no way to get the name of the motor, and the index is protected.

    However you can make a derived class of vex::motor to get the port

    class Motor : public vex::motor{
        public:
            int32_t getPort(){
                //add one becasue index is zero based
                return this->_index+1;
            }
    };
  3. Shard

    Jan 11 New York 1353C

    if youre looking for the port the motor is in, my method was unplugging it from the brain, then seeing which motor light turned off. for example, if my puncher is in port 20, and i unplug 20 and my puncher turns off, i know that port 20 is my puncher motor

  4. Enderclaw|8373H

    Jan 11 Phoenix, AZ 8373H: MHP Twisted Axles

    Or, you could check the motor screen on your brain and in the code itself.

 

or Sign Up to reply!