dependabot[bot] cda31464d3 ci(deps): bump actions/configure-pages from 4 to 5
Bumps [actions/configure-pages](https://github.com/actions/configure-pages) from 4 to 5.
- [Release notes](https://github.com/actions/configure-pages/releases)
- [Commits](https://github.com/actions/configure-pages/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/configure-pages
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-09-03 08:01:31 +00:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00
2025-09-02 16:39:44 +08:00

MsgCenterPy

PyPI version Python versions Build Status Documentation

GitHub stars GitHub forks GitHub issues License


🚀 概述

MsgCenterPy 是一个基于统一实例管理器架构的多格式消息转换系统,支持 ROS2PydanticDataclassJSONDictYAMLJSON Schema 之间的无缝互转。

支持的格式

格式 读取 写入 JSON Schema 类型约束
ROS2
JSON Schema
Pydantic 开发中 开发中 开发中 开发中
Dataclass 开发中 开发中 开发中 开发中
JSON 开发中 开发中 开发中 开发中
Dict 开发中 开发中 开发中 开发中
YAML 开发中 开发中 开发中 开发中

📦 安装

基础安装

pip install msgcenterpy

包含可选依赖

# 安装 ROS2 支持
conda install

# 安装开发工具
pip install msgcenterpy[dev]

# 安装文档工具
pip install msgcenterpy[docs]

# 安装所有依赖
pip install msgcenterpy[all]

从源码安装

git clone https://github.com/ZGCA-Forge/MsgCenterPy.git
cd MsgCenterPy
pip install -e .[dev]

🔧 快速开始

基础使用

from msgcenterpy import MessageInstance, MessageType

# 从字典创建消息实例
data = {
    "name": "sensor_001",
    "readings": [1.0, 2.0, 3.0],
    "active": True
}
dict_instance = MessageInstance.create(MessageType.DICT, data)

# 生成 JSON Schema
schema = dict_instance.get_json_schema()
print(schema)

ROS2 消息转换

from std_msgs.msg import String
from msgcenterpy.instances.ros2_instance import ROS2MessageInstance

# 创建 ROS2 消息实例
string_msg = String()
string_msg.data = "Hello ROS2"
ros2_instance = ROS2MessageInstance(string_msg)

# 转换为 JSON Schema
json_schema_instance = ros2_instance.to_json_schema()

# 获取生成的 Schema
schema = json_schema_instance.json_schema
print(schema)

字段访问和约束

# 动态字段访问
ros2_instance.data_field = "new_value"
print(ros2_instance.fields.get_field_info("data"))

# 类型约束验证
type_info = ros2_instance.fields.get_sub_type_info("data")
print(f"约束条件: {[c.type.value for c in type_info.constraints]}")

📖 文档

核心概念

  • MessageInstance: 统一消息实例基类
  • TypeInfo: 详细的字段类型信息和约束
  • FieldAccessor: 统一字段访问接口
  • MessageCenter: 消息类型管理和转换中心

API 参考

详细的 API 文档请访问:https://zgca-forge.github.io/MsgCenterPy/

示例代码

更多示例请查看 examples/ 目录:

🧪 测试

运行测试

# 运行所有测试
python -m pytest

# 运行特定测试套件
python run_all_tests.py --type json_schema
# 生成覆盖率报告
pytest --cov=msgcenterpy --cov-report=html

🛠️ 开发

开发环境设置

git clone https://github.com/ZGCA-Forge/MsgCenterPy.git
cd MsgCenterPy
pip install -e .[dev]
pre-commit install

代码质量

# 代码格式化
black msgcenterpy tests
isort msgcenterpy tests

# 类型检查
mypy msgcenterpy

# 运行测试
pytest

贡献指南

  1. Fork 项目
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交变更 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 创建 Pull Request

详细贡献指南请查看 CONTRIBUTING.md

📊 开发路线图

  • ROS2 消息支持
  • JSON Schema 生成和验证
  • 统一字段访问器
  • 类型约束系统
  • 🔄 Pydantic 集成
  • 🔄 Dataclass 支持
  • 🔄 YAML 格式支持
  • 🔄 性能优化
  • 🔄 插件系统

🤝 社区

支持渠道

贡献者

感谢所有为 MsgCenterPy 做出贡献的开发者!

Contributors

📄 许可证

本项目基于 Apache-2.0 许可证开源 - 查看 LICENSE 文件了解详情。

🙏 致谢


给个 Star🍴 Fork 项目📖 查看文档

Made with ❤️ by the MsgCenterPy Team

Description
Unified message conversion system supporting ROS2, Pydantic, Dataclass, JSON, YAML, Dict, and MCP schema inter-conversion
Readme Apache-2.0 228 KiB
Languages
Python 96.8%
PowerShell 2%
Shell 1.2%