Skip to main content

NAO Bridge Client

This directory contains a Python 3 client for the NAO Bridge HTTP API.

Installation

  1. Install the client package
pip install nao-bridge-client

Quick Start

from nao_bridge_client import NAOBridgeClient

# Create client instance
client = NAOBridgeClient("http://localhost:3000")

# Get robot status
status = client.get_status()
print(f"Robot connected: {status.data.robot_connected}")

# Enable stiffness and stand up
client.enable_stiffness()
client.stand()

# Make robot speak
client.say("Hello, I am a NAO robot!")

# Control LEDs
client.set_leds(leds={"eyes": "blue"})

# Sit down and disable stiffness
client.sit()
client.disable_stiffness()

# Close the client
client.close()

Using Context Manager

The client supports context manager usage for automatic cleanup:

with NAOBridgeClient("http://localhost:3000") as client:
    status = client.get_status()
    print(f"Robot connected: {status.data.robot_connected}")
    # Client automatically closed when exiting the context

Error Handling

The client provides proper error handling with custom exceptions:

from nao_bridge_client import NAOBridgeClient, NAOBridgeError

client = NAOBridgeClient("http://localhost:3000")

try:
    status = client.get_status()
    print("Success!")
except NAOBridgeError as e:
    print(f"API Error: {e.message}")
    print(f"Error Code: {e.code}")
    if e.details:
        print(f"Details: {e.details}")
except Exception as e:
    print(f"Unexpected error: {e}")

Available Methods

Status and Information

  • get_status() - Get robot and API status
  • get_operations() - List active operations
  • get_operation(operation_id) - Get status of specific operation

Robot Control

  • enable_stiffness(duration=None) - Enable robot stiffness
  • disable_stiffness() - Disable robot stiffness
  • put_in_rest() - Put robot in rest mode
  • wake_up() - Wake up robot from rest mode
  • set_autonomous_life_state(state) - Set autonomous life state

Posture Control

  • stand(speed=None, variant=None) - Move to standing position
  • sit(speed=None, variant=None) - Move to sitting position
  • crouch(speed=None) - Move to crouching position
  • lie(speed=None, position=None) - Move to lying position

Movement Control

  • move_arms_preset(position=None, duration=None, arms=None, offset=None) - Control arms
  • control_hands(left_hand=None, right_hand=None, duration=None) - Control hands
  • move_head(yaw=None, pitch=None, duration=None) - Control head positioning

Speech and LEDs

  • say(text, blocking=None, animated=None) - Make robot speak
  • set_leds(leds=None, duration=None) - Control LED colors
  • turn_off_leds() - Turn off all LEDs

Walking

  • start_walking(x=None, y=None, theta=None, speed=None) - Start walking
  • stop_walking() - Stop walking
  • walk_preset(action=None, duration=None, speed=None) - Preset walking patterns

Sensors

  • get_sonar() - Get sonar sensor readings
  • get_joint_angles(chain) - Get joint angles for chain
  • get_joint_names(chain) - Get joint names for a specified chain

Vision and Camera

  • get_camera_image_json(camera, resolution) - Get camera image as JSON with base64 data
  • get_camera_image_bytes(camera, resolution) - Get camera image as raw JPEG bytes
  • get_camera_resolutions() - Get available camera resolutions

Animations

  • execute_animation(animation, parameters=None) - Execute predefined animations
  • get_animations() - Get list of available animations
  • execute_sequence(sequence, blocking=None) - Execute movement sequences

Behaviors

  • execute_behaviour(behaviour, blocking=None) - Execute a behavior on the robot
  • get_behaviours(behaviour_type) - Get list of behaviours by type
  • set_behaviour_default(behaviour, default=True) - Set a behaviour as default

Configuration

  • set_duration(duration) - Set global movement duration

Async Usage

The client also supports async operations:

import asyncio
from nao_bridge_client import NAOBridgeClient

async def main():
    async with NAOBridgeClient("http://localhost:3000") as client:
        # Get status asynchronously
        status = await client.async_get_status()
        print(f"Robot connected: {status.data.robot_connected}")
        
        # Make robot speak asynchronously
        await client.async_say("Hello from async!")
        
        # Start walking asynchronously
        await client.async_start_walking(x=0.1, speed=0.5)
        
        # Get sensor data asynchronously
        sonar = await client.async_get_sonar()
        print(f"Sonar left: {sonar.data.left}, right: {sonar.data.right}")

# Run the async function
asyncio.run(main())

