Overview
Preparation
On the navel robot:
# Check and if needed install Python 3.8.
# Newer versions may also work, but are currently untested.
sudo apt install python3.8
# Install virtualenv
sudo apt install virtualenv
# Create a virtualenv using Python 3.8 and activate it
virtualenv -p /usr/bin/python3.8 venv
# Install dependencies
pip install protobuf bitstring
# Install the SDK, provided by navel as whl:
pip install <navel_whl_filename>
Usage
Get started with your first Python script:
Import SDK using
import navel.navel as navel
Read this guide, in particular the navel module to get an overview of the available functions
The navel module provides classes to connect to and communicate with the robot
The data_structs module contains enumerations and data structures used in communication
For further help, see the examples section on this page for code snippets using the SDK.
Execute:
Start bodyd and allow it to finish initializing
Execute Python script
If SDK cannot connect to bodyd sockets, check the names of the bodyd generated sockets and those the Python script is connecting to and ensure they are identical.
Examples
Sending commands to motion socket:
import navel.navel as navel
import sys
import time
def main():
print("Start test")
try:
motion = navel.Motion()
except OSError as err:
print("Cannot connect to motion socket: ", err)
sys.exit()
# Send a move arm command
x = 100000 # move by 100000 milliradians
y = 0
try:
motion.arm_rotate(x,y)
except OSError as err:
print("Unable to send motion socket message: ", err)
sys.exit()
time.sleep(2)
# Move arm back to start position
try:
motion.arm_rotate(0,0)
except OSError as err:
print("Unable to send motion socket message: ", err)
sys.exit()
motion.disconnect()
if __name__ == "__main__":
main()
Sending TTS messages:
import navel.navel as navel
import sys
def main():
print("Start test")
try:
speech = navel.Speech()
except OSError as err:
print("Cannot connect to speech socket: ", err)
sys.exit()
msg = "Hallo Welt!"
try:
speech.speech_text(msg)
except OSError as err:
print("Unable to send speech socket message: ", err)
sys.exit()
speech.disconnect()
if __name__ == "__main__":
main()
Receiving messages from perception socket:
import navel.navel as navel
import sys
import time
#handler
def perc_msg_handler(msg):
count = len(msg.persons)
print("Detected faces =", count)
def main():
print("Start test")
try:
perception = navel.Perception()
except OSError as err:
print("Cannot connect to perception socket: ", err)
sys.exit()
perception.assign_callbacks(["perception_data"], [perc_msg_handler])
# Infinite loop which gives time for perception listener thread to detect bodyd messages
while(True):
time.sleep(1)
if __name__ == "__main__":
main()