Skip to main content

A starting package to work with smarthome robot

Project description

Smart Home Utils

A Python utility library for controlling and managing robot navigation in a smart home environment. This library provides sensor reading capabilities, movement controls, and debugging functions for robot navigation.

Features

  • Sensor data reading and processing
  • Robot movement control functions
  • Compass and orientation management
  • Distance sensor handling
  • GPS position tracking
  • Debug output functionality
  • Object-oriented interface for U14 robot control
  • Support for both U14 and U19 robot configurations

U14Robot Class

The package provides an object-oriented interface through the U14Robot class, which encapsulates all functionality needed to control a U14 robot:

from smarthome_utils import U14Robot

# Initialize the robot with your team name
robot = U14Robot("Team Name")

# Read sensor data
robot.read_sensors()

# Move the robot
robot.move(5, 5)  # Move forward
robot.turn(90)    # Turn to 90 degrees

# Debug output
robot.debug_print()

U14Robot Methods

  • __init__(team_name): Initialize the robot with your team name
  • read_sensors(): Update all sensor readings
  • move(left, right): Control robot movement by setting wheel velocities
  • turn(deg): Rotate the robot to a specific compass degree
  • compass_correction(alpha): Ensure compass values stay within 0-360 degree range
  • debug_print(): Display detailed sensor information
  • rad_to_deg(rad): Convert radians to degrees

Legacy Functions (smarthome_utils module)

The package also includes the original procedural interface:

Sensor Reading

  • readSensorsU14(): Reads sensor data for U14 configuration
  • readSensorsU19(): Reads sensor data for U19 configuration

Movement Control

  • move(left, right): Controls robot movement by setting wheel velocities
  • turn(deg): Rotates the robot to a specific compass degree
  • compassCorrection(alpha): Ensures compass values stay within 0-360 degree range

Debug Functions

  • debugU14(): Displays detailed sensor information for U14 configuration
  • debugU19(): Displays detailed sensor information for U19 configuration

Dependencies

  • controller: Robot control interface
  • json: For data parsing

Hardware Requirements

The library is designed to work with robots equipped with:

  • 8 distance sensors (D1-D8)
  • GPS sensor
  • Inertial measurement unit
  • Two wheel motors
  • Communication devices (emitter and receiver)

Usage Examples

Object-Oriented Approach (Recommended)

from smarthome_utils import U14Robot

# Initialize the robot
robot = U14Robot("Team Name")

# Main control loop
while robot.robot.step(robot.timeStep) != -1:
    # Read sensor data
    robot.read_sensors()

    # Example: Move forward if front is clear, otherwise turn
    if robot.Front > 100:
        robot.move(5, 5)  # Move forward
    else:
        robot.turn(90)    # Turn to 90 degrees

    # Print debug information
    robot.debug_print()

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smarthome_utils-0.0.3.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smarthome_utils-0.0.3-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file smarthome_utils-0.0.3.tar.gz.

File metadata

  • Download URL: smarthome_utils-0.0.3.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for smarthome_utils-0.0.3.tar.gz
Algorithm Hash digest
SHA256 edbb468d0cd8d739317a5d5e0d8f416b03cbc6a6f615bfeb7a636bea9abbafd3
MD5 85c536e7627a6eb55a727379f778fe39
BLAKE2b-256 2b762b87dbb3226f9d3cc86c8cb5165204ea13137f7b4bb3a24896685454d262

See more details on using hashes here.

File details

Details for the file smarthome_utils-0.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for smarthome_utils-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dcc589a0e1e9b3bc03a588be1c3199921bfbbe71640f3db4bc4277d03825ea03
MD5 8ec9d0b0ab76dcf5c22466980d296749
BLAKE2b-256 1dc0902cd738196aa3844bac0b65c78cf32c7c079825ad44e3ea6e8f126edfd7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page