Farmware to switch camera


#1

Hi

I want to make a simple farmware that will switch between USB camera and raspberry PI camera.

I can’t find a resource which would allow me to do that, I looked through Web App API resources., FarmBotJS BotStateTree as well as celery script documentations.

None of those seem to provide option to switch camera configuration.

Is this possible to do in farmware?

thanks

martin


#2

Currently the camera selection is stored in user_env of the bot state tree. In general, farmware_tools.device.set_user_env can be easily used from within a Farmware to modify user_env values. While verifying this was possible for this particular value, I created this Farmware.


#3

wow, thanks a lot! I am just wondering - how can I possibly figure out what are the various user env values?

If I ran help(farmware_tools.device) from python console, I just got

    set_user_env(key, value)
    Send command: set_user_env.
    
    Args:
        key (str): ENV key
        value (str): ENV value

If I understood it right, farmware is executed on FB’s raspberry pi is that right? I would like to “play” with my farmware code in my IDE (pycharm) and only then upload it and try excuting it on my bot - is this possible?


#4

You can see all the values by viewing them in the bot state. One way to do this is via the JavaScript console in the browser: store.getState().bot.hardware.user_env. In the future, these values will be stored in the API and available via HTTP.


#5

For anyone who would find this useful - I just finished my first farmware :slight_smile:

This allows to switch camera between USB and RPI camera, based on the input provided to farmware / from within the sequence

thanks @Gabriel for help!


#6

Can you put that on your github linklist @Gabriel? :wink: