Sending Python API commands to RaspberryPi via ssh from host2018-12-31T03:35:37+00:00

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • dave.knee
    Participant
    Post count: 3

    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@10.10.10.10 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@10.10.10.10 ‘source ~/catkin_ws/devel/setup.bash && export PYTHONPATH=${PYTHONPATH}:/home/niryo/catkin_ws/src/niryo_one_python_api/src/niryo_python_api && python open-grip-1.py’

    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
    Keymaster
    Post count: 134

    Great that you could make it work.

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

    Edouard Renard
    Keymaster
    Post count: 134

    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 !

    dave.knee
    Participant
    Post count: 3

    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.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.