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 nameread_sensors(): Update all sensor readingsmove(left, right): Control robot movement by setting wheel velocitiesturn(deg): Rotate the robot to a specific compass degreecompass_correction(alpha): Ensure compass values stay within 0-360 degree rangedebug_print(): Display detailed sensor informationrad_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 configurationreadSensorsU19(): Reads sensor data for U19 configuration
Movement Control
move(left, right): Controls robot movement by setting wheel velocitiesturn(deg): Rotates the robot to a specific compass degreecompassCorrection(alpha): Ensures compass values stay within 0-360 degree range
Debug Functions
debugU14(): Displays detailed sensor information for U14 configurationdebugU19(): Displays detailed sensor information for U19 configuration
Dependencies
controller: Robot control interfacejson: 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file smarthome_utils-0.0.4.tar.gz.
File metadata
- Download URL: smarthome_utils-0.0.4.tar.gz
- Upload date:
- Size: 18.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b28676d5cb5bb1b40ff40965f4e51d125d7d69ed7f4910ddfa535856aca05d49
|
|
| MD5 |
cf75f3570095e0219c0bc2a6d9d13f1b
|
|
| BLAKE2b-256 |
eaaf0f69e1b611921f0da0e790fd5c6073585e6a6693279a7fdd9d4b9c38fe0d
|
File details
Details for the file smarthome_utils-0.0.4-py3-none-any.whl.
File metadata
- Download URL: smarthome_utils-0.0.4-py3-none-any.whl
- Upload date:
- Size: 22.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
55932ec27825f5966a9ccbb7260cb81e78653595f713557e5d819cfa72df3fe0
|
|
| MD5 |
5b1d46d92c5a53ba75a1e97fa6ec822e
|
|
| BLAKE2b-256 |
2c7219b6f20f59f4d33a5b8e99e65edbbcbdae3c2b1b0b5fd457cf03950a79a2
|