VEXcode V5 Text Version 1.0.1 Release

https://api.vexcode.cloud/v5/html/classvex_1_1drivetrain.html

Take a look at the constructor - it’s for wheel circumference, track width, and wheelbase.

4 Likes

ok i will try that

20 characters

2 Likes

Our groups are unsure what should be going into robot-config.cpp vs. main.cpp ? More specifically, it looks like the auto-generated code puts all user control features into a ‘while’ loop in robot-config, then what exactly should be placed in usercontrol() in main.cpp ? COuld someone spell out the difference, or how the two files interact with one another?

1 Like

When using the ‘Competition Template’ that you find under File > Open Examples, I don’t see any user control features in robot-config.cpp. The robot-config.cpp file only has declarations for devices and the vexcodeInit(void) function.

Was this from a converted file or did you create it from one of the Templates?

Here’s the robot-config.cpp file from the Competition Template, no modifications:

robot-config.cpp (No modification)
#include "vex.h"

using namespace vex;
using signature = vision::signature;
using code = vision::code;

// A global instance of brain used for printing to the V5 Brain screen
brain  Brain;

// VEXcode device constructors

// VEXcode generated functions

/**
 * Used to initialize code/tasks/devices added using tools in VEXcode Text.
 * 
 * This should be called at the start of your int main function.
 */
void vexcodeInit( void ) {
  // nothing to initialize
}

Here’s the main.cpp file from the Competition Template with no modifications:

main.cpp (No mdofication)
/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       VEX                                                       */
/*    Created:      Thu Sep 26 2019                                           */
/*    Description:  Competition Template                                      */
/*                                                                            */
/*----------------------------------------------------------------------------*/

// ---- START VEXCODE CONFIGURED DEVICES ----
// Robot Configuration:
// [Name]               [Type]        [Port(s)]
// ---- END VEXCODE CONFIGURED DEVICES ----

#include "vex.h"

using namespace vex;

// A global instance of competition
competition Competition;

// define your global instances of motors and other devices here

/*---------------------------------------------------------------------------*/
/*                          Pre-Autonomous Functions                         */
/*                                                                           */
/*  You may want to perform some actions before the competition starts.      */
/*  Do them in the following function.  You must return from this function   */
/*  or the autonomous and usercontrol tasks will not be started.  This       */
/*  function is only called once after the V5 has been powered on and        */
/*  not every time that the robot is disabled.                               */
/*---------------------------------------------------------------------------*/

void pre_auton(void) {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // All activities that occur before the competition starts
  // Example: clearing encoders, setting servo positions, ...
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              Autonomous Task                              */
/*                                                                           */
/*  This task is used to control your robot during the autonomous phase of   */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

void autonomous(void) {
  // ..........................................................................
  // Insert autonomous user code here.
  // ..........................................................................
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              User Control Task                            */
/*                                                                           */
/*  This task is used to control your robot during the user control phase of */
/*  a VEX Competition.                                                       */
/*                                                                           */
/*  You must modify the code to add your own robot specific commands here.   */
/*---------------------------------------------------------------------------*/

void usercontrol(void) {
  // User control code here, inside the loop
  while (1) {
    // This is the main execution loop for the user control program.
    // Each time through the loop your program should update motor + servo
    // values based on feedback from the joysticks.

    // ........................................................................
    // Insert user code here. This is where you use the joystick values to
    // update your motors, etc.
    // ........................................................................

    wait(20, msec); // Sleep the task for a short amount of time to
                    // prevent wasted resources.
  }
}

//
// Main will set up the competition functions and callbacks.
//
int main() {
  // Set up callbacks for autonomous and driver control periods.
  Competition.autonomous(autonomous);
  Competition.drivercontrol(usercontrol);

  // Run the pre-autonomous function.
  pre_auton();

  // Prevent main from exiting with an infinite loop.
  while (true) {
    wait(100, msec);
  }
}


It does add some additional device setup when you add a DriveTrain and a Controller, is that what you’re referring to?

3 Likes

Here is what I mean: I just did the following.
1.) Created new file from competition template example.
2.) Added a motor, controller, and connected the controller buttons to the motor (all through the new GUI…none of it hard-coded)

I look at my files now and I see:
In robot-config.cpp:
image

In main.cpp:
image

We would have normally placed the conditional statements, to control buttons, in main.cpp, but now it appears that those driver control statements are being auto-completed in the robot-config.cpp file.

So my questions are, a.) Why?, b.) What would I then put in user control, and c.) what file would I place additional user-created functions to use in auton or driver controlled periods?

Does that make sense?

1 Like

When you add a DriveTrain and Controller device to the Robot Configuration Wizard, VEXcode automatically generates the code for how the Controller will command the DriveTrain motors. That code is automatically added to robot-config.cpp to make it easy for students to get started.

You’ll still need to write your own code for other motors, like Lift or Claw motors, to the usercontrol() function in main.cpp. They just made it an easy entry point for teams to get the Drive Control going through the Robot Configuration wizard.

They can take control of everything by enabling ‘Expert Robot Configuration’. @tfriez explains how to do that in this post: VEXcode V5 Text 1.0.1 - You Spoke, We Listened

1 Like

How to set the drive train more than two motor? I am using 4 motors.

You enable expert configuration and use motor_group and drivetrain classes. The configuration tool only supports 2 motor drivetrain objects at present.

Now not able to draw an image from file? Brain.Screen.drawImageFromFile has disappeared

Take a look at post #4 in this thread.

Enable Expert Autocomplete for the time being. We’re working on adding more API commands to the simplified Autocomplete system as we continue to enhance VEXcode V5 Text.

2478113cac69705230a6b5b72297452c4eb59a1f

2 Likes

Ah, thank you. Unaware that there is now an expert mode.

1 Like

Anyone know when this will come out on Chrome OS? Our school provides us with Chromebooks, and it would be convenient to run VEXcode on them without the use of Crossover, which is extremely slow and glitchy.

and to clarify, drawImageFromFile is always available, it just does not show in the simplified auto-complete, but the program will still build.

1 Like

Hello, I was just wondering if there was a way to change the refresh rate of user control. Thanks

If I’m still using the beta 0.9 version, should I upgrade or would 0.9 still be perfectly fine? Just asking as readjusting the code seems like a pain for the amount of code we have.

0.9 is perfectly fine. Same compiler and build system, it has an older SDK but very few changes there in 1.0. If you do upgrade, then choose “don’t upgrade project” and the project should build without any changes needed.

2 Likes

I was wondering the same thing

I think you’ve already made a topic about this haven’t you? This is not the place to ask for coding support.

how do you enable the expert robot configuration? I cant find a way to switch it on