View unanswered posts | View active topics It is currently Thu Nov 27, 2014 5:59 pm






Reply to topic  [ 1 post ] 
Auto code skipping statements 
Author Message
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Auto code skipping statements
So in the course of developing our autonomous code we have run into a few bumps and now I have yet another that makes no sense.

Here's the issue. We have an arm and in our auto sequence we want to use it (DUH :roll: ). However when I write statements to operate the arm, they will not execute, they skip over them with no evidence of executing.
The code.
Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  HTServo,  none)
#pragma config(Sensor, S2,     touchMPX,            sensorHiTechnicTouchMux)
#pragma config(Sensor, S3,     compass,             sensorI2CHiTechnicCompass)
#pragma config(Sensor, S4,     auto3,               sensorTouch)
#pragma config(Motor,  motorA,          clawMotor,     tmotorNormal, PIDControl)
#pragma config(Motor,  mtr_S1_C1_1,     leftMotor,     tmotorNormal, openLoop)
#pragma config(Motor,  mtr_S1_C1_2,     rightMotor,    tmotorNormal, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C2_1,     armMotor,      tmotorNormal, PIDControl)
#pragma config(Motor,  mtr_S1_C2_2,     motorG,        tmotorNormal, PIDControl)
#pragma config(Servo,  srvo_S1_C3_1,    armServo,             tServoNormal)
#pragma config(Servo,  srvo_S1_C3_2,    armServo2,             tServoNormal)

#include "JoystickDriver.c"

void autofun1()
{
    nxtDisplayTextLine(2, "Auto 1");
    nMotorEncoder[rightMotor] = 0;
    nxtDisplayTextLine(2, "ME = %d", nMotorEncoder[rightMotor]);
    wait1Msec(1000);
    do
    {
        motor[leftMotor] = 100;
        motor[rightMotor] = 100;
        nxtDisplayTextLine(2, "ME = %d", nMotorEncoder[rightMotor]);
    }while(nMotorEncoder[rightMotor] < 2500);
    motor[leftMotor] = 0;
    motor[rightMotor] = 0;
    wait1Msec(800);
    motor[leftMotor] = -80;
    motor[rightMotor] = 100;
    wait1Msec(730);
    nMotorEncoder[rightMotor] = 0;
    do
    {
        motor[leftMotor] = 100;
        motor[rightMotor] = 100;
    }while(nMotorEncoder[rightMotor] < 4000);
    motor[leftMotor] = 0;
    motor[rightMotor] = 0;
    wait1Msec(800);
    nMotorEncoder[armMotor] = 0;   
    nxtDisplayTextLine(2, "Cut off 1"); //I see this
    wait1Msec(200);
    motor[armMotor] = -100; //This does not appear to execute
    nxtDisplayTextLine(2, "Cut off 2"); //And this
    wait1Msec(300);
    nxtDisplayTextLine(2, "Cut off 3"); //I very briefly see this
    motor[armMotor]= 0;
    nxtDisplayTextLine(2, "Cut off 4"); //And this
    wait10Msec(10);
}

void initializeRobot()
{
    motor[leftMotor] = 0;
    motor[rightMotor] = 0;
    return;
}

task main()
{
    initializeRobot();

    waitForStart();
    autofun1();
}


That is the jist of the code the line that moves the arm does not appear to execute. Now I could be doing something wrong but I don't think I am. Your input is welcomed.

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Thu Mar 19, 2009 9:05 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

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.