Run the following commands to initialise the project directory
python3 setup.py build
python3 setup.py install
a. Make sure the moduleId and moduleSecret are defined correcty in your program.
moduleID = "moduleName" # Name can be anything
moduleSecret = "qwerty" # Leave as is
You can also create a config.ini file along with the information required in the following format:
[MODULE]
ID = "moduleName"
SECRET = "qwerty"
You can find an example for this in the examples folder.
b. Make sure the KaiSDK service is running.
c. Connect to the KaiSDK Websocket.
module = WebSocketModule()
success = module.connect(moduleID, moduleSecret)
if not success:
print("Unable to authenticate with Kai SDK")
exit(1)
# Setting single capability
module.setCapabilities(module.DefaultKai, KaiCapabilities.AccelerometerData)
# Setting multiple capabilities
module.setCapabilities(module.DefaultKai, KaiCapabilities.AccelerometerData | KaiCapabilities.GyroscopeData | KaiCapabilities.PYRData)
def accelerometerEv(ev):
print(ev.accelerometer.x)
print(ev.accelerometer.y)
print(ev.accelerometer.z)
module.DefaultKai.register_event_listener(Events.AccelerometerEvent, accelerometerEv)
# Unsetting single capability
module.unsetCapabilities(module.DefaultKai, KaiCapabilities.AccelerometerData)
# Unsetting multiple capabilities
module.unsetCapabilities(module.DefaultKai, KaiCapabilities.AccelerometerData | KaiCapabilities.GyroscopeData | KaiCapabilities.PYRData)
module.close()
Run the example file using the following command
python3 Gesture.py