Skip to content
Snippets Groups Projects
Commit 77738d26 authored by Junya Hayashi's avatar Junya Hayashi
Browse files

Fix typo: selialize -> serialize

parent 7185f526
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,7 @@ mqtt_bridge provides a functionality to bridge between ROS and MQTT in bidirecti ...@@ -5,7 +5,7 @@ mqtt_bridge provides a functionality to bridge between ROS and MQTT in bidirecti
## Principle ## Principle
`mqtt_bridge` uses ROS message as its protocol. Messages from ROS are selialized by json (or messagepack) for MQTT, and messages from MQTT are deselialized for ROS topic. So MQTT messages should be ROS message compatible. (We use `rosbridge_library.internal.message_conversion` for message conversion.) `mqtt_bridge` uses ROS message as its protocol. Messages from ROS are serialized by json (or messagepack) for MQTT, and messages from MQTT are deserialized for ROS topic. So MQTT messages should be ROS message compatible. (We use `rosbridge_library.internal.message_conversion` for message conversion.)
This limitation can be overcome by defining custom bridge class, though. This limitation can be overcome by defining custom bridge class, though.
...@@ -114,13 +114,13 @@ See `mqtt_bridge.mqtt_client` for detail. ...@@ -114,13 +114,13 @@ See `mqtt_bridge.mqtt_client` for detail.
If `mqtt/private_path` parameter is set, leading `~/` in MQTT topic path will be replaced by this value. For example, if `mqtt/pivate_path` is set as "device/001", MQTT path "~/value" will be converted to "device/001/value". If `mqtt/private_path` parameter is set, leading `~/` in MQTT topic path will be replaced by this value. For example, if `mqtt/pivate_path` is set as "device/001", MQTT path "~/value" will be converted to "device/001/value".
### selializer and deselializer ### serializer and deserializer
`mqtt_bridge` uses `json` as a selializer in default. But you can also configure other selializers. For example, if you want to use messagepack for selialization, add following configuration. `mqtt_bridge` uses `json` as a serializer in default. But you can also configure other serializers. For example, if you want to use messagepack for serialization, add following configuration.
``` yaml ``` yaml
selializer: msgpack:dumps serializer: msgpack:dumps
deselializer: msgpack:loads deserializer: msgpack:loads
``` ```
### bridges ### bridges
......
...@@ -6,8 +6,8 @@ mqtt: ...@@ -6,8 +6,8 @@ mqtt:
port: 1883 port: 1883
keepalive: 60 keepalive: 60
private_path: device/001 private_path: device/001
selializer: msgpack:dumps serializer: msgpack:dumps
deselializer: msgpack:loads deserializer: msgpack:loads
bridge: bridge:
# ping pong # ping pong
- factory: mqtt_bridge.bridge:RosToMqttBridge - factory: mqtt_bridge.bridge:RosToMqttBridge
......
...@@ -10,15 +10,15 @@ from .mqtt_client import create_private_path_extractor ...@@ -10,15 +10,15 @@ from .mqtt_client import create_private_path_extractor
from .util import lookup_object from .util import lookup_object
def create_config(mqtt_client, selializer, deselializer, mqtt_private_path): def create_config(mqtt_client, serializer, deserializer, mqtt_private_path):
if isinstance(selializer, basestring): if isinstance(serializer, basestring):
selializer = lookup_object(selializer) serializer = lookup_object(serializer)
if isinstance(deselializer, basestring): if isinstance(deserializer, basestring):
deselializer = lookup_object(deselializer) deserializer = lookup_object(deserializer)
private_path_extractor = create_private_path_extractor(mqtt_private_path) private_path_extractor = create_private_path_extractor(mqtt_private_path)
def config(binder): def config(binder):
binder.bind('selializer', selializer) binder.bind('serializer', serializer)
binder.bind('deselializer', deselializer) binder.bind('deserializer', deserializer)
binder.bind(mqtt.Client, mqtt_client) binder.bind(mqtt.Client, mqtt_client)
binder.bind('mqtt_private_path_extractor', private_path_extractor) binder.bind('mqtt_private_path_extractor', private_path_extractor)
return config return config
...@@ -41,13 +41,13 @@ def mqtt_bridge_node(): ...@@ -41,13 +41,13 @@ def mqtt_bridge_node():
mqtt_client_factory = lookup_object(mqtt_client_factory_name) mqtt_client_factory = lookup_object(mqtt_client_factory_name)
mqtt_client = mqtt_client_factory(mqtt_params) mqtt_client = mqtt_client_factory(mqtt_params)
# load serializer and deselializer # load serializer and deserializer
selializer = params.get('selializer', 'json:dumps') serializer = params.get('serializer', 'json:dumps')
deselializer = params.get('deselializer', 'json:loads') deserializer = params.get('deserializer', 'json:loads')
# dependency injection # dependency injection
config = create_config( config = create_config(
mqtt_client, selializer, deselializer, mqtt_private_path) mqtt_client, serializer, deserializer, mqtt_private_path)
inject.configure(config) inject.configure(config)
# configure and connect to MQTT broker # configure and connect to MQTT broker
......
...@@ -38,14 +38,14 @@ class Bridge(object): ...@@ -38,14 +38,14 @@ class Bridge(object):
u""" Bridge base class u""" Bridge base class
:param mqtt.Client _mqtt_client: MQTT client :param mqtt.Client _mqtt_client: MQTT client
:param _selialize: message selialize callable :param _serialize: message serialize callable
:param _deselialize: message deselialize callable :param _deserialize: message deserialize callable
""" """
__metaclass__ = ABCMeta __metaclass__ = ABCMeta
_mqtt_client = inject.attr(mqtt.Client) _mqtt_client = inject.attr(mqtt.Client)
_selialize = inject.attr('selializer') _serialize = inject.attr('serializer')
_deselialize = inject.attr('deselializer') _deserialize = inject.attr('deserializer')
_extract_private_path = inject.attr('mqtt_private_path_extractor') _extract_private_path = inject.attr('mqtt_private_path_extractor')
...@@ -73,7 +73,7 @@ class RosToMqttBridge(Bridge): ...@@ -73,7 +73,7 @@ class RosToMqttBridge(Bridge):
self._last_published = now self._last_published = now
def _publish(self, msg): def _publish(self, msg):
payload = bytearray(self._selialize(extract_values(msg))) payload = bytearray(self._serialize(extract_values(msg)))
self._mqtt_client.publish(topic=self._topic_to, payload=payload) self._mqtt_client.publish(topic=self._topic_to, payload=payload)
...@@ -121,7 +121,7 @@ class MqttToRosBridge(Bridge): ...@@ -121,7 +121,7 @@ class MqttToRosBridge(Bridge):
:param mqtt.Message mqtt_msg: MQTT Message :param mqtt.Message mqtt_msg: MQTT Message
:return rospy.Message: ROS Message :return rospy.Message: ROS Message
""" """
msg_dict = self._deselialize(mqtt_msg.payload) msg_dict = self._deserialize(mqtt_msg.payload)
return populate_instance(msg_dict, self._msg_type()) return populate_instance(msg_dict, self._msg_type())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment