HRNSQ---Hybrid_Robotic_Nervous_System_for_Quadrupeds-

Public

@prageethm1702

Share HRNSQ---Hybrid_Robotic_Nervous_System_for_Quadrupeds-

Check access before sharing the link.

Who can open this board

Anyone can open this board. No sign-in is required.

This link opens the latest version. Copying it does not grant additional access.

Loading…

README

HRNS-Q: Hybrid Robotic Nervous System for Quadrupeds

HRNS-Q is a quadruped robot prototype built around a hybrid robotic nervous system. The design separates fast reflex and safety logic from slower sensing, vision, dashboard and gait control, giving the robot a practical layered control architecture for final-year demonstration work.

What It Does

HRNS-Q demonstrates:

  • Raspberry Pi 3 based high-level control
  • PCA9685 based control of 8 hobby servos
  • Four legs with active shoulder and knee joints
  • Hip motors frozen in software because the current hardware does not use them
  • STM32F407 low-level reflex and safety controller scaffold
  • Sim and Real dashboard telemetry modes
  • Two ESP32-CAM streams converted into a simple stereo heat view
  • Wide-angle night-vision camera based human reaction logic
  • MicroPython ESP32-CAM streaming path for non-Arduino workflows

System Architecture

The architecture is split into four practical layers.

LayerHardwareRole
High-level controllerRaspberry Pi 3Dashboard, sensors, camera streams, gait commands, PCA9685 servo output
Actuation layerPCA9685 and 8 servosShoulder and knee joint PWM control
Reflex layerSTM32F407 and reflex circuitFoot contact, safety checks, future fast response path
Vision layerTwo ESP32-CAMs and night cameraStereo heat view and human reaction trigger

Current Hardware

SubsystemParts Used
Main computerRaspberry Pi 3
Low-level controllerSTM32F407
Servo driverPCA9685 16-channel PWM board
Actuators8 x 180 degree hobby servos
Stereo vision2 x ESP32-CAM modules
Human reaction cameraWide-angle night-vision camera without IR LEDs
SensorsBMP280, BMI160, MLX90614, SGP30, Si7021, GPS and optional analog inputs

Repository Layout

Actuation System/          PCA9685 wiring and actuation notes
AI Neural System/          Legacy AI modules kept for reference
Communication/             CAN, I2C and UART maps
CPG System/                Gait tables and analog CPG design file
High Level Cognition/      Navigation and behavior planning modules
Localization Navigation/   GPS, navigation and estimation scripts
Low Level Control/         Python locomotion, STM32 firmware and assembly helpers
Perception/                Sensors, vision, stereo heat service and ESP32-CAM code
Power System/              Battery, fuse and power monitoring notes
Reflex System/             Reflex layer placeholders and interfaces
Safety/                    Safety checks, watchdog and shutdown command logic
Simulation Training/       Simulation environments and noise models
Software Framework/        Dashboard, telemetry and simulator
System Overview/           Architecture description
Vision/                    ESP camera and vision experiments

Locomotion Model

The current prototype uses 8 servos only. Each leg has:

  • Shoulder servo
  • Knee servo
  • Hip output held at 90 degrees in software

The locomotion code is classical and deterministic.

hip_deg = 90.0
frame = build_locomotion_frame(t, gait, speed)
output.apply_frame(frame)

Main files:

Low Level Control/python/hrnsq_locomotion.py
Low Level Control/python/pca9685_servo_driver.py
Low Level Control/python/verify_locomotion.py

PCA9685 Servo Map

PCA9685 ChannelJoint
0Front left shoulder
1Front left knee
2Front right shoulder
3Front right knee
4Rear left shoulder
5Rear left knee
6Rear right shoulder
7Rear right knee

Dashboard

The dashboard supports two telemetry sources.

ModeMeaning
SimGenerated values for demonstration and UI testing
RealRaspberry Pi sensor values, PCA9685 actuator commands and camera streams

Dashboard files:

Software Framework/interface/websocket_server.py
Software Framework/interface/real_telemetry.py
Software Framework/interface/telemetry_state.py
Software Framework/interface/dashboard/

Run telemetry:

cd "Software Framework/interface"
python websocket_server.py

Run dashboard page:

cd "Software Framework/interface/dashboard"
python -m http.server 5500 --bind 0.0.0.0

Open:

http://<raspberry-pi-ip>:5500/templates/dashboard.html

Vision And Stereo Heat View

