Início

ZONY Autonomous + AutoPilot RTK™

IA Decision Engine · GPS RTK · PID Steering · CAN Bus · Nível 4

Python 3.11
GPS RTK cm
PID Control
CAN 0x200
Nível 4

Loop Autônomo Completo

SensoresIA DecidePath PlannerRTK NavigationPID SteeringCAN GatewayMáquina Executa

1. IA Decision Engine

Decide sozinha — sem clique

Roda em loop contínuo. Lê sensores e toma decisões automáticas de plantio ou parada com base em umidade, temperatura e previsão de chuva.

💧Umidade do Solo
🌡️Temperatura Ambiente
🌧️Previsão de Chuva
🌱Estado da Cultura
🚜Disp. de Máquinas
⚡API de Comandos
ai/decision_engine.py
Python
# ai/decision_engine.py
import time
import requests
import random

API_URL = "http://api:8000"

def get_field_data():
    # simulação de sensores
    return {
        "soil_moisture": random.randint(20, 80),
        "temperature": random.randint(20, 35),
        "rain_forecast": random.choice([True, False])
    }

def decision_loop():
    while True:
        data = get_field_data()
        print("DADOS:", data)

        # lógica de decisão
        if data["soil_moisture"] < 30 and not data["rain_forecast"]:
            print("IA DECIDIU: INICIAR PLANTIO")
            requests.post(f"{API_URL}/plant?machine_id=tractor_01&depth=5&spacing=0.5")

        elif data["soil_moisture"] > 70:
            print("IA DECIDIU: PARAR")
            requests.post(f"{API_URL}/stop?machine_id=tractor_01")

        time.sleep(10)

if __name__ == "__main__":
    decision_loop()
CondiçãoDecisão IAAção API
Umidade < 30% E sem chuva🟢 INICIAR PLANTIOPOST /plant
Umidade > 70%🔴 PARAR TUDOPOST /stop
Chuva prevista⏸️ AGUARDAR(nenhuma)
Adicionar docker-compose.yml
YAML
# Adicionar no docker-compose.yml
ai:
  build: ./ai
  depends_on:
    - api
ai/Dockerfile
Dockerfile
# ai/Dockerfile
FROM python:3.11
WORKDIR /app
COPY . .
RUN pip install requests
CMD ["python", "decision_engine.py"]

2. AutoPilot GPS RTK

Precisão centimétrica (2–3 cm)

GPS RTK

u-blox ZED-F9P

Base RTK / NTRIP

Correção diferencial

IMU

Giroscópio 9 eixos

Controlador

ESP32 / Jetson Nano

autopilot/navigation.py
Python
# autopilot/navigation.py
import math

def calculate_heading(current, target):
    lat1, lon1 = current
    lat2, lon2 = target

    dLon = lon2 - lon1

    x = math.sin(dLon) * math.cos(lat2)
    y = (math.cos(lat1) * math.sin(lat2)
         - math.sin(lat1) * math.cos(lat2) * math.cos(dLon))

    heading = math.atan2(x, y)
    return math.degrees(heading)

def steering_control(current_heading, target_heading):
    error = target_heading - current_heading

    # PID simples
    Kp = 1.5
    steering = Kp * error

    return max(min(steering, 30), -30)  # limite volante ±30°

3. Controle Real da Direção

CAN 0x200 · PID

Conversão ângulo → CAN byte

-30°→byte 00°→byte 120+30°→byte 240
autopilot/can_control.py
Python
# autopilot/can_control.py
def send_steering(angle, bus):
    # converte ângulo em byte (range: -30 a +30 → 0 a 240)
    value = int((angle + 30) * 4)
    send_can(0x200, [value], bus)

# CAN ID 0x200 → Controle de direção
# Byte 0 → ângulo codificado (0–240)

4. Linhas de Plantio Automáticas

autopilot/path_planner.py

Gera linhas de plantio paralelas automaticamente a partir da largura do talhão e do espaçamento desejado.

autopilot/path_planner.py
Python
# autopilot/path_planner.py

def generate_lines(field_width, spacing):
    """
    Gera linhas de plantio paralelas.
    field_width: largura do talhão (metros)
    spacing: espaçamento entre linhas (metros)
    """
    lines = []
    x = 0
    while x < field_width:
        lines.append(x)
        x += spacing
    return lines

# Exemplo: talhão 100m, espaçamento 0.5m → 200 linhas
lines = generate_lines(100, 0.5)
print(f"Total de linhas: {len(lines)}")
Talhão de 100m com espaçamento de 0.5m → 200 linhas geradas automaticamente.

5. Loop Completo Autônomo

End-to-End
autopilot/autopilot_main.py
Python
# Fluxo completo — autopilot_main.py
from decision_engine import get_field_data
from path_planner import generate_lines
from navigation import calculate_heading, steering_control
from can_control import send_steering

def autonomous_loop(bus):
    while True:
        # 1. IA decide
        data = get_field_data()

        if data["soil_moisture"] < 30 and not data["rain_forecast"]:
            # 2. Gera linhas de plantio
            lines = generate_lines(field_width=100, spacing=0.5)

            for line_x in lines:
                target = (line_x, 0)
                current = get_gps_position()

                # 3. Autopilot navega
                target_hdg  = calculate_heading(current, target)
                current_hdg = get_imu_heading()
                steering    = steering_control(current_hdg, target_hdg)

                # 4. Gateway envia CAN → máquina executa
                send_steering(steering, bus)
1

IA decide plantar

decision_engine.py · umidade < 30%

2

Gera linhas

path_planner.py · 200 linhas auto

3

Autopilot navega

navigation.py · RTK + heading

4

Gateway envia CAN

can_control.py · 0x200 steering

5

Máquina executa

Firmware ESP32 · atuadores

6. Segurança (OBRIGATÓRIO)

Sem isso NÃO coloque em campo

Botão STOP físico

GPIO independente de software. Para tudo imediatamente.

Geofencing

Limite geográfico da fazenda. Bloqueia saída do talhão.

Detecção de obstáculo

LIDAR ou ultrassom. Para antes de colidir.

Fail-safe sem GPS

Perda de sinal → parada automática e alerta.

7. Nível de Autonomia

SAE Levels

L0

Manual

L1

Assistido

L2

Parcial

L3

Condicional

L4

Alto / ZONY™

🔥 Você está aqui

Sem operador no campo
IA decide e executa
Máquina dirige sozinha

🔥 Resultado Final

IA decide automaticamente
Trator dirige sozinho
Integrado com CAN Bus
Agricultura autônoma L4

"A fazenda pensa, decide e se move sozinha."

— ZONY Autonomous Decision + AutoPilot RTK™

base44
Edit with Base44