View unanswered posts | View active topics It is currently Sat Apr 18, 2015 9:33 am






Reply to topic  [ 7 posts ] 
background autonomous in teleop 
Author Message
Rookie

Joined: Sat Jan 17, 2015 12:29 am
Posts: 5
Post background autonomous in teleop
I was trying to test a auto correction program by directly editing the value that the robot is supposed to read. However the robot does not use the auto when troop is active. Is there a way to run autonomous and troop at the same time?


Sat Jan 17, 2015 12:42 am
Profile
Rookie

Joined: Sat Jan 17, 2015 12:29 am
Posts: 5
Post Re: background autonomous in teleop
I might have figured out a solution that may say that running an autonomous on a teleop program, but I was just an idiot on getting it to work[youtube][/youtube]


Sat Jan 17, 2015 1:42 am
Profile
Rookie

Joined: Tue Jan 13, 2015 10:48 pm
Posts: 23
Post Re: background autonomous in teleop
Please be more clear about your problem. Are you trying to combine autonomous and teleop into the same file? Are you trying to transfer your correction value from your autonomous to teleop?
If you are trying to transfer the correction value, utilize .txt files saved on your NXT.
Example in Autonomous:
Code:
long correction = 0;

task main()
{
     TFileHandle hFileHandle;
     TFileIOResult nIoResult;
     short nFileSize = sizeof(long);
     //blah blah blah code goes here
     correction = 359;
     Delete("Correction.txt", nIoResult);
     OpenWrite(hFileHandle, nIoResult, "Correction.txt", nFileSize);
     WriteLong(hFileHandle, nIoResult, correction);
     Close(hFileHandle, nIoResult);
}

Then to recall it in teleop:
Code:
long correction = 0;

task main()
{
     TFileHandle hFileHandle;
     TFileIOResult nIoResult;
     short nFileSize;
     OpenRead(hFileHandle, nIoResult, "Correction.txt", nFileSize);
     if(nIoResult == ioRsltSuccess)
          ReadLong(hFileHandle, nIoResult, correction);
     Close(hFileHandle, nIoResult);
     //code here
}


Sat Jan 17, 2015 2:20 am
Profile
Rookie

Joined: Sat Jan 17, 2015 12:29 am
Posts: 5
Post Re: background autonomous in teleop
I was trying to transfer my teleport to my pre-existing autonomous to test whether or not I fixed my auto correction. The problem I had before was not that it work, but that I could figure out a way to make it turn mid program. It was made in a weird at where we had trouble making the robot turn, and my new idea didn't work because (I think) that I needed to tell the robot to move at 0% to make it turn.


Sat Jan 17, 2015 2:31 am
Profile
Rookie

Joined: Sat Jan 17, 2015 12:29 am
Posts: 5
Post Re: background autonomous in teleop
I don't have the program in front of me (it's at school) but the program I was test was similar to this:
Code:
float theta;
float turnValue;
/*insert the other decelerations and program stuff*/

task getRotation()
{rotation=0;
time1[0]=0;
while (true)
{rotation=/*the gyro sensor raw data*/;
if (time1[0]>=5)
{theta+=rotation*(time1[0]/1000)/*float*/;
time1[0]}

task autoCorrect()
{float ftheta;
while(true)
{ftheta=theta+turnValue;
//on line 7, show what ftheta is
if(abs(ftheta)>0)
{sign=abs(ftheta)/ftheta;
speed=pow((ftheta/3),2)*sign;
speed=(abs(speed)>=100)?100*sign:speed;
/*then it haves four similar to correctBl=speed; or correctBr=-speed;*/}
}
/*somewhere in between is where it adds the corrected motor speed to the drive speed*/

task autonomous()
{StartTask(getRotation);
StartTask(autocorrect);

After this I try to declare buttons for turnValue but autoCorrect only just showed ftheta. I think the problem is that I didn't realize I had to tell it to move, not that autonomous didn't work.


Sat Jan 17, 2015 3:08 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1515
Post Re: background autonomous in teleop
It sounded like you were trying to do some sort of PID controlled turn. Is that correct?


Sat Jan 17, 2015 3:17 am
Profile
Rookie

Joined: Sat Jan 17, 2015 12:29 am
Posts: 5
Post Re: background autonomous in teleop
yes, only this is the first time we implemented ftheta and the turnValue to try to do this


Sat Jan 17, 2015 3:20 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 7 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.