{"id":8182,"library":"foxglove-schemas-protobuf","title":"Foxglove Schemas Protobuf","description":"This library provides precompiled Protocol Buffer (protobuf) schemas for Foxglove, a web-based visualization and debugging tool for robotics. It allows Python applications to serialize and deserialize data according to Foxglove's standardized message definitions, facilitating interoperability within the Foxglove ecosystem. The current version is 0.3.0, and updates typically align with new schema definitions released by the broader Foxglove SDK.","status":"active","version":"0.3.0","language":"en","source_language":"en","source_url":"https://github.com/foxglove/schemas","tags":["protobuf","schemas","robotics","data-serialization","foxglove"],"install":[{"cmd":"pip install foxglove-schemas-protobuf","lang":"bash","label":"Install latest version"}],"dependencies":[{"reason":"Required for parsing and serializing Protocol Buffer messages generated by this package.","package":"protobuf","optional":false}],"imports":[{"note":"Generated protobuf messages are typically within a `_pb2` module.","wrong":"import foxglove_schemas_protobuf.FrameTransform","symbol":"FrameTransform","correct":"from foxglove_schemas_protobuf.FrameTransform_pb2 import FrameTransform"},{"note":"Common protobuf types like Timestamp are part of the `google.protobuf` package, not directly from `foxglove_schemas_protobuf`.","wrong":"from protobuf.timestamp_pb2 import Timestamp","symbol":"Timestamp","correct":"from google.protobuf.timestamp_pb2 import Timestamp"}],"quickstart":{"code":"from foxglove_schemas_protobuf.FrameTransform_pb2 import FrameTransform\nfrom google.protobuf.timestamp_pb2 import Timestamp\n\n# Create a Timestamp\nts = Timestamp()\nts.seconds = 1678886400  # Example: March 15, 2023 12:00:00 PM UTC\nts.nanos = 123456789\n\n# Create a FrameTransform message\ntransform = FrameTransform(\n    timestamp=ts,\n    parent_frame_id=\"base_link\",\n    child_frame_id=\"tool0\",\n    translation_x=1.0,\n    translation_y=0.5,\n    translation_z=0.2,\n    rotation_x=0.0,\n    rotation_y=0.0,\n    rotation_z=0.0,\n    rotation_w=1.0\n)\n\n# Serialize to bytes\nserialized_data = transform.SerializeToString()\nprint(f\"Serialized FrameTransform data length: {len(serialized_data)} bytes\")\n\n# Deserialize from bytes\ndeserialized_transform = FrameTransform()\ndeserialized_transform.ParseFromString(serialized_data)\n\nprint(f\"\\nDeserialized Parent frame: {deserialized_transform.parent_frame_id}\")\nprint(f\"Deserialized Child frame: {deserialized_transform.child_frame_id}\")\nprint(f\"Deserialized Timestamp: {deserialized_transform.timestamp.seconds}.{deserialized_transform.timestamp.nanos}\")\n\nassert deserialized_transform.parent_frame_id == \"base_link\"\nassert deserialized_transform.translation_x == 1.0","lang":"python","description":"This example demonstrates how to create, serialize, and deserialize a `FrameTransform` message using the `foxglove-schemas-protobuf` library. It includes importing the specific message class and a common Google Protobuf type like `Timestamp`."},"warnings":[{"fix":"Regularly check PyPI for new versions of `foxglove-schemas-protobuf` and update your `requirements.txt`. Consult the Foxglove schemas GitHub repository for the latest schema definitions across all languages.","message":"The `foxglove-schemas-protobuf` Python package may lag behind schema updates in other Foxglove SDK languages (TypeScript, C++, Rust). If you're working with the latest schema definitions in other environments, ensure your Python package version is compatible or sufficiently recent.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your installed `protobuf` library version is compatible with the `foxglove-schemas-protobuf` package. Typically, `pip install foxglove-schemas-protobuf` will install a compatible `protobuf` version, but if you have existing protobuf installations, check for conflicts (`pip check`).","message":"Incompatibility with the `protobuf` library version. Protobuf generated code is sensitive to the version of the `protobuf` runtime library installed. Mismatched versions can lead to serialization/deserialization errors or unexpected behavior.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always pin exact versions for `foxglove-schemas-protobuf` in your project. When upgrading, test thoroughly and review the Foxglove schema changelog for breaking or compatibility-affecting changes. Use default values for optional fields to enhance robustness.","message":"Schema definition changes between `foxglove-schemas-protobuf` versions. While Protobuf is designed for backward compatibility, changes like renaming fields, altering field types, or modifying enum values can lead to `AttributeError` during access or `DecodeError` during deserialization if an older client tries to parse data from a newer schema (or vice-versa).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Verify the exact schema name from the Foxglove schemas repository. The Python module structure is `foxglove_schemas_protobuf.<SchemaName>_pb2` (e.g., `ImageAnnotation_pb2`). Ensure the package is correctly installed.","cause":"The specific schema's `_pb2` file does not exist, or the schema name is misspelled.","error":"ModuleNotFoundError: No module named 'foxglove_schemas_protobuf.SomeSchema_pb2'"},{"fix":"Ensure the input byte string is a complete and valid serialized Protobuf message for the target schema. Check the source of the data for corruption or mismatch. Verify that both sender and receiver are using compatible schema versions.","cause":"Attempting to deserialize an incomplete, corrupted, or incompatible (e.g., non-protobuf or wrong schema type) byte string.","error":"google.protobuf.message.DecodeError: Truncated message"},{"fix":"Update your code to reflect the current schema definition by consulting the Foxglove schema documentation or upgrading your `foxglove-schemas-protobuf` package and re-evaluating the available fields. Alternatively, ensure the data being deserialized matches the expected schema version.","cause":"You are attempting to access a field that no longer exists or has been renamed in the version of `foxglove-schemas-protobuf` you are using, or you are trying to parse data from a newer schema version with an older client.","error":"AttributeError: 'FrameTransform' object has no attribute 'old_field_name'"}]}