The issue is when the light on a motor port is activated via the program the whole robot will freeze but after the light is done flashing works normally can anyone please help me run both at the same time with out an issue? The code is down below.

if(joy2Btn(5) == 1) // If Joy1-Button8 is pressed: {int count = 0;while(count < 10){ motor[light] = 100; // linear is run at a power level of 100. wait1Msec(250); motor[light] = 0; // linear is run at a power level of 100. wait1Msec(250);count = count + 1;}

}

}}}}}}

Thu Jan 10, 2013 4:36 pm

MHTS

Guru

Joined: Sun Nov 15, 2009 5:46 amPosts: 1523

Re: Robot freeezes while running a task during tel-op

If you want to do multiple things at the same time, you should not have any nested while loops. I have cleaned up your code. Since I don't really know your intention on some of the operations, I tried my best to guess what you want. Here is the cleaned up version.

if (joy1Btn(9) == 1) // If Joy1-Button2 is pressed: { grabberTilt = 45; // ring is Grabbed // Can use the debugger to help find these positions } else if (joy1Btn(4) == 1) // If Joy1-Button2 is pressed: { grabberTilt = 1; // ring is Grabbed // Can use the debugger to help find these positions } else if (joy1Btn(2) == 1) // If Joy1-Button2 is pressed: { grabberTilt = 217; // ring is Grabbed // Can use the debugger to help find these positions } else if (joy1Btn(3) == 1) // Open position us Joy1btn 3 // if button 3 is pressed { grabberTilt = 95; }

Notice that by indenting the code properly, it is a lot easier to read and understand. Also, I did not change any of your comments although most of them are obviously wrong.Each of the code sections (starting with the // ******** comment block) is a "task". In order for these tasks to run "concurrently", none of these "tasks" should have any while-loop or wait statement in it (i.e. None of the tasks should block the other tasks from making progress).I am not sure what the last task is trying to do. It seems that if you pressed joystick 2 button 5, then some "light" motor will be pulsing between full power and off for 250 msec each. I also don't understand the "count" variable. It loops for 10 times but then go back to the main loop and execute it again for another 10 times and so on. The only difference with my modification and your code is that my modification requires you to press and hold joystick 2 button 5 whereas yours will run the 10 loop even though the button is released. If you really meant that way, it could be changed easily by detecting the edge event of pressing button 5.

Thu Jan 10, 2013 7:04 pm

amcerbu

Novice

Joined: Sun Oct 21, 2012 10:01 pmPosts: 76

Re: Robot freeezes while running a task during tel-op

I would recommend formatting and indenting your code to make it more readable; logic errors will pop out easily if you can see the structure. Go to the edit menu in RobotC, down to "Code Formatting," and click "Format Whole File."

Whenever button 8 on controller 1 is pressed, the program enters a while loop. Each repetition of the loop, it waits half a second; if you repeat ten times, the rest of your teleop program will not respond for five seconds.

Thu Jan 10, 2013 7:08 pm

Casey890

Rookie

Joined: Mon Feb 27, 2012 5:26 pmPosts: 20

Re: Robot freeezes while running a task during tel-op

MHTS great of thanks I tried it and edited the comment text but next time I upload a tel-op it should be much easier for anyone to help me. I can't be more grateful for what you did for me thank you. To amcerbu I will have to try that during next week the portion of the code you pulled out was the issue exactly, but I didn't know why exactly. For another issue I am trying encoders for autonomous only and need help due to I got the robotc to scan all 4 encoders, but the bot still veers off by a considerable distance sometimes like either a slight over or under turn and short or long on a straight away. I tried reading some online sources and tried using an online course but, all it had that was useful was resources from carnegie mellon great as they maybe they are pretty limited in explaining if something is wrong. I am happy about using the ir seeker being able to act as a "program chooser". If I post the code on Monday can I have a quick response since the 19th is a another ftc meet I'm trying to not panic the night before all help would be great. Should I start a new topic for the forum instead?

Fri Jan 11, 2013 6:40 pm

Casey890

Rookie

Joined: Mon Feb 27, 2012 5:26 pmPosts: 20

Re: Robot freeezes while running a task during tel-op

I have the power level pretty low but if I need further explanation I will ask. I will try my best to use the pervious post to teach myself so I don't take up too much of your time. But for accuracy the tolerance is about a half inch I think. Visually looking at it is pretty small. The power level though to be more specific is at 20 with pid enabled.

Who is online

Users browsing this forum: No registered users and 2 guests

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