Initialising a scanning ultrasonic sensor

Share your building instructions or ask questions about constructing your robot
Post Reply
gairlochan
Posts: 2
Joined: 27 Jan 2014, 11:33

Initialising a scanning ultrasonic sensor

Post by gairlochan »

Greetings from the Aussie tropics,

I'm new to this forum, and (almost) new to robotics, so please bear with me if I ask something obvious:

After failing to usefully complete several more 'handmade' robot builds, I've finally caved in and saved up and got myself a s/h NXT home edition (should have done it years ago). I've put together a basic robot with caterpillar tracks and a few sensors. So far so good, but I'm trying to get it to scan with an US sensor to the left and right before deciding which way to go. I know this has been done many, many times before so there must be solutions to problems which arise, but for the life of me I can't think of an elegant one for the problem I'm facing, so I hope someone can help me.

I've got it chuffing round the house, frightening the cat and mystifying the dogs and my husband, using only the two touch sensors rigged up to a sort of bumper bar across the front with the usual 'touch and reverse' loop, and I've got the US fixed on a transverse-mounted motor and ready to go, but I'm stuck on something simple: if I want it to scan say 90 deg left, then 90 deg right, then make a decision, for instance, how do I get it centred in the first place? I could centre it physically every time I turn it on and turn it loose, but that's rather defeating the purpose of autonomous movement. Any angle the Lego motor can measure is always going to be relative to where it starts measuring from, so it needs to centre itself relative to the robot's chassis before it can do any useful angle measuring.

Atm I have ( see photo, if I manage to get one uploaded ) a piece of cardboard fixed behind the US, and have the US programmed to swivel anticlockwise on startup to 'look over its left shoulder', so to speak, in 5 deg increments, until it sees something < 8 cm away (i.e. the card), and then swivel 180 deg clockwise, which brings it to approximately dead centre forwards every time.

It works well, but it's not pretty, not even by robot standards.

Any ideas for a better solution anyone?

/Users/lachlan/Desktop/P1040518.JPG
dlech27
Posts: 9
Joined: 19 Aug 2013, 23:08

Re: Initialising a scanning ultrasonic sensor

Post by dlech27 »

Your robot sounds very much like one of the first ones that I made when I got a NXT a number of years ago. I had the ultrasonic look left and right to see what was around. If something was close, it would go that direction. I just opted to make sure it started centered and then always returned to center position so that I didn't have to manually adjust it every time I started the program. Just sometimes.

Your solution is clever. For a more elegant solution though, I would suggest using a physical stop to prevent the US sensor from rotating too far to the left or right. Check out the HiTechnic RC Card model at http://www.hitechnic.com/models. The steering does exactly what you are wanting to do. In the program, you will see how they move the motor in one direction until it cannot move any more and how they detect this. It should be easy enough to adapt to your robot.

FYI, to post photos, you have to upload them to another site (any photo sharing site will do) and then you can embed them here. You can't upload photos directly to this web site.
gairlochan
Posts: 2
Joined: 27 Jan 2014, 11:33

Re: Initialising a scanning ultrasonic sensor

Post by gairlochan »

Thanks for the reply dlech.

That's a good idea about the stop; I'll see what I can knock up when I get back to it tonight. I think I can see my way clear to doing it already, just thinking about it now.

Atm I have it working more or less just with the cardboard square, and it's amazing just how attached, protective and even affectionate (sort of) you can feel towards a machine once you have it doing simple things it was 'taught' to do. It's like training a dog and watching it do new tricks. Best thing is, no need to ask the neighbours to feed it while your away on holiday!

But … I need to sleep first. I just spent the whole night debugging and rewriting about a yard and a half of code in the graphical EV3 home edition software, and it's so spread out and awkward that I'm just about ready to shift to some form of C (RobotC or NXC or something), just so I can write a few functions and make calls to them.

Lachlan
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests