Jump to content

Charrua
 Share

Recommended Posts

Hi

I'm starting a mBot simulator ( http://store.makeblock.com/product/mbot-robot-kit )

mBot is an arduino based robot-car programmed in a scratch environment for educational purposes.

The thing is that in a classroom normally there are more students than robot's and a simulator should be handy in the mean time a real robot gets free for playing.

By now I implemented the communications protocol between the Scratch IDE and the Simulator. Connection is made via a Software Virtual Port Pair emulator, because, the IDE connects to the robot via a serial port, and sends commands and receives sensed data form the robot via this way.

For starting I implemented a sub set of commands: Move motors, ultrasonic sensor (for distance to walls measurement: obstacle avoidance) and Line followers (yes.. for the same purpose :).

Firsts test are ok. Here a couple of videos, first having both programs interconnected, running a simple program in scratch and seen the robot act as commanded. Program is so simple, move forward, move backward, turn right, turn left..

 

 

Second video shows the same program running on a real robot, not the mBot, just one i made compatible with it.

 

 

just another real hardware test

For the ultrasonic sensor I'm using world->Pick and for the line followers sensor I'm using a couple of cameras which renders to a texture, then i average the light seen getting the pixels of the texture and simply averaging them.

Next steps will be, testing a obstacle avoidance and line follower automatic motion program, with the simulator and real hardware. Simulator has to match as much as possible the real hardware so still much to do on metrics.

Her a couple of snap shoots:

 

Juan

 

 

 

 

mBotSim.png

scratch.png

  • Upvote 3

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

This looks pretty neat. I've attended a handful of robotics/embedded/IoT short-casual classes and agree that it's difficult to get enough hardware platforms for everyone. Usually the class spends quite a bit of time finding pieces missing and parts not working that it leaves little time to focus on learning the key concepts. A hybrid class with many simulators even with limited amount of hardware platforms might really be the way to go to remove cost and time overhead while still keeping things adaptable to the real world application.

Thanks for sharing.

Link to comment
Share on other sites

Hardware has this kind of issues, and in the other hand this is what make it lovely :) but, you got the point. It's true that most of the time software do not run at first try, but the errors are always between the keyboard and the monitor...

Hardware has the plus of some connection and or other not depending on us matter that makes we get wrong deductions about the bug we have. With a software tested in a simulator, we get a step accomplished, so if it do not work is a hardware related thing, and in the mean time, we enjoyed programming.

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

at this stage... really don't know

there are some things that are so easy of simulate, like the ir sensor, it's just a matter of map keyboard keys and send them to scratch when asked about the ir receiver, and there are other that should be more difficult to emulate.

my first goals are basic functions, some set of mazes/tracks and any easy to implement function. At first making a led display and this things sounds to me not so much useful but not so hard to implement. I use de pro version and the serial communication is made cpp side, and any lua simple thing is made in lua :)

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

The mBot software communicates with the real hardware through a serial connection, on the other side instead of the mBot hardware (which is an arduino running a sketch) is my software receiving commands and reporting sensor status as commanded. 

That´s the real mBot

mBotPicture.png.55a51dc4162895d14b155faa50c7693b.png

After some changes, the way the robot looks :) mostly, some explanations and a couple of small programs in scratch and the way them plays on the simulator. Sorry about my version of mBot, I´m obviously not an artist.

mBotExplained.png.76c206fda89079771b36d02947cc4030.png

Line follower sensors are quite a simple device, just a light source and a light sensible sensor that measures the reflected light by the floor, those sensors are calibrated to give only 2 values 1 or 0 if the floor is white or black and, normally a path in black is traced on the floor to follow...

The leadwerks way of making a line follower senor is somewhat more complicated: A spot light and a camera. The spot light is needed because the shadow of the environment and/or the mBot it self causes to see shadows as black floor... the camera is rendering to a texture, which i set to the small cubes just to watch what the camera sees, it looks good and gives real time visual feedback. I get the pixels of the texture and average the amount of light received and compares it to a threshold of 1/2 the full range.

For the ultrasonic sensor i use a pivot 4 meters ahead of the mBot body just because normally is the usable range of this kind of sensors, each frame i do a world:pick to know if there is something in front of the robot.

Following a scratch code for line following and the corresponding simulation.

LF.png.a06a6965435726cb7b890eee709b263f.png

 

And a simple object avoidance program and it´s behavior on the simulator

OA.png.89ab834fd9dda268d443605abd438138.png

 

Juan

  • Upvote 1

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

now I started to add some user interface, to select a maze and/or a texture for the floor and some mBot related parameters.

I'm using a text file to define maze walls, following some screen shots and the text file which defines the maze:

laberinto.thumb.png.329964204e260b9aeb056221780b26f4.png

 

laberinto2.thumb.png.4c9413230bc3a40bafea630f2c7b609e.png

 

laberinto1.thumb.png.8320190d03eac7a1544bf102e652d8b0.png

 

menu1.png.537da5ba6b9a1c93327a15634df56471.png

menu3.png.b36193748c4b36f6054e3ee8d81b10ff.pngmenu2.png.6e96f46a81281f9d79a96941ee118ff8.png

 

  • Upvote 2

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

  • 1 month later...

Hi

this is the first release of my mBot simulator

https://www.dropbox.com/s/yoao21cieviitun/emulador mBot.zip?dl=0

