Hey all, have you ever wished you could operate your Workcell using Metric System coordinates? I wanted to share some information on how to achieve this through VEXcode, harnessing a bit of math magic and handy conversion factors to bridge the gap for us.
To start, we’ll need to understand what units of measurement we want to use. By default, the Workcell operates in inches so we’ll need to convert from that. For the sake of this post, we’ll be converting to millimeters, but feel free to use whatever system you’re most comfortable with (centimeters, micrometers, yards, miles, gumballs, etc.). We know that for every 1 inch, there are 25.4mm. This is the magic number!
While I’ll leave teaching math to the professional @Lauren_Harter, we can set up a basic equation to determine millimeters from inches, shown below. This equation will be used in VEXcode anywhere the program has inches, but we want it converted to millimeters.
Let’s see how we can do this in VEXcode! Shown below is an image of the default Manual Movement program after mastering the arm. You’ll see in the far right column, I have labeled my original coordinate units to be displayed on the V5 Brain. It’s always important to label units no matter what you are doing, so in this exercise I wanted this to be the first step.
For reference, we can see on the Brain our starting position units of our end effector (electromagnet).
Next, we’re gonna use that conversion equation from above in VEXcode. Remember that for every 1 inch, there are 25.4mm, so I created a variable called mmConversion
to house this magic number (and so that I don’t have to type it for every conversion). Using the Divide Operator block will allow us to perform this conversion from inches (default of RoboticArm1
position (x, y, or z)) to mm! Remember to update that unit label!
As we can see in the next image, our Workcell is now displaying its current position in millimeters (try the conversion out yourself from our original Workcell coordinates in inches!).
This is not all folks! Now that we have converted default inches to millimeters in VEXcode, how do we convert back to inches? Well fear not, for we can rearrange our original equation to now solve for inches!
For every 25.4 mm, there is 1 inch. How simple is that? The purpose we want to convert back to inches is now to input coordinate movement for our Arm, as it assumes you are entering inch values. Let’s see what this looks like in VEXcode;
In short, we can now convert default Workcell units into any unit of our liking. Below is a short demonstration of arm movement using Metric System coordinates.
It is imperative to remember the unit you are entering, and be consistent with it throughout your program. If you entered just 210.4
into position X of the linear move block command, the arm would try to reach way off in the distance. This also goes for the type of Operator Blocks you are using. Mistakenly put a multiplication sign instead of a divide? Your arm now resides in Timbuktu.
I hope you find this information cool, and let me know if and how you plan to use it!