Vex Computer Science with Vex VR – Courses

I’m impressed with the Vex certification courses offered here:

https://certifications.vex.com/educator

I just did the two for VexVR (vr.vex.com) for Vexcode Blocks and Vexcode Python. They were both very good in the incremental introduction of both programming and a lot of the sensors.

The other thing that the courses did was introduce me to the virtual coding environments for this year’s competition. (codev5.vex.com and codeiq.vex.com). Those environments have a playground modeled on this year’s game, and a virtual robot loaded up with sensors to play that game. To use the virtual skills environments, you’ll need the “Virtual Skills Key” that you get with team registration. For me, the relevance of the current game in the virtual environment was enormous.

For the V5 and the SpinUp game, their “hero bot” details are here: https://kb.vex.com/hc/en-us/articles/360060687012-Understanding-Robot-Features-in-VRC-Virtual-Skills#robot-controls-LKwfC

That robot is a great start to using the sensors and in a very relevant playground. The robot also has all kinds of potential improvements, so it shouldn’t stifle creativity to improve.

Vex IQ also has a virtual skills playground and hero robot:

https://kb.vex.com/hc/en-us/articles/6423365106580-Understanding-Robot-Features-in-VIQC-Virtual-Skills

Vexcode: MyBlocks Simplify Your Code

When writing code, you can end up with LOTS and LOTS of lines of code (or Blocks). The sheer volume of instructions can become overwhelming, and you can lose sight of what the program is supposed to do.

MyBlocks (and functions in Python) are the solution! They enable you to encapsulate the details of how to do something, … and give a name to that group of instruction details.

Subsequently, you can use the name of the MyBlock anywhere that you would have had to replicate all those instruction details.

If you find later inspiration – and figure out how to implement those instructions differently and better, you only need to update the MyBlock. All the places that used the MyBlock by name will invoke the newly updated code without you needing to update each place that you had used it.

Here are a few screen captures to help illustrate the idea:

You need to click on the red “My Blocks” icon, and then the “Make a Block” button:

make a new MyBlock

Then, create a meaningful name that describes the behavior that you want:

Name your MyBlock

Then, add any input parameters that you want.

Creating Input parameters for your MyBlock

I had started out thinking about the new GPS sensor, but ended up creating/editing the MyBlock to support the drivetrain. See the yellow callout for the definition, and the red callouts for using the MyBlock.

Notice in the definition (yellow callout), I used the values coming in through the input parameters to populate the commands to the drivetrain. Those carried through parameter values are in red ovals.

I show this block in Autonomous, but the block is available for driving mode as well.

Add defining statements to the MyBlock and use it from the MyBlocks toolbox

Here’s a video from Vex that explains the MyBlock in detail (you may need to login): https://codev5.vex.com/static/tutorials/v5/videos/V5_Blocks_MyBlocks_V2.mp4

Vexcode: Setting Motor Velocity with Joystick Position

Use the value of the joystick position to set the motor velocity in Vexcode Blocks

A question came up recently about how do you use the controller to manage the motors (or drivetrain).

The key is that the range of the joysticks is exactly the same as the range of the motor velocity input:  -100 to +100.  When we set the motor velocity to 100 (%) – we’re setting it to full speed, and that is the same as the joystick pushed to the full extent.

Here’s a picture of that in Blocks:

Use joystick position to set velocity in Vexcode Blocks

Vexcode: Programming Tank and Arcade driving in Blocks.

Demonstrations and examples of Vexcode Blocks programming for driving, using ranging sensors for claw height and for forward distance.

We covered using the MyBlocks to simplify the code. Using those MyBlocks – we printed out sensor readings (range finder values and joystick values), we created a tank drive block and an arcade driving block.

We also proved that the “drivetrain” block does not handle turns correctly, particularly when it doesn’t have an inertial sensor configured. We made this proof by printing out the joystick values as we drove, and the turn was erractic.

The Vexcode Blocks coding will work with either the V5 or the IQ controllers – so feel free to join. If this would be your first time – email me at steve.rhoads@stemrobotics.org, and I’ll invite you to the Zoom.

Download the code from the session