documentation is in spanish :(

https://www.dropbox.com/s/9z5wtvrfa17tt3o/guía de usuario.pdf?dl=0

in the zip file there is a folder "mBot" with the executable and a couple of subfolders

"pisos" : floors

"laberintos" : mazes

in which some .jpg for floors and text files for defining mazes can be added to the sample ones.

also there is the vcredist_x86.exe and an aplication VSPE to emulate pairs of serial ports to link the simulator with the mBot scratch sofware, and a couple of .sb2 (scratch scripts files) to test the scratch-simulator behavior.

would be good to me to know if someone can execute the exe file and with what issues if any and in which platform if possible

and if you have some experience with mBot and the simulator is of any interest, better! play with it :)

enjoy

Juan

 

 

 

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

As the documentation is in Spanish… English will come soon, but mine is very elemental :(

in the zip file will find:

  • mBot folder: the executable
  • vcredist_x86.exe if needed
  • a couple of sb2 scripts: line follower and obstacle avoidance
  • vspe: virtual serial port emulator, optional, if you need it to link scratch with the simulator
  • (another way of linking the simulator with scratch is using a couple of FTDI modules wired one with each other

Here is some basic explanation

In the mBot folder you will find a couple of sub-folders called “pisos” and “laberintos” : floors and mazes.
Any jpg image of 512x512 pixels can be added to the “pisos” folder and used as a mat on the 3D scene of the simulator, some examples are inside the folder for you to use. The mat will have 4m x 4m so one pixel is about 0.78 cm, i recommend the use of at least 4 pixels thick lines if you plan to build a track for the mBot to follow.

In the “laberitnos” folder, there are text files with a elemental draw of the walls of the mazes: 40x40 characters
each non “space” character will build a cube of 10x10x10 centimeters so a 4m x 4m maze could be built.

About the first 3 lines of the text file they must contain 3 numbers, one on each
first line: x position in the range 1 .. 40 column in the maze where mBot will start positioned
second line, y position  in the range 1 .. 40 line in the maze where mBot will start positioned
third starting forward angle of mBot, 0=North (?), heading away from us, 90 means going right, 180 approaching us, 270 going to the left. Any integer from 1 to 359 may be written.
 

If you do not link scratch with my simulator, you may select “continuar” in the first screen and use some keys to move the mBot manually and to move the camera which always look to the mBot.
Keys A/Z will increase/decrease Left motor speed by 25, Up/Down arrow does the same with the Right motor
Space will stop both motors
Left arrow will give 50 of speed to both motors and right arrow -50 (reverse) to both motors
With keypad keys you can control the camera position
5 move camera to default position 30 cm above and 40 cm behind
4,6 turn camera position clockwise/counter clockwise
8,2 rise/lower the camera
7,9 zoom in, out

to reach the first screen (3 options menu) you have to press ESCAPE key
if you select “Config” to select a floor and/or a maze, one, other or both and some other options like kind of power 6V, 3.7V, serial communication port, some optionally texts on screen like motors speed, line followers state, ultrasonic sensor reading…
On the “Escenarios” Tab, you will have a couple of list boxes with the files on the “pisos” and “laberintos” folders, the included ones and the ones you create :rolleyes:

“pantalla” tab will let you choose screen resolution, I recommend some half width resolution so if you hide the “scene” on scratch you may have scratch and mBot simulator side by side.

enjoy

Juan

  • Upvote 1

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

  • 7 months later...

so far, so long...

time to do an update :)

a video showing the bot finding the way out of a maze..

https://youtu.be/-sOQDLpiigQ

 

for this algorithm to work, the ultrasonic sensor and the linefollower sensor were re-positioned, thing that is easily done using the gui, as loading a new floor and/or maze.

another simple test of the on-board led's

the installer:

https://drive.google.com/open?id=1rD2J0IMv8yju-4eIAve84Sp2Rz0XF9Bl

 

the new look:

5b084af2ef9be_Screenshot2018-05-2510_07_30.png.815a325aa5eaf5a6059375896623663a.png

 

5b084b0085478_Screenshot2018-05-2510_07_54.thumb.png.0cc64c7bc57f4b5d754f162beed68a89.png

 

 

 

kind regards

Juan

  • Like 2

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

Omg, should I switch links..

https://drive.google.com/file/d/1rD2J0IMv8yju-4eIAve84Sp2Rz0XF9Bl/view?usp=drivesdk

Hope not this time :)

 

sorry, i did it again... 

here is the correct installer:

https://drive.google.com/open?id=1rD2J0IMv8yju-4eIAve84Sp2Rz0XF9Bl

Thanks

Edited by Charrua
link was wrong
  • Like 1

Paren el mundo!, me quiero bajar.

Link to comment
Share on other sites

  • 2 years later...
On 10/18/2017 at 8:57 PM, Charrua said:
  • scripts: line follower and obstacle avoidance
  • vspe: virtual serial

 

On 5/28/2018 at 8:22 PM, Charrua said:

Omg, should I switch links..

https://drive.google.com/file/d/1rD2J0IMv8yju-4eIAve84Sp2Rz0XF9Bl/view?usp=drivesdk

Hope not this time :)

 

sorry, i did it again... 

here is the correct installer:

https://drive.google.com/open?id=1rD2J0IMv8yju-4eIAve84Sp2Rz0XF9Bl

Thanks

This is very helpful. I am following you man. Hoping for updates very soon!

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...