I need help! I have made 3 toggles that function very well one for snags and a claw however these motors get too hot after 2 minutes I have so far tried to just spin to position instead of just spin but nothing works they still get hot.
It seems to be the motors are running constantly for those several minutes. I would change the code so it doesn’t try to move the motor to the same spot every loop.
I can’t remember if you can get the current position of the motor, but that can be helpful to make sure the motor doesn’t try to run when it doesn’t need to.
SpinToPosition is helpful because you can tell the code not to run if it’s already at the position.
Something like (but I haven’t tested it, or programmed any robotics for a while):
if !(motor(Claw).position == -187) {
motor(Claw).spinToPosition(-187,vex::rotationUnits::deg,100,vex::velocityUnits::pct, true);
}
Ah, well, it means opposite. So when the motor isn’t at -187; run the code. Such as !True == False.
I haven’t programmed any robotics for a while, and don’t really use C++. Well, I prefer Python, but am using another program which acts a lot like C++, so I’m not really sure what will work. I just though I’d give an example.
I assume you mean to their starting positions, that should be at 0 degrees - I think, because 0 is starting degree no matter the angle the motor starts at.
To fix that issue, what you can do is start the movement and only send that command once. You can do that by setting the waitForCompletion flag to false. This will make it so that the motor command will run independently and will not hold up the rest of the thread. You also need to make sure that it won’t keep running it. You can do this with the buttonUpPressed variable that you have already created. This will make it so that it will only send the spinToPosition command once when you press the button. Your code should look something like this.
The false just means that it will run separately from this thread. You need to do this otherwise you won’t be able to drive anything else while the claw is going.