Help a Highschool Student Out knowledge on Vex Robotics PIC or Cortex Coding

View previous topic View next topic Go down

Help a Highschool Student Out knowledge on Vex Robotics PIC or Cortex Coding

Post by Encryption on 20/12/2012, 10:22 pm

Currently in Robotics in High school.
In the Vex Team.
Competition in February.
Competing in Sack- Attack which consists of picking up a square sack, and lifting it into a trough.

Equipment and current robot to have a more visual understanding.
http://jaronsportfoli.weebly.com/robotics-vex-team.html

My current problem:
I am the programmer in a team of three and is in need of some technical support.
I've been programming using the autonomous mode, but what I didn't know was, in the competition the autonomous part is only 20 seconds. So my problem right now, is going from autonomous to driver control. I will have a script that runs for 20 seconds, which consists of traveling forward a distance then scooping up a sack then lifting arm into the trough. After that it needs to go to driver control. Another problem is, how do I code / program so I can control the Robot / Module using the controller?

Do I use this?

Code:
task main()
{
  while(1 == 1)
  {
    //Right side of the robot is controlled by the right joystick, Y-axis
    motor[frontRightMotor] = vexRT[Ch2];
    motor[backRightMotor]  = vexRT[Ch2];
    //Left side of the robot is controlled by the left joystick, Y-axis
    motor[frontLeftMotor] = vexRT[Ch3];
    motor[backLeftMotor]  = vexRT[Ch3];
  }
}

And Insert into the "User Control" Script Area

Code:

#pragma platform(VEX)

//Competition Control and Duration Settings
#pragma competitionControl(Competition)
#pragma autonomousDuration(20)
#pragma userControlDuration(120)

#include "Vex_Competition_Includes.c"  //Main competition background code...do not modify!

/////////////////////////////////////////////////////////////////////////////////////////
//
//                          Pre-Autonomous Functions
//
// You may want to perform some actions before the competition starts. Do them in the
// following function.
//
/////////////////////////////////////////////////////////////////////////////////////////

void pre_auton()
{
  // Set bStopTasksBetweenModes to false if you want to keep user created tasks running between
  // Autonomous and Tele-Op modes. You will need to manage all user created tasks if set to false.
  bStopTasksBetweenModes = true;

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

task autonomous()
{
  // .....................................................................................
  // Insert user code here.
  // .....................................................................................

   AutonomousCodePlaceholderForTesting();  // Remove this function call once you have "real" code.
}

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

task usercontrol()
{
   // User control code here, inside the loop

   while (true)
   {
     // 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.
     // .....................................................................................

     UserControlCodePlaceholderForTesting(); // Remove this function call once you have "real" code.
   }
}

After I have this program working, I want to add 3 more motors to control using the other buttons on the controller.
avatar
Encryption
Tier 4 (500 posts)
Tier 4 (500 posts)


Back to top Go down

Re: Help a Highschool Student Out knowledge on Vex Robotics PIC or Cortex Coding

Post by bs merchants on 21/12/2012, 10:53 am

I'm guessing there would be event handlers? I've done some stuff with the LEGO Mindstorms before, similar to this. My guess would be something along the lines of:

Code:
void leftButtonPushed() {
  doSomething();
  motor[left].rotate(90);
  // more code
}
avatar
bs merchants
Forum Fanatic (1000 posts)
Forum Fanatic (1000 posts)


Back to top Go down

Re: Help a Highschool Student Out knowledge on Vex Robotics PIC or Cortex Coding

Post by Encryption on 21/12/2012, 9:12 pm

I understand the autonomous and have a code for the automous, my problem is getting the controller to work with the robot...

Let's say my motor setup is

Code:
#pragma config(Motor,  port2,          frontRight,    tmotorServoContinuousRotation, openLoop)
#pragma config(Motor,  port3,          backRight,    tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor,  port4,          frontLeft,    tmotorServoContinuousRotation, openLoop, reversed)
#pragma config(Motor,  port5,          backLeft,      tmotorServoContinuousRotation, openLoop, reversed)

What would the script be to have it working with the controller?
avatar
Encryption
Tier 4 (500 posts)
Tier 4 (500 posts)


Back to top Go down

Re: Help a Highschool Student Out knowledge on Vex Robotics PIC or Cortex Coding

Post by Encryption on 22/12/2012, 8:07 pm

Do you happen to know the link for the PIC instead of the Cortex?
avatar
Encryption
Tier 4 (500 posts)
Tier 4 (500 posts)


Back to top Go down

Re: Help a Highschool Student Out knowledge on Vex Robotics PIC or Cortex Coding

Post by bs merchants on 23/12/2012, 10:20 am

Encryption wrote:Do you happen to know the link for the PIC instead of the Cortex?

I'm not quite following the technical terms here, sorry. All I can say is there is quite a bit of stuff on google when I searched for it (other search engines are available).
avatar
bs merchants
Forum Fanatic (1000 posts)
Forum Fanatic (1000 posts)


Back to top Go down

Re: Help a Highschool Student Out knowledge on Vex Robotics PIC or Cortex Coding

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum