Avatar for user104966


Member since Nov 2019 • Last active Mar 2020
  • 2 conversations

Most recent activity

  • in Other Boards
    Avatar for user104966

    ok, thanks for comment, I will expand.

    All of the code loaded on the smartibot is in the attachment.

    The smartibot comes with an android or Iphone App which has some pre-defined panels.

    As a default, when the smartibot is connected to the App it is possible to control the motors using a D-pad .
    It is possible to create your own panel, I have added two buttons, I can see the confusion because I referenced them as Button 1 and 2.

    Lets call them Auto and Manual.

    On the App it is possible to execute a command when a button is pressed and released.

    So the code attached on the original post has been downloaded to flash but it does not automatically run when the smartibot is powered up.

    I am trying to use the smartibot as follows:

    switch on the smartibot and connect to the app.
    Control it using the D-PAD
    Press the auto button which sends text to the smartibot "load()", which then loads the program from flash into RAM.
    Release the auto button and it sends "wallAvoid()" to the smartibot, which now executes the function "wallAvoid()". The smartibot then moves automatically according to the measured distance.

    Press the manual button on the app and it sends text "stopWallAvoid()", the smartibot now stops moving.
    Release the manual button on the app and it sends text "reset()".
    At this point I wanted to take control from the D-PAD again, this does not happen.
    But I can toggle between auto and manual mode.

    So based on the definition of reset, extract below.
    "If reset() is called with no arguments, it will reset the board's state in RAM but will not reset the state in flash. When next powered on (or when load() is called) the board will load the previously saved code.
    Calling reset(true) will cause all saved code in flash memory to be cleared as well."

    I expected the D-PAD to work.

    Am I correct in that assumption?

    I hope this explains what I was trying to do, there is no need to look at the reddit group, that is where it was suggested to call load() and wallAvoid from a button press. Based on that suggestion which worked I added the code for stopWallAvoid and reset.

    As I am about to hit post I have realised a work around, add my own functions for forwards, backwards , left , right and call them when the D-pad on the phone is used.

    Thanks for the response, I will add more detail next time and post links,

  • in Other Boards
    Avatar for user104966

    Background, there are alot more details on the Redditt sub-group, not sure of the best pace to post this.

    So, I have downloaded modified wall avoidance software from the web, it does not run automatically.

    Taking advice I have modified a panel on the app so that :

    Button 1 on the app when pressed calls load()

                                          when released calls wallAvoidance()

    Button 2 on the app when pressed calls a function to stop wallAvoidance and stop both motors

                                          when released calls reset()

    So on power up I connect from the app and I can control the smartibot using the dpad.
    When I press and release Button 1 on the app it starts wall avoidance.
    When I press and release Button 2 on the app, wall avoidance terminates and the motors stop.

    At this point because the RAM has been cleared I expected to be able to take control from the dpad, this does not happen.
    I can however toggle between wall avoidance and not be using buttons 1 and 2 on the app.

    Is there some other function I should use?
    Have I misunderstood what reset() does?
    Or have I found a feature in the firmware?

    I would like to sort it because it means I can demonstrate the robot in schools and exhibitions by switching between the two modes from my phone.

    Steve Gale

    Here is the code for the smartibot itself

  • in Other Boards
    Avatar for user104966

    I just tried BTN1 and BTN2 , that has sorted that problem. I will see if I can change the documentation here

    That just leaves the "block code" issue.

    Thanks for replies, I will have to look at java script so I can better understand the documentation you pointed me at.

  • in Other Boards
    Avatar for user104966

    I have updated my Smartibot to version 2.04 and last night started to work through some of the examples in the documentation.

    First one I tried was button presses

    setWatch(function(e) {
      if (e.state) print("Button pressed");
      else print("Button released");
    }, BTN, {repeat:true});

    When I download this "Button pressed" is printed only when Button A on the smartibot is pressed, nothing when released and nothing for Button B.

    So looking at some examples I added

    var smarti = require("Smartibot");

    to the top and this made no difference.

    I then tried the "block" coding and used the set watch construct.
    First block was BTN1 rising and inside I change the colours of the leds. This was then duplicated for BTN1 falling, then I duplicated both for BTN2.

    Downloaded and it worked.
    Tried to change the code but somehow deleted everything, when I started again BTN2 was not available.

    This morning I started to create the post, initially the same problem , no BTN2.
    Tried refreshing the browser still did not work.
    So I downloaded the raw javascript to prove that did not detect BTNB , it did not.

    Then went back to "block" mode and BTN2 is available.

    I am using Chrome on a mac and I am new to java script.

    My questions are:

    1. what is wrong with the raw javascript code I downloaded ?
    2. have I found a bug with the block code ?

    PS should I have tagged this post or posted elsewhere so it is obvious it is a smartibot issue I am having.