Available Async Methods

  • async_get_status() - Get robot status (async)
  • async_say(text, blocking=None, animated=None) - Make robot speak (async)
  • async_start_walking(x=None, y=None, theta=None, speed=None) - Start walking (async)
  • async_stop_walking() - Stop walking (async)
  • async_move_head(yaw=None, pitch=None, duration=None) - Move robot head (async)
  • async_get_sonar() - Get sonar readings (async)
  • async_get_joint_angles(chain) - Get joint angles for chain (async)
  • async_get_camera_image_json(camera, resolution) - Get camera image as JSON (async)

Data Models

The client uses Pydantic models for type-safe request and response handling:

Core Data Models

  • StatusData - Robot status information
  • SonarData - Sonar sensor readings
  • VisionData - Camera image metadata
  • JointAnglesData - Joint angle information

Response Models

  • BaseResponse - Base response structure
  • StatusResponse - Robot status information
  • SuccessResponse - Successful operation responses
  • SonarResponse - Sonar sensor data
  • VisionResponse - Camera image data
  • JointAnglesResponse - Joint angles data
  • AnimationsListResponse - Available animations list
  • OperationsResponse - Active operations list
  • OperationResponse - Single operation status
  • BehaviourResponse - Behavior execution response
  • BehavioursListResponse - Available behaviors list

Request Models

  • DurationRequest - Duration-based operations
  • PostureRequest - Posture change requests
  • SpeechRequest - Speech commands
  • WalkRequest - Walking commands
  • HeadPositionRequest - Head positioning
  • LEDsRequest - LED control
  • AnimationExecuteRequest - Animation execution
  • SequenceRequest - Movement sequences
  • BehaviourExecuteRequest - Behavior execution
  • ArmsPresetRequest - Arms preset positions
  • HandsRequest - Hand control
  • LieRequest - Lie posture
  • AutonomousLifeRequest - Autonomous life state

Exception Types

  • NAOBridgeError - Base exception for all NAO Bridge errors

Example Usage

See example_usage.py for comprehensive examples demonstrating:

  • Basic robot control
  • Movement and positioning
  • Speech and LED control
  • Sensor reading
  • Animation execution
  • Walking control
  • Sequence execution
  • Error handling
  • Context manager usage
  • Async operations

Running the Example

python example_usage.py

Make sure the NAO Bridge server is running on http://localhost:3000 and a NAO robot is connected before running the example.

API Documentation

The client is based on the OpenAPI/Swagger specification available at:

  • Swagger UI: http://localhost:3000/swagger
  • OpenAPI JSON: http://localhost:3000/api/v1/swagger.json

Requirements

  • Python 3.8+
  • httpx>=0.24.0
  • pydantic>=2.0.0
  • pillow>=8.0.0
  • typing-extensions>=4.0.0 (for Python < 3.11)

License

This client is part of the NAO Bridge project and follows the same license terms.

Installing from test.pypi.org

Allow main index as fallback

pip install -i https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ nao-bridge-client

Metadata

Release files for nao-bridge-client 0.1.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nao-bridge-client 0.1.5
File Size Uploaded Provenance Actions
nao_bridge_client-0.1.5.tar.gz 11.3 kB With provenance Details for nao_bridge_client-0.1.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nao-bridge-client 0.1.5
File Interpreter ABI Platform Actions
nao_bridge_client-0.1.5-py3-none-any.whl Python 3 none any Details for nao_bridge_client-0.1.5-py3-none-any.whl

Total release size: 20.6 kB

Release files / nao_bridge_client-0.1.5.tar.gz

Download URL nao_bridge_client-0.1.5.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
8565a6d4da97cb0ed062fe818bd5335a20273387a2fc949cfbe6b3f047cbd77d
BLAKE2b-256 checksum
How to use checksums
d0d223094c81af9652503c5fa25de4b4b518c70eaeeca3a3e634aa4e2b12ef84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 26, 2025.

Transparency log

Release files / nao_bridge_client-0.1.5-py3-none-any.whl

Download URL nao_bridge_client-0.1.5-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7a5d810353cc44740c746762cbe3faf01f75611c0621711711dfce9220a4cf19
BLAKE2b-256 checksum
How to use checksums
d272d1a6d88bae0dfadb9612ca9084f929474a7f2a2dc9684c49fcb0e8a4b95e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 26, 2025.

Transparency log

Security for nao-bridge-client 0.1.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for nao_bridge_client-0.1.5.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 26, 2025.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page