Skip to content

Conversation

@mlecriva
Copy link
Collaborator

@mlecriva mlecriva commented Dec 16, 2025

Odometry Calibration Tool & Telemetry Infrastructure

This PR adds an interactive odometry calibration tool with the supporting telemetry infrastructure to enable real-time firmware monitoring.

Changes

Telemetry System

  • Add protobuf message schema for firmware telemetry data
  • Add pydantic model for parsing/validation of telemetry messages
  • Implement telemetry forwarding in copilot via Socket.IO
  • Add /telemetry namespace on server for broadcasting to tools
  • Add embeddable FirmwareTelemetryManager for use in Calibration tools

Calibration Tool

  • Add /firmware_calibration namespace on server for tool-to-firmware communication
  • Enable copilot to receive pose orders from calibration tools
  • Add reusable ConsoleUI utilities for terminal-based tool interfaces
  • Implement odometry calibration tool with:
    • Socket.IO orchestration via cogip-server
    • Firmware control through FirmwareAdapter
    • Interactive terminal UI
    • Calculation engine for odometry parameter tuning

Other

  • Refactor parameter manager to use Socket.IO via server (aligns with stack architecture)

Why

  • Enables real-time monitoring of firmware internal state for debugging and tuning
  • Provides a streamlined workflow for calibrating robot odometry parameters
  • Aligns tool architecture with consistent Socket.IO-based communication pattern

Closes #171

@mlecriva mlecriva requested review from ecourtois and gdoffe December 16, 2025 20:47
@mlecriva mlecriva self-assigned this Dec 16, 2025
@mlecriva mlecriva added enhancement New feature or request feature A new feature labels Dec 16, 2025
@mlecriva mlecriva linked an issue Dec 16, 2025 that may be closed by this pull request
@mlecriva mlecriva force-pushed the 171-add-odometry-calibration-tool branch 4 times, most recently from bb55b90 to 31363a8 Compare December 20, 2025 10:04
Copy link
Contributor

@ecourtois ecourtois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job!
Please check few comments anyway.

@mlecriva mlecriva force-pushed the 171-add-odometry-calibration-tool branch 2 times, most recently from a8b96f4 to 849bb23 Compare December 22, 2025 09:45
@mlecriva mlecriva requested a review from ecourtois December 22, 2025 09:45
Copy link
Contributor

@ecourtois ecourtois left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check 3 new comments and you can merge once fixed.

Comment on lines 45 to 47
@cache
def fnv1a_hash(string: str) -> int:
"""Compute FNV-1a hash of a string.

Results are cached to avoid recomputing hashes for previously seen strings,
since parameter names are typically accessed repeatedly.

Args:
string: The string to hash

Returns:
The 32-bit hash value as an unsigned integer

Example:
>>> hex(fnv1a_hash("parameter"))
'0x100b'
"""
# FNV-1a constants
FNV_OFFSET_BASIS = 0x811C9DC5
FNV_PRIME = 0x01000193

hash_value = FNV_OFFSET_BASIS

for byte in string.encode("utf-8"):
hash_value ^= byte
hash_value = (hash_value * FNV_PRIME) & 0xFFFFFFFF # Keep it 32-bit

return hash_value


class FirmwareParameterBase(BaseModel):
"""Base firmware parameter type"""

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This replacement must be done in the previous commit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

by communicating with the firmware via SocketIO through cogip-server.
"""

from __future__ import annotations
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it required using Python 3.13?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not required with Python 3.13. Removed.

"scikit-learn~=1.6.1",
"watchfiles==0.24.0",
"websocket-client==1.7.0",
"rich==14.2.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You forgot to commit uv.lock.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rich already exist in the merged uv.lock so there is nothing new to commit.

Move fnv1a to utils folder because this is not a model and can be used
everywhere.

Add @cache decorator to avoid recomputing hashes for repeated parameter
names.

Parameter names are typically accessed multiple times during firmware
communication and hashes never changes, so we can cache it during the whole
execution lifetime.
- Align architecture with other tools implementation pattern
- Enable integration within existing stack without conflicts
- Add firmware_parameters namespace to server
- Route parameter operations through copilot socket.io events

This tool is designed to be used through another client as setting/getting
parameter is useful for other tool integration.
- Define PB_Telemetry message schema for mcu-firmware data
- Generate Python bindings and type stubs
- Enable real-time monitoring of firmware internal state
- Enable parsing and validation of telemetry messages from firmware
- Provide easy access to latest valid data by key or full message
- Ensure data consistency with pydantic validation
- Enable firmware telemetry data broadcast to connected clients
- Follow existing tools architecture for consistency
- Allow embedding in other Socket.IO clients (Monitor, etc.)
- Store telemetry in TelemetryStore with key/hash access
- Enable firmware telemetry broadcast to connected tools
- Register /telemetry namespace for Planner, Monitor, Calibration tools
- Support multiple concurrent client connections
- Route telemetry events from copilot through server
- Enable tools to receive firmware telemetry via copilot Socket.IO
- Register /telemetry namespace on host client connection
- Store telemetry data in TelemetryStore with key/hash access
- Design for embedding in Monitor, Calibration tools
- Enable calibration tools to send pose commands via Socket.IO
- Allow remote control of robot pose during calibration process
- Extend copilot event handling for calibration workflow
- Enable calibration tools to communicate via server Socket.IO
- Route calibration commands between tools and copilot
- Follow existing namespace architecture pattern
- Provide reusable terminal UI components for calibration tools
- Orchestrate calibration via Socket.IO connection to cogip-server
- Coordinate firmware operations through FirmwareAdapter
- Provide interactive user interface via ConsoleUI
- Include calculation engine for odometry parameter tuning
@mlecriva mlecriva force-pushed the 171-add-odometry-calibration-tool branch from 849bb23 to d402c69 Compare January 2, 2026 08:47
@mlecriva mlecriva merged commit 874465c into master Jan 2, 2026
4 checks passed
@ecourtois ecourtois deleted the 171-add-odometry-calibration-tool branch January 2, 2026 12:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tools: Add Calibration Tool for Robot Odometry

2 participants