ltcodecs
Advanced tools
+5
-1
| Metadata-Version: 2.1 | ||
| Name: ltcodecs | ||
| Version: 2.0.1 | ||
| Version: 3.0.0 | ||
| Summary: LT Codecs | ||
@@ -19,2 +19,6 @@ Home-page: https://git.whoi.edu/acomms/ltcodec/ | ||
| [](https://git.whoi.edu/acomms/ltcodec/-/commits/master) | ||
| [](https://git.whoi.edu/acomms/ltcodec/-/commits/master) | ||
| [](https://git.whoi.edu/acomms/ltcodec/-/releases) | ||
| Flexible, lightweight codec system for transferring messages over acoustic and other low-throughput links. | ||
@@ -21,0 +25,0 @@ |
+4
-0
| # LT Codecs | ||
| [](https://git.whoi.edu/acomms/ltcodec/-/commits/master) | ||
| [](https://git.whoi.edu/acomms/ltcodec/-/commits/master) | ||
| [](https://git.whoi.edu/acomms/ltcodec/-/releases) | ||
| Flexible, lightweight codec system for transferring messages over acoustic and other low-throughput links. | ||
@@ -4,0 +8,0 @@ |
+1
-1
| [metadata] | ||
| name = ltcodecs | ||
| version = 2.0.1 | ||
| version = 3.0.0 | ||
| author = whoi | ||
@@ -5,0 +5,0 @@ author_email = egallimore@whoi.edu |
| Metadata-Version: 2.1 | ||
| Name: ltcodecs | ||
| Version: 2.0.1 | ||
| Version: 3.0.0 | ||
| Summary: LT Codecs | ||
@@ -19,2 +19,6 @@ Home-page: https://git.whoi.edu/acomms/ltcodec/ | ||
| [](https://git.whoi.edu/acomms/ltcodec/-/commits/master) | ||
| [](https://git.whoi.edu/acomms/ltcodec/-/commits/master) | ||
| [](https://git.whoi.edu/acomms/ltcodec/-/releases) | ||
| Flexible, lightweight codec system for transferring messages over acoustic and other low-throughput links. | ||
@@ -21,0 +25,0 @@ |
@@ -9,3 +9,3 @@ """ | ||
| from __future__ import annotations | ||
| from typing import Any | ||
| from typing import Any, Union | ||
| import ltcodecs as ltcodecs | ||
@@ -19,2 +19,5 @@ import msgpack | ||
| import rospy | ||
| from genpy import Message | ||
| from rospy_yaml_include.yaml_include import RospyYamlInclude | ||
| import yaml | ||
@@ -27,3 +30,3 @@ | ||
| def __init__(self, ros_type, fields_dict: dict = None, checksum=None): | ||
| def __init__(self, ros_type: Union[Message, str], fields_dict: dict = None, checksum=None): | ||
| self.ros_type = ros_type | ||
@@ -138,1 +141,8 @@ self.packet_codec = None | ||
| return self.root_field_codec.min_length_bits + checksum_len | ||
| @classmethod | ||
| def from_codec_file(cls, ros_type: Union[type, str], msg_codec_file_path: str, codec_include_directory: str = None) -> "ROSMessageCodec": | ||
| constructor = RospyYamlInclude(base_directory=codec_include_directory) | ||
| with open(msg_codec_file_path, 'r') as f: | ||
| codec_fields = yaml.load(f, Loader=constructor.add_constructor()) | ||
| return cls(ros_type=ros_type, fields_dict=codec_fields) |
@@ -13,3 +13,3 @@ """ | ||
| from rospy import AnyMsg | ||
| from genpy import Message | ||
| from typing import Union, Any | ||
@@ -31,3 +31,3 @@ import roslib.message | ||
| def __init__( | ||
| self, ros_type: Union[str, AnyMsg], fields: dict = None, **kwargs | ||
| self, ros_type: Union[str, Message], fields: dict = None, **kwargs | ||
| ) -> None: | ||
@@ -110,3 +110,3 @@ self.fields = fields | ||
| def encode(self, message: AnyMsg, metadata=None) -> tuple[BitArray, dict[Any]]: | ||
| def encode(self, message: Message, metadata=None) -> tuple[BitArray, dict[Any]]: | ||
| """ | ||
@@ -143,3 +143,3 @@ encode a ROS message | ||
| def decode(self, bits_to_decode: ConstBitStream, metadata=None) -> AnyMsg: | ||
| def decode(self, bits_to_decode: ConstBitStream, metadata=None) -> Message: | ||
| """ | ||
@@ -146,0 +146,0 @@ decode a ROS message |
+19
-1
@@ -6,2 +6,3 @@ #!/usr/bin/env python3 | ||
| """ | ||
| import os | ||
| import time | ||
@@ -408,4 +409,21 @@ import sys | ||
| def test_ros_message_codec_from_yaml(self) -> None: | ||
| """test functionality of the ros message codec""" | ||
| msg = String() | ||
| msg.data = "test" | ||
| codec_file_path = os.path.dirname(__file__) + "/string_msg_codec.yaml" | ||
| codec = ltcodecs.RosMessageCodec.from_codec_file("std_msgs/String", codec_file_path) | ||
| encoded_msg = codec.encode(msg) | ||
| bit_stream = ConstBitStream(encoded_msg[0]) | ||
| decoded_msg = codec.decode(bit_stream) | ||
| pytest.approx(decoded_msg, msg) | ||
| if __name__ == "__main__": | ||
| sys.exit(pytest.main(['--capture=no', __file__])) | ||
| sys.exit(pytest.main(['--capture=no', '--junitxml=results.xml', '--cov=ltcodecs', '--cov-report=xml', '--cov-report=term', __file__])) |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
84848
2.93%1787
1.13%