• 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


    1 Attachment

  • Wed 2020.03.04

    I have no experience with SmartiBot nor dpad.

    Hello Steve @user104966 and thank you for posting your code block.

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

    It would be nice to understand what details were attempted to be conveyed. Please post link so that we may follow with that understanding.

    'I have downloaded modified wall avoidance software from the web'

    Again, please post the referenced web link.

    'Button 1 on the app when pressed calls load()'
    'it does not run automatically'

    Looking over the code module I find neither a load() function or an onInit() function.

    'At this point because the RAM has been cleared'

    Am I to conclude that reset() was entered into the Left Hand console side of the WebIDE just prior to this statement?

    'Have I misunderstood what reset() does?'

    http://www.espruino.com/Reference#l__glo­bal_reset

    It might be, as it isn't entirely clear what is to be attempted at this point. If the intent is to wipe out memory then reset(1) is what you are after. If the intent is to re-initialize the position variables, then a separate function might be one solution to perform that task. From the two 'When I press and release' text instructions, the motors start and then stop. Function stopWallAvoid() stops updating and halts the motors. Code should remain in memory. dump() to reveal. What is expected at that point?

    http://www.espruino.com/Reference#t_l__g­lobal_dump


    'when released calls reset()'

    There isn't a reference to the reset() function and either button functions.

    Is it possible that ALL the code is not in the attached file?

  • I could be wrong here, but I think that when the app connects it runs some magic command on the Smartibot (it may just end up being smarti = require("Smartibot"); or something like that).

    You'd have to ask Smartibot what the actual command is (or maybe disconnect the app, open the web IDE, and try using up-arrow to look back in the command history).

    Either way if you ran reset() it'd blow away the result of running that command, which may be why the dpad no longer works?

    I guess looking at what you're doing, just calling stopWallAvoid() and not reset() might be enough? Although possibly calling load() to run your code might have removed the code the app uploaded too...

  • 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,

  • As I'd mentioned above, you don't want to call reset:

    I think that when the app connects it runs some magic command on the Smartibot (it may just end up being smarti = require("Smartibot"); or something like that).

    Either way if you ran reset() it'd blow away the result of running that command, which may be why the dpad no longer works?

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Smartibot - function reset() - should it restore josytick control from APP

Posted by Avatar for user104966 @user104966

Actions