View unanswered posts | View active topics It is currently Tue Sep 23, 2014 12:31 am






Reply to topic  [ 3 posts ] 
Help with Teleop not working 
Author Message
Rookie

Joined: Sat Feb 20, 2010 11:30 pm
Posts: 2
Post Help with Teleop not working
here is my code that is giving me the error:
pgmcnt: 00017c
type: 2
:roll:
Here is my teleop program.
Thanks for any help you can give.

code:

#pragma config(Hubs, S1, HTMotor, HTMotor, HTMotor, none)
#pragma config(Sensor, S2, IR_seeker, sensorHiTechnicIRSeeker1200)
#pragma config(Motor, motorB, motorB, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, motorC, motorC, tmotorNormal, PIDControl, encoder)
#pragma config(Motor, mtr_S1_C1_1, intake_motor, tmotorNormal, openLoop, encoder)
#pragma config(Motor, mtr_S1_C1_2, lifter_motor, tmotorNormal, openLoop, encoder)
#pragma config(Motor, mtr_S1_C2_1, right_motor, tmotorNormal, openLoop, encoder)
#pragma config(Motor, mtr_S1_C2_2, left_motor, tmotorNormal, openLoop, reversed, encoder)
#pragma config(Motor, mtr_S1_C3_1, shooter_motor, tmotorNormal, openLoop, encoder)
#pragma config(Motor, mtr_S1_C3_2, shooter_motorII, tmotorNormal, openLoop, encoder)

// Tele-Operation Mode Code Template
//*!!Code automatically generated by 'ROBOTC' configuration wizard !!*//

/////////////////////////////////////////////////////////////////////////////////////////////////////
//
//
// This file contains a template for simplified creation of an tele-op program for an FTC
// competition.
//
// You need to customize two functions with code unique to your specific robot.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////
#include "JoystickDriver.c" //Include file to "handle" the Bluetooth messages.
/*#define _LOGGING
#define NULL 0

typedef struct {
string name;
tMotor m;
int power;
} rmotor;


/////////////////////////////////////////////////////////////////////////////////////////////////////
// static struct init is not supported
// therefore these are inited below
rmotor intake;
rmotor lifter;
rmotor shooter;
rmotor shooterII;
rmotor wheelLeft;
rmotor wheelRight;

rmotor buttons[12];

int catline = 0;

void cat(string s)
{
// log text to nxt display
// each call advances to the next line
nxtDisplayTextLine(catline, s);
catline += 1;
catline %= 10;
}

void toggleMotor(rmotor *m)
{
// toggle motor on or off
#ifdef _LOGGING
string s = "tgl mtr:";
strcat(s, m->name);
strcat(s, ".");
cat(s);
#endif
if(m->power) {
motor[m->m] = 0;
} else {
motor[m->m] = 50;
}
m->power ^= true;
}

void onMotor(rmotor *m) {
motor[m->m] = 50;
}

void offMotor(rmotor *m) {
motor[m->m] = 0;
}*/

/////////////////////////////////////////////////////////////////////////////////////////////////////


void initializeRobot()
{
return;
}

/*void initializeRobot()
{
intake.name = "intake";
intake.m = intake_motor;
intake.power = 0;
lifter.name = "lifter";
lifter.m = lifter_motor;
lifter.power = 0;
shooter.name = "shooter";
shooter.m = shooter_motor;
shooter.power = 0;
shooterII.name = "shooterII";
shooterII.m = shooter_motorII;
shooterII.power = 0;
wheelLeft.name = "wheel_left";
wheelLeft.m = left_motor;
wheelLeft.power = 0;
wheelRight.name = "wheel_right";
wheelRight.m = right_motor;
wheelRight.power = 0;
for(int i=0; i<12; i++) buttons[i]=(rmotor)0;
buttons[0] = lifter;
buttons[1] = intake;
buttons[2] = shooter;

bFloatDuringInactiveMotorPWM = true;

cat("Start.");
nxtDisplayTextLine(4, "Start.");

return;
}*/


/////////////////////////////////////////////////////////////////////////////////////////////////////
//
// Main Task
//
// The following is the main code for the tele-op robot operation. Customize as appropriate for
// your specific robot.
//
// Game controller / joystick information is sent periodically (about every 50 milliseconds) from
// the FMS (Field Management System) to the robot. Most tele-op programs will follow the following
// logic:
// 1. Loop forever repeating the following actions:
// 2. Get the latest game controller / joystick settings that have been received from the PC.
// 3. Perform appropriate actions based on the joystick + buttons settings. This is usually a
// simple action:
// * Joystick values are usually directly translated into power levels for a motor or
// position of a servo.
// * Buttons are usually used to start/stop a motor or cause a servo to move to a specific
// position.
// 4. Repeat the loop.
//
// Your program needs to continuously loop because you need to continuously respond to changes in
// the game controller settings.
//
// At the end of the tele-op period, the FMS will autonmatically abort (stop) execution of the program.
//
/////////////////////////////////////////////////////////////////////////////////////////////////////

task main()
{

initializeRobot(); //Initialize robot for tele-op mode

waitForStart();

//cat("Start.");
//nxtDisplayTextLine(4, "Start.");

while(true)
{
getJoystickSettings(joystick);
// nxtDisplayCenteredTextLine(3, "IR Val: %d", SensorValue(IRSensor));

if(joy1Btn(8))
{
motor[lifter_motor] = 50;
motor[intake_motor] = 50;
}

if(joy1Btn(3))
{
motor[shooter_motor] = 30;
motor[shooter_motorII] = 30;
}

if(joy1Btn(4))
{
aim_2();
}
else if(joy1Btn(2))
{
motor[shooter_motor] = 40;
motor[shooter_motorII] = 40;
}
else
{
motor[shooter_motor] = 0;
motor[shooter_motorII] = 0;
}

if(joy1Btn(7))
{
motor[lifter_motor] = 0;
motor[intake_motor] = 0;
}

if(joy1Btn(6))
{
motor[shooter_motor] = 0;
motor[shooter_motorII] = 0;
}
if(joy1Btn(5))
{
motor[shooter_motor] = 0;
motor[shooter_motorII] = 0;
}

/*
if(nPgmTime%10 == 1) {
if(joy1Btn(1)) toggleMotor(lifter);
if(joy1Btn(2)) toggleMotor(intake);
if(joy1Btn(3)) toggleMotor(shooter);
}
*/
// abort program
// if(joy1Btn(10)){ break; }

//panic button
if(joy1Btn(1))
{
motor[intake_motor] = 50;
motor[lifter_motor] = 50;
motor[shooter_motor] = 50;
}

if(joystick.joy1_TopHat == 2)
{
motor[intake_motor] = 100;
wait1Msec(50);
motor[intake_motor] = 0;
}
else if(joystick.joy1_TopHat == 6)
{
motor[intake_motor] = -50;
wait1Msec(50);
motor[intake_motor] = 0;
}
else if(joystick.joy1_TopHat == 0)
{
motor[shooter_motor] = 50;
wait1Msec(50);
motor[shooter_motor] = 0;
}
else if(joystick.joy1_TopHat == 4)
{
motor[shooter_motor] = -50;
wait1Msec(50);
motor[shooter_motor] = 0;
}

// control wheels
if(abs(joystick.joy1_y2) > 10){
motor[left_motor] = 5*joystick.joy1_y2;
} else {
motor[left_motor] = 0;
}

if(abs(joystick.joy1_y1) > 10){
motor[right_motor] = 5*joystick.joy1_y1;
} else {
motor[right_motor] = 0;
}
}

//cat("Aborted.");
//cat("Sleeping...");
//wait10Msec(100000);
}


Mon Feb 22, 2010 12:37 am
Profile
Rookie

Joined: Sat Feb 20, 2010 11:30 pm
Posts: 2
Post Re: Help with Teleop not working
Never mind I figured out the problem it was a hardware problem not a program problem
Thanks for looking though and maybe it helped you with your own quest.
:P


Mon Feb 22, 2010 9:06 pm
Profile
Rookie

Joined: Sat Feb 20, 2010 11:06 pm
Posts: 4
Post Re: Help with Teleop not working
hey I was looking at your file and i have a few questions what is "aim" for? Do you use the encoders for autnonmous mode? because I need help on 90 degrees turns. Do you use the IRseeker? because I know how to line it up with the beacon but do not know how to program depth.


Mon Feb 22, 2010 10:18 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.