Jump to content

Charrua

Developers
  • Posts

    230
  • Joined

  • Last visited

Posts posted by Charrua

  1. I was using Leadwerks 4.4, recently i upgraded to latest beta and installed visual studio 2017

    I get to have working a project i'been on (mBot simulator) with some usual mistakes in the process, all of mine, over and over again... :(

    But, i started a blank project to test some gui related things... and i found that all the references to files do not have the app name in the filepath

    If i build the debug/release version it builds ok, if i then run or debug from the leadwerks editor every thing is fine, but if i run from visual studio the app crashes

    looking at the console i found that the lua scripts are not loaded because the path do not include the project's name, and when as I said, run from leadwerks etitor, the output throws the correct paths...

    guess i have some setting missing...

    any idea?

    aplication name: pruebasGui

    thats the console from visual studio:

    Error: No debugger hostname supplied in command line.
    Initializing OpenGL graphics driver...
    OpenGL version 450
    GLSL version 450
    Device: GeForce 840M/PCIe/SSE2
    Loading shader "C:/Users/notebook/Documents/Leadwerks/Projects/Shaders/Drawing/drawprimitive.shader"...
    Error: Failed to load shader "C:/Users/notebook/Documents/Leadwerks/Projects/Shaders/Drawing/drawprimitive.shader"
    Loading component "C:/Users/notebook/Documents/Leadwerks/Projects/Scripts/GUI/Panel.lua..."
    Initializing Lua...
    Warning: Lua sandboxing disabled.
    Executing file "C:/Users/notebook/Documents/Leadwerks/Projects/Scripts/Error.lua"
    Error: Failed to read file "C:/Users/notebook/Documents/Leadwerks/Projects/Scripts/Error.lua".
    Failed to load component "C:/Users/notebook/Documents/Leadwerks/Projects/Scripts/GUI/Panel.lua"
    Loading component "C:/Users/notebook/Documents/Leadwerks/Projects/Scripts/GUI/Button.lua..."
    Failed to load component "C:/Users/notebook/Documents/Leadwerks/Projects/Scripts/GUI/Button.lua"

    that's the output from leadwerks editor:

    Executing "C:\Users\notebook\Documents\Leadwerks\Projects\pruebasGui\pruebasGui.debug.exe"...
    Initializing Lua...
    Lua sandboxing enabled.
    Executing file "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Scripts/Error.lua"
    Successfully connected to debugger.
    Initializing OpenGL graphics driver...
    OpenGL version 450
    GLSL version 450
    Device: GeForce 840M/PCIe/SSE2
    Loading shader "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Shaders/Drawing/drawprimitive.shader"...
    Loading component "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Scripts/GUI/Panel.lua..."
    Executing file "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Scripts/GUI/Panel.lua"
    Loading font "C:/WINDOWS/Fonts/Arial.ttf"...
    Loading component "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Scripts/GUI/Button.lua..."
    Executing file "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Scripts/GUI/Button.lua"
    Loading shader "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Shaders/Drawing/drawtext.shader"...
    Deleting script "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Scripts/GUI/Button.lua"
    Loading component "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Scripts/GUI/Button.lua..."
    Executing file "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Scripts/GUI/Button.lua"
    Loading shader "C:/Users/notebook/Documents/Leadwerks/Projects/pruebasGui/Shaders/Drawing/drawimage.shader"...
    event queue peek
    widget action!
    butt1 pressed
    Process Complete.

     

    than's in advance

    Juan

     

  2. 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
  3. Hi Yue, nice to see you arround :), very good models, congrats!

    You may use a slider joint to move up and down the lift part, i used them somewhat when doing some tests:

    I also use blitz3d some years ago with ODE, my art skill is 0, just cubes but here you may see what I've done:

    https://sites.google.com/site/odriozolajuanignacio/juanodriozola/blitz3d

    (Utility cars is at the bottom of the page)

    And here with Leadwerks:

    5a1191fcbc2d5_conveyorbelt.png.0cea6c387d2df76222ccc2ba88f0faab.png

    and some videos showing it in action

    As a starting point you may look at "SlidingDoor.lua" in "Scripts\Objects\Doors" to see an example of a sliding joint

    If you need some help, ask or PM me, in that case you know, you can use Spanish :)

    But I do like, if possible, continue here, just in case, it would be helpful for some one else here.

    Juan

     

     

    • Like 1
  4. 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
  5. 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

     

     

     

  6. 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
  7. 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
  8. 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 :)

  9. 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.

  10. 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
  11. is there a way to find the color of the picked surface after a world::pick or similar?

    i guess that should be doing some maths with u,v coords and the relative position of the pick with respect to the triangle vertex... but i can not figure it out.. , or there is a simple and obvious way of doing it.

    thanks in advance

    Juan

  12. I started another thread (https://www.leadwerks.com/community/topic/16553-handling-widgets-created-cpp-side-and-lua-side/) because i started with a gui in lua and then has the need to create and handle some widgets in cpp code, i had some troubles and guessed that the problem was in a bad parameter usage/passage.

    So I decided to make it work only in cpp code and i found that the test (event->source == butt1) never gets true, the same problem that i have when calling a method from lua passing the event peeked from the queue.

    Relevant parts of my code:

    /* globals */
    GUI* gui;
    Widget* butt1;

     

    /* in App::Start */
    gui = Leadwerks::GUI::Create(context);
    butt1->Button("Quit",30,30,100,50,gui->GetBase());
    /* function to process events */
    bool App::ProcessEvent(Event* event){
    
        if (event->id == Event::WidgetAction) {
            System::Print("widget action!");
            if (event->source == butt1) {
                System::Print("butt1 pressed");
                butt1->Hide();
                return false;   //quit
            }
        }
        return true;
    }


     

    inside App::Loop
    
        while (EventQueue::Peek()){
            System::Print("event queue peek");
            Event event = EventQueue::Wait();
            if (ProcessEvent(&event)==false) return false;
        }

    what am I doing wrong?

    thanks in advance

    Juan

  13. Hi

    I have some widgets created and handled on lua scripts

    Now i need to create some widgets cpp side, and, as far as i know, there is one eventQueue so only one loop to peek events should exists, isn't it?

    I do that loop, on a lua scrpt and i have exposed a class with tolua with only one method:

    void ProcessEvent(Event event)

    and when a piked event.source do not match any widget created by lua scripts then, the ProcessEvent in lua calls it's counterpart ProcessEvent method and pass the event to it.

    When i push a button created by cpp, then the ProcessEvent method is invoked (that's ok and nice!) but the test

    if (event.source == myCppCreatedButton) never gets true

    i can and do use, event.id for example, so not all is wrong..

    i guess that perhaps i'm missing something obvious, casting perhaps?

    any idea?

    by the way, any idea of doing the same thing better? or I did take a complicated solution being one easier?

    thanks in advance

    Juan

  14. thank's for your time and generator

    yesterday i wrote a very simple class to start doing some tests and found that there is a generator for windows and as i have to write th .pkg by hand (for a simple test class is not so much work) i just be curios about the same tool for linux.

    if I get it to work, in case i use it i'll will update here or on your thread, but, you know, if i already make it work by hand... and my class will not be so much complicated... chances are that i let it as is for a while :)

     

    thank's again

     

    Juan

×
×
  • Create New...