Problem making NXT-g wall follower program

Discussion specific to NXT-G, NXC, NBC, RobotC, Lejos, and more.
jonnxt
Posts: 14
Joined: 27 Mar 2012, 11:12

Problem making NXT-g wall follower program

Post by jonnxt »

I wanted this program to first count how many times the left nxt button has been bumped, then follow the wall with a touch sensor until the touch sensor has been pressed as many times as the left nxt button.
Wall Follower.rbt
This is the NXT-g wall follower program
(1 MiB) Downloaded 358 times
The problem (i know about is that it would not end the first loop when the enter button is bumped).
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Problem making NXT-g wall follower program

Post by hassenplug »

jonnxt,

I'll be happy to explain a bit about how to improve this program, but can you explain a bit more about what you want it to do, and what you think it's currently doing?

This program looks like it's a good start towards your final goal, but I suspect you still have changes you know you need to make. Right?

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Re: Problem making NXT-g wall follower program

Post by jojoguy14 »

So...what you're saying is:

Press the LEFT NXT BUTTON x number of times and have the robot follow the wall (using a TOUCH sensor) and follow until the TOUCH sensor has been pressed x number times.

Correct?
If so, here's my explanation:
First, the switch in the loop has to be set to use the NXT button. Right now, you have it set as a touch sensor.

That's really all I can see. Like Steve said, I'm not really sure what you're having trouble with. More info and we can help :-)

Joey "jojoguy10"
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
jonnxt
Posts: 14
Joined: 27 Mar 2012, 11:12

Re: Problem making NXT-g wall follower program

Post by jonnxt »

I think i know what the problem is, but i don´t know how to fix it. I think that the fact that the loop goes one more round does not mean that the touch sensor has been pressed one more time.

Here is a commented version of my program.
Wall Follower.rbt
This is the NXT-g program
(1020.2 KiB) Downloaded 356 times
When I run the program I choose how many times the touch sensor is going to be pressed before the program stops by touching the right nxt button. I push the enter button. It sounds a click and the robot starts turning a slight turn (if i set the number to three it runs for two seconds and stops before it reaches the wall). And if the touch sensor is pressed nothing happens.
jojoguy14
Posts: 155
Joined: 29 Sep 2010, 12:49
Contact:

Re: Problem making NXT-g wall follower program

Post by jojoguy14 »

So....what's happening is the loop is "looping" REALLY fast! SO fast, that one press in the real world could mean x number of presses (where x is the speed the loop "loops" (REALLY fast!))

What I'd try is adding a "Wait For Touch" block in front of the touch sensor switch. That way, it won't repeat until the touch sensor is pressed again.

Hope this helps!
Joey "jojoguy10"
Creator of LEGO-X TechN'XT! (http://lego-x.com http://techn-xt.blogspot.com)
Known as jojoguy10
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Problem making NXT-g wall follower program

Post by hassenplug »

jon,

A little advice for you. If you want help, you need to be able to explain your problem. Or, at least explain what you WANT to happen. To just say "this program doesn't work", doesn't really explain what you think it's doing, or what you want it to do.

I've found that a lot of times, when I explain the problem to someone, it can be helpful in my own understanding of what's going on.

Now, I'm not totally sure what you want this program to do (what's the point of pressing the button) however, I'm pretty sure it's not going to do what you want. As jojo pointed out, there's a problem with the 'nxt-button' loop. However, there's a similar problem with the driving loop.

It seems like you want this wall-following robot to bump into (touch) the wall a specific number of times. That doesn't make a lot of sense, because those bumps will not relate to an exact distance.

I'm sure we could help, if you want to explain what you want the robot to do.

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
jonnxt
Posts: 14
Joined: 27 Mar 2012, 11:12

Re: Problem making NXT-g wall follower program

Post by jonnxt »

I am ten years old. English is my second language. My mother helps me some, but she doesn't know much about programming. I got my nxt two weeks ago and I have tried to read all the help information in the program, and I have listened to a tutorial from ortop.org/nxt_tutorial but I don't have anybody to ask. Thank you for answering. We will post again tomorrow with comments in the program that tell what I want the program to do. I hope we will be able to explain it well enough. (My mother wrote this.)

jonnxt
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Problem making NXT-g wall follower program

Post by hassenplug »

jonnxt & jonnxt's mom,

This is an excellent explanation of your situation. I'm not trying to be mean, or unhelpful. I'm just trying to jon to 'talk' a little more about what he's trying to do.

I'm looking forward to a description of what you're trying to do. In the engineering world, that's officially called a design document.

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
jonnxt
Posts: 14
Joined: 27 Mar 2012, 11:12

Re: Problem making NXT-g wall follower program

Post by jonnxt »

Did you understand that the comments that aren´t like "This loop works" and "I have almost copied this switch" explain what i want the program to do.
hassenplug
Posts: 346
Joined: 27 Sep 2010, 03:05
Contact:

Re: Problem making NXT-g wall follower program

Post by hassenplug »

I was hoping to try and find out exactly what you're trying to do with the robot.

Assuming you're just trying to follow along a wall, you really don't need the first loop at all. Just use the second loop, without the counter.

Steve
---> Link to lots of MINDSTORMS stuff under my picture --->
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests