My First Robot

While I wait for the geared motors to arrive in my mail, I have continued the work on the software. 

Since it is my first robot with behavior a bit more complex than the Gwünderer ( https://www.robotshop.com/letsmakerobots/node/30544 ) it is programmed a bit more Clean Code style.

The behavior of this robot is implemented with the state-pattern in combination with the strategy-pattern. The state is determined by the sensor and contains the relevant motor configuration to apply. That might be "Don't Panic! Go Ahead!" or "Turn Left (since there is most space)" or "Backwards now!". The strategy determines how this is fulfilled. So is a "Go Ahead" a simple motor forward while a "Backwards" is a motor backward followed by a u-turn.

You find the source code here: https://github.com/mnemonia/robotix/tree/master/MyFirstRobot

 

 

Navigate around via ultrasound

  • Control method: Full autonomous
  • CPU: arduino uno
  • Power source: one 9 volt for logic and batter pack for motor
  • Programming language: C
  • Sensors / input devices: HC-SR04 ultrasonic sensor
  • Target environment: indoor

This is a companion discussion topic for the original entry at https://community.robotshop.com/robots/show/my-first-robot-23

Oooh! Nice Bot! I really

Oooh! Nice Bot! I really liked the Gwunderer… But this is cool as well! Where did you get the chassis? And what is that shield? And this bot is very neat! :smiley:

Thank you!

The chassis is from here: http://shop.boxtec.ch/product_info.php/cPath/59_61/products_id/40536

And the shield is this one: http://www.adafruit.com/products/81

 

The shield

I believe thats the ever-popular Adafruit Motor Shield Which you can use to control 4 DC motors or 2 Stepper motors. 

A neat platform

I like the platform, I was looking at this the other day. I must have a tinker with arduinos too…

HiTested your Code " my

Hi

Tested your Code " my Second Robot"

But I get some erros while compiling

I using also your Ultrasonic library

timing

convert

int getDistance(){
  long microsec = radarUltrasonic.timing();
  int distance = radarUltrasonic.convert(microsec, Ultrasonic::CM);
  return distance;

Thanx for your help

MABA

You use a different ultrasonic library

It looks as if you are using a different ultrasonic library. The code from this robot uses this ultrasonic library.

Actually you can use whatever ultrasonic library you have. Change the following code to match the specification:

212 int getDistance(){
213 long microsec = radarUltrasonic.timing();
214 int distance = radarUltrasonic.convert(microsec, Ultrasonic::CM);
215 return distance;
216 }

…and welcome to LMR!

**thanks a lot !!! **

thanks a lot !!!

 

 

Link down

NilsB your link https://github.com/mnemonia/robotix/tree/master/MyFirstRobot is down.

Maybe reupload it and tell me if you did it.

My code is your code.

…ah true. Thank you. This is the actual link: https://github.com/mnemonia/robotix/tree/master/Robots/MyFirstRobot

…and yes. Code is from me. Implementation with the notion of state. A state is forwardState where both motors have the FWD setting and the sensor is adjusted accordingly. It stays in this state until some object in the way gets detected. Depending on the distance from the robot to the obstacle an other state gets activated. If the obstacle is very close then the robot changes to backwardUturnState and turns around.