ROBOTC.net forums
http://www.robotc.net/forums/

Roaming Robot
http://www.robotc.net/forums/viewtopic.php?f=11&t=13466
Page 1 of 1

Author:  ErrorSuccess [ Thu Feb 25, 2016 7:27 pm ]
Post subject:  Roaming Robot

As a side job for our robotics club, we have "built" a disgrace of a robot. This bot consists of 6 wheels (2 are attached by zipties on the back of the bot) 0 wheels have two points of contact, and its just over garbage. Our code is (not worthy of this next statement) semi-decent. Here is our code:

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)
   {motor (port2)= vexRT (Ch2);//Right Wheels
         motor (port3) = vexRT (Ch2);//Right Wheels
         motor (port4)= vexRT (Ch3);//Left Wheels
         motor (port5) = vexRT (Ch3);//Left Wheels
         
     // 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.



Our goal is to have a robot that using one ultrasonic ranger finder, will roam through our school, turning and going in another direction when it finds an obstacle. We need help getting our ultrasonic range finder working. It would be appreciated if anyone would get us a program that would do this for us! Thanks.

Author:  CARBOT [ Sat Feb 27, 2016 7:49 pm ]
Post subject:  Re: Roaming Robot

You are missing two } shown below.
Maybe you did not post all of your code.
Code:
task usercontrol()
{
   // User control code here, inside the loop

   while (true)
   {
      motor (port2)= vexRT (Ch2);//Right Wheels
      motor (port3) = vexRT (Ch2);//Right Wheels
      motor (port4)= vexRT (Ch3);//Left Wheels
      motor (port5) = vexRT (Ch3);//Left Wheels
   }

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

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/