Is there a way to practice/emulate without a bot?

I haven't touched Arduino bots yet, I also haven't downloaded any of the associated code.
I will soon.

Is there some sort of emulator I can use to get some practice?
Does the language (that is similar to C++) have a test feature that I can use without the bot?

I just want to write the code before I get the bots so I can hit the ground running.

I just want to write the code before I get the bots so I can hit the ground running.

You are a lot better off getting the hardware first. Once you have the hardware, write some code to make the robot move forward. Then, make it stop after a period of time. Then, make it back up.

Then, add sensors to make the robot learn about its environment.

There are some emulators, but they won't tell you a thing about the physical hardware. Suppose the robots drifts to the right all the time. The emulator won't tell you that that will happen, so, you won't have learned anything about the need to compensate for the tendency to drift.

There is but it will cost you $49.00 US.

http://www.virtualbreadboard.com/

Have not tried it myself but looks like it does it all.

Cheers

keysle:
I haven't touched Arduino bots yet, I also haven't downloaded any of the associated code.
I will soon.

Is there some sort of emulator I can use to get some practice?
Does the language (that is similar to C++) have a test feature that I can use without the bot?

I just want to write the code before I get the bots so I can hit the ground running.

This could be done, but honestly it works best if:

  1. You have a ton of coding experience
  2. You are excellent at visualizing using abstractions
  3. You have at least some electronics experience (and maybe some tools - a frequency counter and/or an oscilloscope might help)
  4. You plan on designing and building the robot from scratch, or...
  5. ...you know exactly how to interface to the robot platform you are coding for
  6. You have the patience of a saint...?

At it's simplest, you need to decide on what you want the robot to do, then abstract and "black-box" each of the functions to accomplish those tasks in your code. Let's say you know the following:

  1. The robot is a differentially steered device
  2. You can use PWM to control the motors
  3. It has a servo which pans an ultrasonic sensor
  4. The ultrasonic sensor has (or you'll write) a library for it

So - you can figure you'll need the following functions (this is all high-level abstraction here - not real code):

1 - stop()
2 - forward(speed)
3 - reverse(speed) - note: alternatively, you could make a "move(speed)" function, where speed is a positive/negative amount - to replace both these functions
4 - left(speed)
5 - right(speed) - note: same here, except call it "turn(speed)"...
6 - panSensor(angle) - moves servo with ultrasonic sensor to some angle
7 - readSensor() - pings and returns a distance value from the ultrasonic sensor

From there, you would start implementing your functions to do what you need to do - but instead of motors being attached to the pins or whatnot, you would attach LEDs (with current limiting resistors, of course!) to the pins needed for PWM. You might actually hook up a real servo; for the sensor read portion, maybe you substitute in a potentiometer and use the Arduino's map() function to scale things appropriately as necessary.

As you develop the functions, you observe the output of the LEDs, the servo, and your simulated input of the "sensor" via the potentiometer. For some things (like stop(), forward(), reverse(), left(), and right(), for instance) - you only need the LEDs on those pins, which would eventually be hooked up to an h-bridge controller. Watch the brightness level of the LEDs to "guess" if it looks correctly (alternatively, hook up the outputs to a frequency counter or oscilloscope). Once you know that the PWM is working ok, force it to 100 percent all the time, then make sure that when the "forward()" LED is on, the "reverse()" LED is off, and vice-versa. Do the same for left(), right(), and stop().

After that, move on to controlling the servo; once you know you can command the servo to a proper position, simulation of the ultrasonic sensor is next. Doing this piece won't be easy, but you can gain a good idea of how your code will work, and whether it will work "mostly" properly.

Then - when you get your hardware purchased or built, you can plug it in to your board, and start the real testing; once you know your "black-box" functions all work properly, you can continue on with commanding those functions from your actual code which controls the robot. Just take it one step at a time, making sure each piece works before moving to the next (and don't get hasty or impatient, and try to implement it all at once - that can be a recipe for disaster; resist this understandable impulse, and do things in a plodding but methodical manner; you'll get much further with less problems that way).

If you want to practice higher level coding for your bot, maybe Robocode is interesting.

It is programmed in Java (close enough to C++) and you can create the movement functions on your real bot once you have the hardware.

Before you have the hardware, it may be a tad difficult to write something. The problem is that in normal conditions, you'd code a part of the program and then test it. If you code everything without testing, chances are that you'll have errors and then you have to go through the complete code to troubleshoot. Not good.

Here's the robocode website-> http://robocode.sourceforge.net/