inxhrobotics-bob 1.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.1
2
+ Name: inxhrobotics-bob
3
+ Version: 1.0.1
4
+ Summary: Python AI & Computer Vision Library for INXH Robotics Bob Biped Robot Kit
5
+ Home-page: https://github.com/inxhrobotics/inxh_BobRobot
6
+ Author: INXH Robotics
7
+ Author-email: info@inxhrobotics.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+
14
+ # inxhbob
15
+
16
+ Official Python AI & Computer Vision Library for the **INXH Robotics Bob Biped Robot Kit**.
17
+
18
+ ## Features
19
+ - **High-Speed Serial Protocol:** Plug-and-play USB connection to Bob Robot with automatic COM port detection.
20
+ - **MediaPipe AI Hand Tracking:** Real-time 21-point 3D hand tracking and finger counting (0-5) with robot high-five triggers.
21
+ - **Face Detection & Greeting:** Real-time face tracking that commands Bob to look, greet, and interact.
22
+ - **Gesture Recognition & Mirroring:** Rock-paper-scissors, thumbs-up, peace signs, and victory dances.
23
+ - **Sensor Telemetry Query:** Real-time querying of Bob's touch, tilt, and ultrasonic sonar distance sensors.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install inxhrobotics-bob
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```python
34
+ from inxhbob import BobRobotSerial, FingerCounter
35
+ import cv2
36
+
37
+ # Initialize Bob Robot over USB
38
+ bob = BobRobotSerial()
39
+
40
+ # Show Heart Eyes and play happy tone
41
+ bob.show_expression("HEART")
42
+ bob.play_sound("HAPPY")
43
+
44
+ # Perform a dance
45
+ bob.execute_motion("DANCE")
46
+
47
+ # Clean disconnect
48
+ bob.close()
49
+ ```
50
+
51
+ ## Requirements
52
+ - Python >= 3.7
53
+ - opencv-python >= 4.5.0
54
+ - mediapipe >= 0.8.9
55
+ - pyserial >= 3.5
56
+
57
+ ## Official Links
58
+ - **Website:** [https://inxhrobotics.com](https://inxhrobotics.com)
59
+ - **GitHub:** [https://github.com/inxhrobotics/inxh_BobRobot](https://github.com/inxhrobotics/inxh_BobRobot)
@@ -0,0 +1,46 @@
1
+ # inxhbob
2
+
3
+ Official Python AI & Computer Vision Library for the **INXH Robotics Bob Biped Robot Kit**.
4
+
5
+ ## Features
6
+ - **High-Speed Serial Protocol:** Plug-and-play USB connection to Bob Robot with automatic COM port detection.
7
+ - **MediaPipe AI Hand Tracking:** Real-time 21-point 3D hand tracking and finger counting (0-5) with robot high-five triggers.
8
+ - **Face Detection & Greeting:** Real-time face tracking that commands Bob to look, greet, and interact.
9
+ - **Gesture Recognition & Mirroring:** Rock-paper-scissors, thumbs-up, peace signs, and victory dances.
10
+ - **Sensor Telemetry Query:** Real-time querying of Bob's touch, tilt, and ultrasonic sonar distance sensors.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ pip install inxhrobotics-bob
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```python
21
+ from inxhbob import BobRobotSerial, FingerCounter
22
+ import cv2
23
+
24
+ # Initialize Bob Robot over USB
25
+ bob = BobRobotSerial()
26
+
27
+ # Show Heart Eyes and play happy tone
28
+ bob.show_expression("HEART")
29
+ bob.play_sound("HAPPY")
30
+
31
+ # Perform a dance
32
+ bob.execute_motion("DANCE")
33
+
34
+ # Clean disconnect
35
+ bob.close()
36
+ ```
37
+
38
+ ## Requirements
39
+ - Python >= 3.7
40
+ - opencv-python >= 4.5.0
41
+ - mediapipe >= 0.8.9
42
+ - pyserial >= 3.5
43
+
44
+ ## Official Links
45
+ - **Website:** [https://inxhrobotics.com](https://inxhrobotics.com)
46
+ - **GitHub:** [https://github.com/inxhrobotics/inxh_BobRobot](https://github.com/inxhrobotics/inxh_BobRobot)
@@ -0,0 +1,13 @@
1
+ """
2
+ INXH Robotics Bob Python AI Library (inxhbob)
3
+ ==============================================
4
+ Provides high-level Serial Communication and Computer Vision (OpenCV + MediaPipe)
5
+ integration for the INXH Robotics Bob Biped Robot Kit.
6
+ """
7
+
8
+ from .bob_serial import BobRobotSerial
9
+ from .bob_vision import FingerCounter, FaceTracker, GestureRecognizer, EmotionDetector
10
+
11
+ __version__ = "1.0.1"
12
+ __author__ = "INXH Robotics"
13
+ __all__ = ["BobRobotSerial", "FingerCounter", "FaceTracker", "GestureRecognizer", "EmotionDetector"]
@@ -0,0 +1,130 @@
1
+ import time
2
+ import json
3
+ import serial
4
+ import serial.tools.list_ports
5
+
6
+ class BobRobotSerial:
7
+ """
8
+ High-level Python driver for communicating with Bob Robot's Arduino Serial Bridge (115200 Baud).
9
+ Includes automatic port detection, graceful exception handling, and offline simulation fallback.
10
+ """
11
+
12
+ def __init__(self, port=None, baudrate=115200, timeout=1.0):
13
+ self.port = port
14
+ self.baudrate = baudrate
15
+ self.timeout = timeout
16
+ self.ser = None
17
+ self.is_connected = False
18
+
19
+ if self.port is None:
20
+ self.port = self.auto_detect_port()
21
+
22
+ if self.port:
23
+ self.is_connected = self.connect()
24
+
25
+ def auto_detect_port(self):
26
+ """Auto-detects connected Arduino COM port."""
27
+ try:
28
+ ports = list(serial.tools.list_ports.comports())
29
+ for p in ports:
30
+ if "Arduino" in p.description or "CH340" in p.description or "USB Serial" in p.description or "FT232" in p.description:
31
+ print(f"[inxhbob] Auto-detected Bob Robot on port: {p.device}")
32
+ return p.device
33
+ if ports:
34
+ print(f"[inxhbob] Using fallback COM port: {ports[0].device}")
35
+ return ports[0].device
36
+ except Exception as e:
37
+ pass
38
+ print("[inxhbob] Warning: No COM port detected. Please specify port manually (e.g. port='COM3').")
39
+ return None
40
+
41
+ def connect(self):
42
+ """Establishes Serial Connection with Bob Robot."""
43
+ if not self.port:
44
+ return False
45
+ try:
46
+ self.ser = serial.Serial(self.port, self.baudrate, timeout=self.timeout)
47
+ time.sleep(1.5) # Allow serial bridge stabilization
48
+ print(f"[inxhbob] Connected successfully to Bob Robot on {self.port} at {self.baudrate} baud!")
49
+ return True
50
+ except serial.SerialException as e:
51
+ print(f"\n[inxhbob] COM PORT BUSY NOTICE ({self.port}):")
52
+ print(f" -> Arduino IDE Serial Monitor or Thonny backend is occupying {self.port}.")
53
+ print(" -> Please close Arduino IDE Serial Monitor or click Stop (Ctrl+F2) in Thonny.")
54
+ print(" -> [Running in Vision Preview Mode]\n")
55
+ self.ser = None
56
+ return False
57
+ except Exception as e:
58
+ print(f"[inxhbob] Connection Error on {self.port}: {e}")
59
+ self.ser = None
60
+ return False
61
+
62
+ def send_command(self, cmd):
63
+ """Sends raw command string to Arduino over Serial if connected."""
64
+ if self.ser and self.ser.is_open:
65
+ try:
66
+ full_cmd = f"{cmd}\n"
67
+ self.ser.write(full_cmd.encode('utf-8'))
68
+ self.ser.flush()
69
+ except Exception as e:
70
+ pass
71
+
72
+ def display_number(self, digit):
73
+ """Displays digit 0 to 9 on MAX7219 Matrix."""
74
+ digit = max(0, min(9, int(digit)))
75
+ self.send_command(f"N:{digit}")
76
+
77
+ def show_expression(self, expression):
78
+ """
79
+ Displays Facial Expression on MAX7219 Matrix.
80
+ Expressions: 'HAPPY', 'SAD', 'WINK', 'SURPRISE', 'HEART', 'ANGRY', 'SLEEP', 'NEUTRAL'
81
+ """
82
+ self.send_command(f"E:{expression.upper()}")
83
+
84
+ def play_sound(self, sound):
85
+ """
86
+ Plays Sound Effect / Tone on Piezo Buzzer.
87
+ Sounds: 'BEEP', 'HAPPY', 'SAD', 'SURPRISE', 'ALARM'
88
+ """
89
+ self.send_command(f"S:{sound.upper()}")
90
+
91
+ def execute_motion(self, motion):
92
+ """
93
+ Executes Bipedal Gait / Motion.
94
+ Motions: 'WALK_FWD', 'WALK_BWD', 'TURN_L', 'TURN_R', 'DANCE', 'HOME'
95
+ """
96
+ self.send_command(f"M:{motion.upper()}")
97
+
98
+ def read_sensors(self):
99
+ """
100
+ Queries Bob's hardware sensors (Touch, Tilt, HC-SR04 Sonar) and returns dict:
101
+ {'touch': 0/1, 'tilt': 0/1, 'sonar': float_cm}
102
+ """
103
+ if not self.ser or not self.ser.is_open:
104
+ return {'touch': 0, 'tilt': 0, 'sonar': 25.0} # Offline preview fallback
105
+
106
+ try:
107
+ self.ser.reset_input_buffer()
108
+ self.send_command("R:SENSORS")
109
+
110
+ # Read response line from Arduino (blocking up to timeout)
111
+ line = self.ser.readline().decode('utf-8', errors='ignore').strip()
112
+ if line.startswith("{") and line.endswith("}"):
113
+ return json.loads(line)
114
+ except Exception as e:
115
+ pass
116
+ return {'touch': 0, 'tilt': 0, 'sonar': 25.0}
117
+
118
+ def close(self):
119
+ """Safely closes serial connection and releases COM port."""
120
+ if self.ser and self.ser.is_open:
121
+ try:
122
+ self.ser.flush()
123
+ self.ser.close()
124
+ print("[inxhbob] Serial connection closed cleanly.")
125
+ except Exception as e:
126
+ pass
127
+
128
+ def __del__(self):
129
+ """Destructor releasing COM port handle."""
130
+ self.close()
@@ -0,0 +1,162 @@
1
+ import cv2
2
+ import math
3
+ import mediapipe as mp
4
+
5
+ class FingerCounter:
6
+ """
7
+ Real-time Hand Landmark & Finger Counting AI using MediaPipe Hands.
8
+ Uses 3D Vector Distance Ratios for accurate 0-5 finger counting.
9
+ """
10
+ def __init__(self, max_hands=1, detection_confidence=0.7, tracking_confidence=0.7):
11
+ self.mp_hands = mp.solutions.hands
12
+ self.hands = self.mp_hands.Hands(
13
+ max_num_hands=max_hands,
14
+ min_detection_confidence=detection_confidence,
15
+ min_tracking_confidence=tracking_confidence
16
+ )
17
+ self.mp_draw = mp.solutions.drawing_utils
18
+ self.tip_ids = [4, 8, 12, 16, 20] # Thumb, Index, Middle, Ring, Pinky
19
+
20
+ def count_fingers(self, img, draw=True):
21
+ img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
22
+ results = self.hands.process(img_rgb)
23
+ finger_count = 0
24
+
25
+ if results.multi_hand_landmarks:
26
+ for hand_lms in results.multi_hand_landmarks:
27
+ if draw:
28
+ self.mp_draw.draw_landmarks(img, hand_lms, self.mp_hands.HAND_CONNECTIONS)
29
+
30
+ landmarks = []
31
+ for id, lm in enumerate(hand_lms.landmark):
32
+ h, w, c = img.shape
33
+ cx, cy = int(lm.x * w), int(lm.y * h)
34
+ landmarks.append((id, cx, cy))
35
+
36
+ if len(landmarks) >= 21:
37
+ # Thumb Vector Distance Ratio
38
+ d_tip_index = math.hypot(landmarks[4][1] - landmarks[5][1], landmarks[4][2] - landmarks[5][2])
39
+ d_ip_index = math.hypot(landmarks[3][1] - landmarks[5][1], landmarks[3][2] - landmarks[5][2])
40
+
41
+ if d_tip_index > d_ip_index * 1.15:
42
+ finger_count += 1
43
+
44
+ # 4 Fingers (Index, Middle, Ring, Pinky)
45
+ for id in range(1, 5):
46
+ tip_idx = self.tip_ids[id]
47
+ pip_idx = tip_idx - 2
48
+ mcp_idx = tip_idx - 3
49
+
50
+ if (landmarks[tip_idx][2] < landmarks[pip_idx][2]) and (landmarks[tip_idx][2] < landmarks[mcp_idx][2]):
51
+ finger_count += 1
52
+
53
+ return finger_count, img
54
+
55
+
56
+ class FaceTracker:
57
+ """
58
+ Real-time Face Detector using OpenCV Haar Cascades.
59
+ """
60
+ def __init__(self, min_detection_confidence=0.6):
61
+ self.face_cascade = cv2.CascadeClassifier(cv2.data.haarcascades + 'haarcascade_frontalface_default.xml')
62
+
63
+ def detect_face(self, img, draw=True):
64
+ gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
65
+ faces = self.face_cascade.detectMultiScale(gray, 1.1, 5, minSize=(60, 60))
66
+
67
+ found = False
68
+ center_x, center_y = 0, 0
69
+
70
+ if len(faces) > 0:
71
+ x, y, w, h = faces[0]
72
+ center_x = x + (w // 2)
73
+ center_y = y + (h // 2)
74
+ found = True
75
+
76
+ if draw:
77
+ cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
78
+ cv2.circle(img, (center_x, center_y), 5, (0, 0, 255), -1)
79
+ cv2.putText(img, "FACE DETECTED", (x, y - 10),
80
+ cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2)
81
+
82
+ return found, center_x, center_y, img
83
+
84
+
85
+ class GestureRecognizer:
86
+ """
87
+ Recognizes Hand Gestures: 'THUMBS_UP', 'PEACE', 'OPEN_PALM', 'FIST', 'NONE'.
88
+ """
89
+ def __init__(self):
90
+ self.finger_counter = FingerCounter()
91
+
92
+ def detect_gesture(self, img, draw=True):
93
+ count, img = self.finger_counter.count_fingers(img, draw=draw)
94
+
95
+ gesture = "NONE"
96
+ if count == 5:
97
+ gesture = "OPEN_PALM"
98
+ elif count == 2:
99
+ gesture = "PEACE"
100
+ elif count == 1:
101
+ gesture = "THUMBS_UP"
102
+ elif count == 0:
103
+ gesture = "FIST"
104
+
105
+ if draw and gesture != "NONE":
106
+ cv2.putText(img, f"GESTURE: {gesture}", (20, 50),
107
+ cv2.FONT_HERSHEY_SIMPLEX, 0.8, (255, 255, 0), 2)
108
+
109
+ return gesture, img
110
+
111
+
112
+ class EmotionDetector:
113
+ """
114
+ Real-time Facial Emotion & Smile AI using MediaPipe Face Mesh.
115
+ """
116
+ def __init__(self):
117
+ self.mp_face_mesh = mp.solutions.face_mesh
118
+ self.face_mesh = self.mp_face_mesh.FaceMesh(
119
+ max_num_faces=1,
120
+ refine_landmarks=True,
121
+ min_detection_confidence=0.6,
122
+ min_tracking_confidence=0.6
123
+ )
124
+
125
+ def detect_emotion(self, img, draw=True):
126
+ img_rgb = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
127
+ results = self.face_mesh.process(img_rgb)
128
+ emotion = "NEUTRAL"
129
+
130
+ if results.multi_face_landmarks:
131
+ for face_lms in results.multi_face_landmarks:
132
+ h, w, _ = img.shape
133
+ pts = [(int(lm.x * w), int(lm.y * h)) for lm in face_lms.landmark]
134
+
135
+ left_corner = pts[61]
136
+ right_corner = pts[291]
137
+ top_lip = pts[13]
138
+ bottom_lip = pts[14]
139
+
140
+ mouth_width = math.hypot(right_corner[0] - left_corner[0], right_corner[1] - left_corner[1])
141
+ mouth_height = math.hypot(bottom_lip[0] - top_lip[0], bottom_lip[1] - top_lip[1])
142
+ face_width = math.hypot(pts[454][0] - pts[234][0], pts[454][1] - pts[234][1])
143
+
144
+ if face_width > 0:
145
+ smile_ratio = mouth_width / face_width
146
+ open_ratio = mouth_height / face_width
147
+
148
+ if open_ratio > 0.15:
149
+ emotion = "SURPRISE"
150
+ elif smile_ratio > 0.43:
151
+ emotion = "SMILE"
152
+ else:
153
+ emotion = "NEUTRAL"
154
+
155
+ if draw:
156
+ cv2.circle(img, left_corner, 3, (0, 255, 255), -1)
157
+ cv2.circle(img, right_corner, 3, (0, 255, 255), -1)
158
+ cv2.line(img, top_lip, bottom_lip, (255, 0, 255), 2)
159
+ cv2.putText(img, f"EMOTION: {emotion}", (20, 50),
160
+ cv2.FONT_HERSHEY_SIMPLEX, 1.0, (0, 255, 0), 2)
161
+
162
+ return emotion, img
@@ -0,0 +1,59 @@
1
+ Metadata-Version: 2.1
2
+ Name: inxhrobotics-bob
3
+ Version: 1.0.1
4
+ Summary: Python AI & Computer Vision Library for INXH Robotics Bob Biped Robot Kit
5
+ Home-page: https://github.com/inxhrobotics/inxh_BobRobot
6
+ Author: INXH Robotics
7
+ Author-email: info@inxhrobotics.com
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.7
12
+ Description-Content-Type: text/markdown
13
+
14
+ # inxhbob
15
+
16
+ Official Python AI & Computer Vision Library for the **INXH Robotics Bob Biped Robot Kit**.
17
+
18
+ ## Features
19
+ - **High-Speed Serial Protocol:** Plug-and-play USB connection to Bob Robot with automatic COM port detection.
20
+ - **MediaPipe AI Hand Tracking:** Real-time 21-point 3D hand tracking and finger counting (0-5) with robot high-five triggers.
21
+ - **Face Detection & Greeting:** Real-time face tracking that commands Bob to look, greet, and interact.
22
+ - **Gesture Recognition & Mirroring:** Rock-paper-scissors, thumbs-up, peace signs, and victory dances.
23
+ - **Sensor Telemetry Query:** Real-time querying of Bob's touch, tilt, and ultrasonic sonar distance sensors.
24
+
25
+ ## Installation
26
+
27
+ ```bash
28
+ pip install inxhrobotics-bob
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```python
34
+ from inxhbob import BobRobotSerial, FingerCounter
35
+ import cv2
36
+
37
+ # Initialize Bob Robot over USB
38
+ bob = BobRobotSerial()
39
+
40
+ # Show Heart Eyes and play happy tone
41
+ bob.show_expression("HEART")
42
+ bob.play_sound("HAPPY")
43
+
44
+ # Perform a dance
45
+ bob.execute_motion("DANCE")
46
+
47
+ # Clean disconnect
48
+ bob.close()
49
+ ```
50
+
51
+ ## Requirements
52
+ - Python >= 3.7
53
+ - opencv-python >= 4.5.0
54
+ - mediapipe >= 0.8.9
55
+ - pyserial >= 3.5
56
+
57
+ ## Official Links
58
+ - **Website:** [https://inxhrobotics.com](https://inxhrobotics.com)
59
+ - **GitHub:** [https://github.com/inxhrobotics/inxh_BobRobot](https://github.com/inxhrobotics/inxh_BobRobot)
@@ -0,0 +1,10 @@
1
+ README.md
2
+ setup.py
3
+ inxhbob/__init__.py
4
+ inxhbob/bob_serial.py
5
+ inxhbob/bob_vision.py
6
+ inxhrobotics_bob.egg-info/PKG-INFO
7
+ inxhrobotics_bob.egg-info/SOURCES.txt
8
+ inxhrobotics_bob.egg-info/dependency_links.txt
9
+ inxhrobotics_bob.egg-info/requires.txt
10
+ inxhrobotics_bob.egg-info/top_level.txt
@@ -0,0 +1,3 @@
1
+ opencv-python>=4.5.0
2
+ mediapipe>=0.8.9
3
+ pyserial>=3.5
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,32 @@
1
+ from setuptools import setup, find_packages
2
+ import os
3
+
4
+ this_directory = os.path.abspath(os.path.dirname(__file__))
5
+ readme_path = os.path.join(this_directory, "README.md")
6
+ long_description = ""
7
+ if os.path.exists(readme_path):
8
+ with open(readme_path, encoding="utf-8") as f:
9
+ long_description = f.read()
10
+
11
+ setup(
12
+ name="inxhrobotics-bob",
13
+ version="1.0.1",
14
+ description="Python AI & Computer Vision Library for INXH Robotics Bob Biped Robot Kit",
15
+ long_description=long_description,
16
+ long_description_content_type="text/markdown",
17
+ author="INXH Robotics",
18
+ author_email="info@inxhrobotics.com",
19
+ url="https://github.com/inxhrobotics/inxh_BobRobot",
20
+ packages=find_packages(),
21
+ install_requires=[
22
+ "opencv-python>=4.5.0",
23
+ "mediapipe>=0.8.9",
24
+ "pyserial>=3.5"
25
+ ],
26
+ classifiers=[
27
+ "Programming Language :: Python :: 3",
28
+ "License :: OSI Approved :: MIT License",
29
+ "Operating System :: OS Independent",
30
+ ],
31
+ python_requires=">=3.7",
32
+ )