Two ESP32-CAM modules are mounted with:

ParameterValue
Camera spacing15 cm
Camera height6 cm from ground

This is not a calibrated depth system. The Raspberry Pi reads both ESP32 streams and creates a simple heat-style view for dashboard demonstration.

Vision service:

cd "Perception/Depth Camera"
export HRNSQ_ESP32_LEFT_URL="http://192.168.1.51:81/stream"
export HRNSQ_ESP32_RIGHT_URL="http://192.168.1.52:81/stream"
export HRNSQ_NIGHT_CAM_INDEX="0"
python stereo_heat_server.py

Streams:

OutputURL
Night camerahttp://<pi-ip>:9100/night.mjpg
Stereo heat viewhttp://<pi-ip>:9100/depth_heat.mjpg
Human reaction JSONhttp://<pi-ip>:9100/reaction.json

ESP32-CAM MicroPython

Arduino firmware is not required. The project includes a MicroPython stream server.

Perception/Depth Camera/esp32_micropython/

Important requirement:

import camera

The ESP32-CAM firmware must include the MicroPython camera module. Generic ESP32 MicroPython firmware often does not include it.

Upload with Thonny:

  1. Flash ESP32-CAM camera-enabled MicroPython firmware
  2. Save config_left.py as config.py on the left ESP32-CAM
  3. Save main.py on the left ESP32-CAM
  4. Save config_right.py as config.py on the right ESP32-CAM
  5. Save main.py on the right ESP32-CAM

Expected stream URLs:

http://192.168.1.51:81/stream
http://192.168.1.52:81/stream

Human Reaction Logic

The night camera uses OpenCV based lightweight detection.

DetectionReaction
Face high in framelook_up
Human centered and closegive_hand
Human visiblelook_at_human
Nothing detectedidle_scan

Raspberry Pi Setup

Enable I2C and serial:

sudo raspi-config

Install packages:

sudo apt update
sudo apt install python3-full python3-venv i2c-tools git python3-opencv
python3 -m venv hrnsq_env
source hrnsq_env/bin/activate
pip install adafruit-blinka smbus2 numpy pynmea2
pip install adafruit-circuitpython-servokit
pip install adafruit-circuitpython-bmp280 adafruit-circuitpython-sgp30
pip install adafruit-circuitpython-si7021 adafruit-circuitpython-mlx90614
pip install adafruit-circuitpython-ads1x15 BMI160-i2c

Verify I2C:

i2cdetect -y 1

STM32F407 Path

The STM32 side is used as the low-level reflex and safety controller scaffold.

Low Level Control/stm32/
Low Level Control/stm32/firmware/asm/

Flash using STM32CubeIDE and ST-LINK.

The firmware/asm folder contains optional Cortex M4 assembly for the STM32F407 reflex path: IRQ lock and restore, low-power wait instructions, DWT cycle timing, fast GPIO BSRR writes, EXTI reflex stubs and a startup/vector table template. Use only one startup file in STM32CubeIDE. If CubeMX already generated startup code, keep the CubeMX file and use the HRNS-Q startup file as a reference.

ST-LINKSTM32F407
SWDIOPA13
SWCLKPA14
GNDGND
3.3 V sense3.3 V
NRSTNRST optional

Testing Evidence

Safety Notes

  • Do not power servos from the Raspberry Pi.
  • Use a separate 5 to 6 V high-current servo supply.
  • Connect Raspberry Pi, PCA9685, STM32 and servo supply grounds together.
  • Keep all Raspberry Pi GPIO and STM32 logic at 3.3 V.
  • Test with the robot lifted before enabling movement.
  • Real mode does not move servos unless HRNSQ_ENABLE_SERVOS=1 is set.

Quick Start

python "Low Level Control/python/verify_locomotion.py"

Start vision:

cd "Perception/Depth Camera"
python stereo_heat_server.py

Start telemetry:

cd "Software Framework/interface"
python websocket_server.py

Start dashboard:

cd "Software Framework/interface/dashboard"
python -m http.server 5500 --bind 0.0.0.0

Status

HRNS-Q is a working prototype-level implementation. The simulator, dashboard, PCA9685 servo command path, ESP32-CAM heat view service and MicroPython camera streaming code are present. The STM32 reflex layer is prepared as a scaffold and should be completed through hardware testing.

Comments

No comments yet. Be the first to ask about this board.

Ask about this board

Sign in to BoardRepo

New here? Signing in creates your account; there is no separate sign-up.