1. Home
  2. Docs
  3. Niryo One documentation
  4. Tutorials
  5. Use the Niryo One Python API

Use the Niryo One Python API

This tutorial is designed for Niryo One users. If you are using Ned, please find our new documentation here.

You can control Niryo One using directly a Python API (no ROS knowledge needed).

This is great if you want to have more control over the robot, and start teaching/learning Python programming.

Basically, if you’re already using the block interface in Niryo One Studio, you have to know that all the blocks are directly calling functions from the Python API. So, you can start by teaching/learning with blocks first and then dive into the Python code.

Code examples and reference documentation

You can find some examples as well as a documentation for all available functions here on our official GitHub repository.

Remotely execute a Python script

Let’s say you have written a script on the Raspberry Pi inside the robot. It’s working nicely, but now you want to remotely execute it.

Instead of manually connecting to the robot via ssh and launching the Python script, you can start the script with just one command from your computer.

If you just use the command ssh niryo@ip_address python your_script.py, it won’t work, you’ll get an error message stating “ImportError: No module named niryo_one_python_api.niryo_one_api”.

To successfully execute the script, you’ll need to write:

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

Replace “ip_address” with the Raspberry Pi IP address, and “your_script” with the name of your script. Also, don’t forget to make the script executable (using chmod +x).

If you want to avoid typing this every time you want to execute the script, you can automate this by including it on a script or create an alias on your own .bashrc.

How can we help?