This error is confusing

I get the error message: image on this line of code: con.Screen.setCursor(1, 1);

The code works in other spots.

Code
/*----------------------------------------------------------------------------*/
/*                                                                            */
/*    Module:       main.cpp                                                  */
/*    Author:       VEX                                                       */
/*    Created:      Thu Sep 26 2019                                           */
/*    Description:  Competition Template                                      */
/*                                                                            */
/*----------------------------------------------------------------------------*/






#include "vex.h"

using namespace vex;

// A global instance of competition
competition Competition;
int ArmMinHight = Arms.rotation(deg);

// 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 drive(int distance, int speed){
  
  Right.setVelocity(speed, percent);
  Left.setVelocity(speed, percent);

  Right.rotateFor(vex::directionType::fwd, (distance/4.125), rev, false);
  Left.rotateFor(vex::directionType::fwd, (distance/4.125), rev, true);
}

void stop(float time){
  Right.stop(coast);
  Left.stop(coast);
  vex::task::sleep(time);
}

void turn (float degrees, int speed) {

  Right.setVelocity(speed, percent);
  Left.setVelocity(speed, percent);

  Right.rotateFor(vex::directionType::fwd, (degrees*0.8), rev, false);
  Left.rotateFor(vex::directionType::rev, (degrees*0.8), rev, true);
}

void tamperUp (float Speed1, float Speed2, float distance) {
  for(int i = Speed1; i < Speed2; i++) {
  Right.setVelocity(i, percent);
  Left.setVelocity(i, percent);

  Right.rotateFor(vex::directionType::fwd, (distance/(Speed2-Speed1)), rev, false);
  Left.rotateFor(vex::directionType::rev, (distance/(Speed2-Speed1)), rev, true);
  } 
}

void autonomous(void) {
  // ..........................................................................
  //insert autton here
  // ..........................................................................
  if (RP1.pressing() == true) {
    // Red Protected autton 1
  }
  else if (BP1.pressing() == true) {
    // Blue Protected autton 1
  }
  else if (RUP1.pressing() == true) {
    // Red UnProtected autton 1
  }
  else if (BUP1.pressing() == true) {
    // Blue UnProtected autton 1
  }
  else if (RP2.pressing() == true) {
    // Red Protected autton 2
  }
  else if (BP2.pressing() == true) {
    // Blue Protected autton 2
  }
  else if (RUP2.pressing() == true) {
    // Red UnProtected autton 2
  }
  else if (BUP2.pressing() == true) {
    // Blue UnProtected autton 2
  }
  else {


    while(true){
    con.rumble(".--.-.--.-.--.");
    wait(100, msec);
    con.rumble("-..-.-..-.-..-");
    wait(100, msec);    
    }
  }
}

/*---------------------------------------------------------------------------*/
/*                                                                           */
/*                              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.


  Tilt.setVelocity(20, percent);
  Arms.setMaxTorque(100, percent);
  con.Screen.
  con.Screen.setCursor(1, 1);
  con.Screen.clearScreen();
  con.Screen.print("Arm %f", Arms.temperature());
  con.Screen.newLine();
  con.Screen.print("Tray %f", Tilt.temperature());
  con.Screen.newLine();
  con.Screen.print("AVG Intake %f", (Left_Intake.temperature()*Right_Intake.temperature()));
  
  if (con.ButtonR1.pressing()) {
    Intake.setVelocity(60, percent);
    Intake.spin(forward);
  }
  else if (con.ButtonR2.pressing()) {
    Intake.setVelocity(-60, percent);
    Intake.spin(forward);
  }
  else {
    Intake.stop(coast);
  }
  if (con.ButtonA.pressing()) {
    Tilt.spin(forward);
  }
  else if (con.ButtonB.pressing()){
    Tilt.spin(reverse);
  }
  else {
    Tilt.stop(brake);
  }

  if (abs(con.Axis2.position())>10) {
    Right.spin(forward, ((con.Axis2.position()/100)*(con.Axis2.position()/100)*(con.Axis2.position()/100))*70,percent);
  }
  else {
  Right.stop(coast);
  }
  if (abs(con.Axis3.position())>10) {
    Left.spin(forward, ((con.Axis3.position()/100)*(con.Axis3.position()/100)*(con.Axis3.position()/100))*70, percent);
  }
  else {
  Left.stop(coast);
  }
  

  if (con.ButtonL1.pressing()) {
  Arms.setVelocity(40, percent);
  Arms.spin(reverse);
  }
  else if (con.ButtonL2.pressing()){
  Arms.setVelocity(100, percent);
  Arms.spin(forward);
  }
  else {
    Arms.stop(hold);
  } 
  

    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);
  }
}

Code download: v5code-project-Autton_Testing.zip (16.3 KB)

It’s because you didn’t finish the line above it

Arms.setMaxTorque(100, percent);
con.Screen.
con.Screen.setCursor(1, 1);
con.Screen.clearScreen();

In this snippet we can see that the code is still reading the command starting on line 2 when it reads the command on line 3.

2 Likes

THANK YOU :pray: :pray: :pray:

To expand on this, the compiler ignores whitespace, and so sees lines 2 and 3 as:

con.Screen.con.Screen.setCursor(1,1);

which snippet implies that the object con.Screen (an instance of the class vex::controller::lcd) has a member object called con, which of course doesn’t exist.

Hopefully that sheds some more light on why you got the error you did:

No member named ‘con’ in 'vex::controller::lcd" (149,3)

2 Likes

THANK YOU :pray: :pray: :pray: