Help a 5th Grader

News, rumors, and other broad discussion topics.
Post Reply
lasater97
Posts: 3
Joined: 16 Mar 2012, 01:40

Help a 5th Grader

Post by lasater97 »

My son is on a robotics team. They have a table to run and they are trying to figure out how to get the NXT robot to "change" programs in the middle. Here is the situation...

They have 2 minutes to run the board. If they are approaching the time limit after "the dog bone" task, they want to skip the "veggie oil 2" task and go only for veggie oil 1. However...if they have enough time, they will go for "veggie oil 2" first, then "veggie oil 1".

All of this is my sons idea, but it has been 15+ years since I did any development (I am now a lowly project manager ;) ), and this Lego Block language is new to me...and he does not know how to write the program to do this!

Basic pseudo-code

After "Dog Bone"
If Touch Sensor 4 is pressed...go to Veggie oil 2, then veggie oil 1, then dry dock.
Else If touch sensor 1 is pressed...go to Veggie oil 1 then Dry dock

We have looked at the switch block...it does not "wait" to see which touch sensor we press.

Any tips are appreciated!
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: Help a 5th Grader

Post by mcsummation »

The "Wait" block will wait until a particular sensor is pressed.
inxt-generation
Posts: 290
Joined: 03 Oct 2011, 00:06
Location: Gallifrey
Contact:

Re: Help a 5th Grader

Post by inxt-generation »

What you want to do is a bit more complicated with NXT-G than mcsummation describes. I'm about to go to bed, so I'll have to get back to you tomorrow.
A.K.A. NeXT-Generation.
"A kingdom of heaven for RobotC now has recursion!"
lasater97
Posts: 3
Joined: 16 Mar 2012, 01:40

Re: Help a 5th Grader

Post by lasater97 »

We use wait blocks throughout the program. Basically we do task1...wait for touch4 to be pressed...then proceed to task2.

I look forward to your answer INXT. We are both learning on this...and having HUGE AMOUNTS of fun...but my best programming ever was done in basic! I could write it if it were basic...but I can't get these blocks to do what I want them to do ;)
mcsummation
Posts: 220
Joined: 23 Jan 2012, 17:07
Location: Round Rock, TX

Re: Help a 5th Grader

Post by mcsummation »

In your pseudo code, what happens if neither 1 nor 4 are pressed?

The way I read your code:
Dog bone
If 4 then vo2
in any case vo1 then dry dock
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Help a 5th Grader

Post by hassenplug »

I think I understand what you're saying. Correct me if I'm wrong:
1) Run program
2) Execute "Dog Bone"
3) If touch sensor 4 is pressed, execute Veggie Oil 2
4) Execute Veggie Oil 1, then Execute Dry Dock

Is that right? I have three suggestions for you.
1) (A) Put each mission into a "My Block". That's the NXT-G version of a subroutine. (B) Create two different programs that call the my blocks. One program has the veggie oil 2, the other does not

2) Use a variable or a wire in the program to "remember" if touch sensor 4 was pressed when the program was run

3) This may be the most interesting, cool, and fun... build a lever/device that actually holds down switch 4 when the robot is running. So, before they run the last program, set the touch sensor to the correct place (pressed or not) and then run the mission. When it gets to that spot in the program, it will check for the touch sensor, and execute as needed.

I can explain more, if you want.

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
lasater97
Posts: 3
Joined: 16 Mar 2012, 01:40

Re: Help a 5th Grader

Post by lasater97 »

mcsummation...

The program goes out and does task1, then comes back and waits until touch 4 is pressed....then it goes to dog bone...comes back and waits until touch sensor 4 is pressed again...then goes to veggie 2.

However...time constraints might not let us go to veggie 2....so we want to "skip" it by using a different touch sensor to route the program to a different subroutine.

So adjusted pseudo code would be

After "Dog Bone"...wait for input
If Touch Sensor 4 is pressed...go to Veggie oil 2, then veggie oil 1, then dry dock.
Else If touch sensor 1 is pressed...go to Veggie oil 1 then Dry dock
Else...continue to wait!

Steve...hopefully this answers your question too.

I think a variable wire may be what I need...but I don't know how to do that?!?! Is there a "wait for variable input" concept? Right now we use wait blocks to divide our program and allow the kids to re-align the robot for the next task...then push the touch4 to start the next subroutine. If we could code something like this...it might work (but again...I don't know how).

Run Dog bone...wait for input of variable (either touch1 or touch4)
If Touch4 is pressed...go to Veggie oil 2, then veggie oil 1, then dry dock.
Else If touch1 is pressed...go to Veggie oil 1 then Dry dock
Else...continue to wait!

I do like the idea of "My Blocks"...My son has been wanting to use them...I have a good tutorial on them so I think we can figure them out.

Thanks for the replies...please keep them coming! I'd like to solve this puzzle this weekend so they can do nothing but practice the table for the next two weeks!
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Help a 5th Grader

Post by hassenplug »

OK, there's a VERY simple solution. But, it requires the kids to use two fingers, instead of one.

After the dog mission, the program would still wait for touch-4. Right after the "wait for touch-4" block, check to see if touch-1 is pressed. If it is, run the veggie 2 mission. Otherwise, skip it.

So, right after the dog mission, if they DO want to run veggie 2, press (and hold) touch 1, then press touch-4.

Now, they have a choice if the "default" is to run veggie 2, or skip it. (what to do if touch-1 is NOT pressed) My suggestion (as an FLL coach) is to skip veggie2 if touch-1 is NOT pressed. That way when they run short on time, and start to panic, and don't press T1, the robot will skip the mission, like they want.

I strongly recommend they use the same robot starting position for both veggie2 & veggie1. That way when they run the wrong one (forget to T1), it still works.

Lastly, the major problem they will face is when a mission fails, and someone stops the robot program. There is no way for them to "continue". Or, if one mission "just missed" and they want to try it, again.

This is a good place to think again about using My Blocks, and come up with different ways of selecting which My Block to execute. (like another switch statement)

Good luck
Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
inxt-generation
Posts: 290
Joined: 03 Oct 2011, 00:06
Location: Gallifrey
Contact:

Re: Help a 5th Grader

Post by inxt-generation »

I think that Steve has answered your questions about the logic, but I'm a bit sick right now, and got bored. So here's the snippet of code that will wait for a button press and store whichever one was hit in a variable. You can read that variable later to find out which button was pressed. It should work, but it's untested.

Does this help?
Attachments
laseter97.rbt
untested! But should work!
(471.54 KiB) Downloaded 378 times
A.K.A. NeXT-Generation.
"A kingdom of heaven for RobotC now has recursion!"
Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests