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

background autonomous in teleop
http://www.robotc.net/forums/viewtopic.php?f=52&t=10282
Page 1 of 1

Author:  mattofmcompany267 [ Sat Jan 17, 2015 12:42 am ]
Post subject:  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?

Author:  mattofmcompany267 [ Sat Jan 17, 2015 1:42 am ]
Post subject:  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]

Author:  FTC_359 [ Sat Jan 17, 2015 2:20 am ]
Post subject:  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
}

Author:  mattofmcompany267 [ Sat Jan 17, 2015 2:31 am ]
Post subject:  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.

Author:  mattofmcompany267 [ Sat Jan 17, 2015 3:08 am ]
Post subject:  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.

Author:  MHTS [ Sat Jan 17, 2015 3:17 am ]
Post subject:  Re: background autonomous in teleop

It sounded like you were trying to do some sort of PID controlled turn. Is that correct?

Author:  mattofmcompany267 [ Sat Jan 17, 2015 3:20 am ]
Post subject:  Re: background autonomous in teleop

yes, only this is the first time we implemented ftheta and the turnValue to try to do this

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