Forums Niryo One How to… Sending Python API commands to RaspberryPi via ssh from host

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
  • dave.knee
    Post count: 7

    So I had this problem. I was going to ask for help, but I think
    I have it figured out. The problem:

    I have a simple python script; I can ssh into the Pi and execute it
    from there, but I want to send the command on the ssh command line.
    When I try to do this I get an Import Error for the
    niryo_one_python_api.niryo_one_api module.

    If I do ‘ssh niryo@ python’ and then import sys and print
    sys.path I do not see the 3 niryo_one directories that I see when
    I log in via ssh normally, just the basic python directories.
    What to I need to do to get python to find the necessary module?

    The solution:

    There are 2 lines from ~/.bashrc on the Pi that are needed for
    the remote command to work.

    source ~/catkin_ws/devel/setup.bash

    export PYTHONPATH=${PYTHONPATH}:/home/niryo/catkin_ws/src/niryo_one_python_api/src/niryo_python_api

    So this seems to work:

    $ ssh niryo@ ‘source ~/catkin_ws/devel/setup.bash && export PYTHONPATH=${PYTHONPATH}:/home/niryo/catkin_ws/src/niryo_one_python_api/src/niryo_python_api && python’

    Now I just need to put all those commands in a short bash script on the Pi
    and I think that should clean things up a bit.

    Edouard Renard
    Post count: 239

    Great that you could make it work.

    And thanks for posting the solution, that will be helpful for some Niryo One users :)

    Edouard Renard
    Post count: 239

    Just added a new doc on how to use the Python API, and remotely execute a Python script.

    Thanks again for your contribution @dave.knee !

    Post count: 7

    I’m glad I could contribute something. I have this other idea I want to
    mention. I have no one to help me train my Niryo One and I found that when I
    put it in learning mode, position the arm, and then reach for the mouse to
    click on the plus sign in the Blockly window, I tend to move the arm a little bit. I could not
    position it accurately. So I rigged up a footswitch. It’s a bit of a kludge.

    I took an Arduino-like board (I used a Texas Instruments MSP-EXP430G2
    LaunchPad)and wired up a switch with a wire long enough to sit on the floor.
    When I tap the switch with my foot, the microcontroller sends a character to
    the host computer. I read this with a python script, and from that I call a
    program named xdotool. (This is for a Linux host. I hope there is some similar
    program for windows.) Xdotool can perform mouse clicks at designated locations
    in a designated window. So the python script on the host running Niryo Studio
    clicks the plus sign and then the button for Add Block in the Add Position
    Block pop-up window. I haven’t used this a lot, but it seems to work.

    Post count: 1

    Hi…call the Python script from a webbrowser on another computer at school or at home. If needed you can put a timer function in the webpage that wil reload the page every xx seconds.
    Assuming that the Raspi at school is on a local network so it has a local IP address, from an outside network, like yours at home, the Raspi´s IP address has to be accesible e.g. through port forwarding on the school´s router.

    Post count: 7

    I’m not sure I understand this suggestion. Wouldn’t calling the script from a remote web browser require running a lightweight http server like lighttp or something on the Niryo One’s Raspberry Pi?

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.