View unanswered posts | View active topics It is currently Tue Apr 24, 2018 12:33 pm






Reply to topic  [ 6 posts ] 
Program Freezing Mid-Execution 
Author Message
Rookie

Joined: Thu Apr 14, 2016 3:43 pm
Posts: 4
Post Program Freezing Mid-Execution
My AI class is developing building searching robots for our final project. Out robots use EV3 brick and a mix of EV3 and NXT sensors to operate. Specifically our robot has 2 EV3 motors set up like a tank, with an EV3 ultrasonic sensor on the right side and an older NXT one on the front.

The robot starts doing a right-hand wall walk and gets pretty far along. At some point, typically when it should turn because of a wall in front of the robot, the stops completely. It's default action is to always be moving forward and not even that is happening, even sound stops playing when this occurs. This behavior does not occur every time it should react to the front sensor however, maybe happens 50% of the time. When running in debugging mode it shows variables and sensors being changed but with no change to movement. Pausing and restarting execution, or moving the robot entirely, occasionally brings it back to working order but not always.

Our code has no permanent stops/sleeps or traps in it. We have no idea what is causing this to happen. Different EV3 bricks have been tested along with controlling and compiling from different computers doesn't solve the issue. I've attached the code to this as it is moderately lengthy. Any comments or suggestions as to how this is happening or a fix would be extremely grateful. My partner and I, along with our professor haven't been able to find a solution.


Attachments:
rescue.c [8.27 KiB]
Downloaded 339 times
Thu Apr 14, 2016 6:06 pm
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post Re: Program Freezing Mid-Execution
Using multiple tasks adds a huge variable. You assume the 4 main tasks are running sequentially but they may not be. Consider making the tasks into functions and calling them in a loop to drive what you really want to occur. You would also remove the while, hog, and release from the tasks to support this.

If you want to keep the tasks, consider setting the LED to a different color for each task to show you what task is running.


Thu Apr 14, 2016 11:33 pm
Profile
Rookie

Joined: Thu Apr 14, 2016 3:43 pm
Posts: 4
Post Re: Program Freezing Mid-Execution
We can't switch to functions a the project requires using tasks. The hog and release ensure that each task is started and completed in one go without being left half done.

Did some testing via LEDs and the freezing occurs during the rightSensorTask at some point. Can't check where as the Show PC button doesn't work and only show as being in the infinite loop in main. It occurs roughly 75% of the time, and maybe 30% of the time it will recover on its own or with a push or hand wave and keep moving. The rest of the time it it sits there until stopped.


Fri Apr 15, 2016 3:01 pm
Profile
Expert

Joined: Thu Dec 01, 2011 12:07 am
Posts: 151
Post Re: Program Freezing Mid-Execution
Try changing the else portion of the rightSonar task to include braces after the else.

if (x>y)
{
//code
}
else
{
//more code
}


Fri Apr 15, 2016 3:27 pm
Profile
Rookie

Joined: Thu Apr 14, 2016 3:43 pm
Posts: 4
Post Re: Program Freezing Mid-Execution
We added an else statement to the if/else if statement in the task. All it does is set the flag to false. We can't set the global flag to true as it would cause issues with the arbitrator. The most recent code is attached to this reply.

It still freezes with the LED being red, which is set in rightSonarTask.


We put a play sound in the task and it keeps playing the sound without releasing the CPU. But this only happens some of the time, others it works perfectly.


Attachments:
rescue.c [8.42 KiB]
Downloaded 215 times
Mon Apr 18, 2016 7:28 pm
Profile
Rookie

Joined: Thu Apr 14, 2016 3:43 pm
Posts: 4
Post Re: Program Freezing Mid-Execution
We found a "solution", but it doesn't make sense unless there's an underlying problem. In the task we copied the releaseCPU statement 5 times and then it worked properly without stopping.

The only way this could "fix" the problem is if it skips the releaseCPU function or it doesn't work some of the time for some unknown reason.


Mon Apr 18, 2016 8:31 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.