When a claw is closed?

We’ll be using a modified claw to grab a mobile goal by the vertical stem. What’s the most efficient way (in block-based Vexcode) to stop the claw motor as soon as it’s got a good grip on the stem? Do we check if

  • the motor is still spinning
  • the motor is done
  • its velocity
  • its current?

You could make it so that you read for a rapid acceleration change.

Acceleration = (Velocity - VelocityPrevious)/delta_time

If the acceleration unnaturally accelerates down (as in hits a mechanical stop) and the speed goes to almost zero then that’s when you know that the claw is closed.

1 Like

You could also use current. I read in a textbook that a stationary motor produces no back emf and so current draw is high. Maybe you could use this to measure current.


Generally checking if the motor is stalled (velocity is 0) is a good way to check for something like this.


That is correct but the arm must first be in motion before it checks, otherwise the system will check before the motor starts moving.


motor.torque also exists. One of my teams used it for a cube claw in the tower takeover season to do essentially what you are looking to do.

1 Like

What we ended up doing is let the motor spin for 0.5s, keep spinning and at the same time wait until the velocity drops to < 10%, and then stop the motor (hold). That sort of works, but what happens is the plastic pipe tends to slide out of the claw (even though the claw is padded on the inside with, I think, tire tracks?). I’m wondering if it’s okay to keep applying a small velocity (<5%?) once the claw has closed? Or will that put an excessive strain on the motor?

Is there a way to capture data to a file? We’d like to log the velocities, torque, amps, etc, so that we can choose an appropriate threshold value.

int nWritten = Brain.SDcard.savefile( “test.h”, (uint8_t *)arrayofvalues, sizeof(arrayofvalues) );

You have to store all of your values in a 2D array or a vector, so that way you can have everything in one file.
Apparently you can only save data types of uint8_t (unless I’m wrong, I hope I’m wrong because it’s causing me problems), so anything that involves anything above 256 or lower than 0 you’re gonna have to do some math to fit it in there. Plus you can’t use floats, so you gotta figure that out.

1 Like

Thanks, can you do write to/read from files in V5 Blocks? Even Lego EV3 supports file I/O.

I don’t believe you can. If you’re trying to do these things you should honestly switch to vexcode pro. But if you insist, you can just print the variable values to the screen (preferably the computer, if they have an std::cout function). Then you can write it down on an excel spreadsheet. This is ofc if you’re trying to save the averages over time. if you only need it in a match, like being the decider for an if statement, just use variables, no need to save the information. You can combine the two btw


I guess you still don’t understand this.
Fat32 files store their data as a sequence of bytes, what the bytes mean is determined by the software that reads the bytes and interprets them.