CO538 Anonymous Questions and Answers |
This page lists the various questions and answers. To submit a question, use the anonymous questions page. You may find the keyword index and/or top-level index useful for locating past questions and answers.
We have taken the liberty of making some minor typographical corrections to some of the questions as originally put. Although most of the questions here will have been submitted anonymously, this page also serves to answer some questions of general interest to those on the course.
When asking questions, please do not simply paste in your code and ask what is wrong with it, as these types of question are hard to answer in a public forum (resulting in either no answer, or an answer which will only be of use to the person asking the question). In many cases, a question about code can be formulated in general terms. For example, if you have an `IF' block that results in an `incorrect indentation' error, you might ask, ``what is the correct syntax for an occam `if' statement ?''. Questions of this form are easier to answer, and are meaningful to all.
Questions that are not suitable for these public pages (i.e. those that contain assignment-specific code), should be mailed to your seminar-leader.
Submission reference: IN1961
I'm stuck on Task 3 for the last few hours.. dont't know where the problem is, but the colors from the camera and the color provided by the user don't seem to match.. It'd be great if you could tell me where I'm going wrong.. Here's the full code:
... code deleted
Your find.blobs process has two ALTs, each with only one guarded process. They are the same as no ALTs – just do their input guard and response code in sequence!
The second ALT takes input from the camera and it's within a search loop. If no blob with the target colour appears, the camera eventually exhausts the blobs it can see and sends nothing ... and your find.blobs gets stuck. Fix this by setting a timeout on waiting for the camera – see the end of the answer to Question 52 (2010).
Keywords: mars
Submission reference: IN1958
Hi, Just wondering if there is an occam-pi alternative to the Java/C continue inside a while loop? For the mars assessment, I have sent an operator response and no longer want to continue with the rest of the code in that iteration of the loop. Thanks in advance :-)
Nope – continue statements are evil and lead to tears. Set a BOOL flag when you send to the operator and use an IF construct to skip the rest of the code. That's explicit and we can see what's happening.
Keywords: continue , break , loops , mars
Submission reference: IN1959
Having a bit of a problem with the mars assignment. When I read in the values from hazard, I get a runtime error (STOP error):
SEQ i = 0 FOR 4 hazard[i] ? h[i] <--- this line
Any help would be greatly appreciated.
The hazard array we plug into robot.control indeed has 4 channels. Are you sure your array h has four elements? If it has less, the runtime error you describe must happen.
Referrers: Question 31 (2012)
Submission reference: IN1960
A question for the mars assignment. I've just noticed that when I want the robot to move 1 mm it will move 10, 11 mm will move 20 mm ... and so on. Is this correct or am I fluffing something up somewhere?
Mine does the same! It's OK.
Given the feedback from the motors comes in tens, you could anticipate – e.g. if asked to move x mm, tell it to move (x - 5) or zero, whichever is larger. Then, the robot will move to the nearest 10 mm of the distance asked. But you weren't told the feedback is like this and it may change ... i.e. don't worry on this point! :)
Keywords: mars
Submission reference: IN1957
I'm having the same problem as Question 48 (2010), );. The colour returned for blue by the camera is #0064220A while the robot is looking for #0000FF. Is there a way to implement the colour in hex instead an INT, coz that's where I think the problem is ...??
Sorry – I don't understand "The colour returned for blue by the camera"? I guess you mean the colours of the blobs returned by the camera are numbers like #0064220A (while the robot is looking for blue, although that's not relevant)?
Your question asks how to "implement the colour in hex" ... but numbers like #0064220A and #0000FF are in hex! Sorry, don't understand ... ?
Keywords: mars
Submission reference: IN1962
A question for task 3 of the mars assignment. I want a full "turn 360" to occur when it can't find a blob, but I noticed that when I use "camera ? b" to check for blobs (b being the variable for blob) - it turns about 60 degree more than 360 (and displays that it turned a total of 380ish) ...
I'm assuming that this is because using "camera ? b" will delay the other processes somewhat ...
Will I lose marks for my current implementation?
Probably!
Using "camera ? b" won't delay anything if it's a guard in an ALT with other guards (e.g. motor feedback or a timeout) that can be taken ... or if it's done in a process running in parallel with other actions.
Hope this has helped ... it is 5:41am (and we've a lecture at 10)!
Keywords: mars
Submission reference: IN1964
Hello! Can you answer a question for me? I am working on part 3 of mars!! It says: "At the end of the search you should return the new heading of the robot relative to the heading you started at (as you will have rotated)." What does that mean?
Say the robot is facing NORTH and it rotates 90 degrees clockwise and then sees the blob which is 95 degrees from NORTH do I return, 90 or 95??
Thanks, see you at 10!
The sentence quoted only talks about the robot – not the blob. So, if the robot has rotated x degrees, it should return x.
It must also return whether it found the blob and, if so, the blob data. This data includes information about the bearing of the blob relative to the orientation of the robot when it saw the blob ... which you need to ensure is the orientation of the robot when making its report ... i.e. the blob must be observed (or re-observed) when the robot is at rest.
The short answer to your question is: 90.
Keywords: mars
Submission reference: IN1963
I'm really sorry this is not a question!
I wanted to say thanks a lot for the answers you've given me. I submitted a first question and thought: "well no-one is going to reply on a sunday so I will have to wait till monday" – but you still replied and the answer really helped me! Then I submitted another (I think around 4-5am) and thought: "well no-one is going to be awake at this time so I might as well go to sleep and check the answer tomorrow" – but I stayed up anyway and then found a very useful answer to my question!
I'm actually really surprised - I hope you are getting paid overtime for this! Thanks a lot!
:)
... but they don't pay overtime!
Keywords: mars
Submission reference: IN2030
Hiya, I have been going through the 2010 paper and have come stuck on question 3(a) where I have to write a function to count the TRUE elements in an array of bools, but the size of the bool array is not mentioned. How would I go about this?
Also, I noticed that in the answers page you have said that mobiles are not examinable, but there was a question on barriers. Are mobiles examinable this year??
Thanks :D
The prefix SIZE operator returns the size of an array (of channels or any data-type). See slide 113 from the choice set of slides, 93 from replicators, 71 from shared-etc and Question 52 (2003) and Question 58 (2000) from the anonymous Q&As (which I found by searching for "SIZE" under the keyword-index page for "arrays" – I've now added a page for the keyword "size"). There's also an example in the very last code box of the occam reference/checklist (which is linked from the Practical Resources box on the Co538 Moodle page).
Note that this last example (from the reference/checklist) has very similar form to the answer required for the exam question part you raised. The answer to that part is trivial:
INT FUNCTION count.true (VAL []BOOL array) INT count: VALOF SEQ -- function body count := 0 SEQ i = 0 FOR SIZE array IF array[i] count := count + 1 TRUE SKIP RESULT count :
(where you only had to write the 8 lines starting from the line commented "function body").
I can't find anything in the answers page for this year that says there was a question on barriers? Please mail me (phw@kent.ac.uk) where you have seen this.
The concept of barrier synchronisation has been explained in previous exam questions (see Question 62 (2008)), with follow-on parts asking for bits of implementation and/or use. Such questions – introducing new concepts – are always possible. However, the formal occam-pi language mechanism for BARRIERs, along with that for MOBILEs, is presented in the slides titled mobiles. The material in the mobiles slides is for advanced study and is not examinable in Co538. The material in all the other slide sets (including shared-etc) is examinable.
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License. |