0
$\begingroup$

Rosanswers logo

Hi I have tried various code snippets but have not been able to create correct code for sensor QOS definition for a service I am writing in python

    self.speed_subscription = self.create_subscription(
        Int32,
        'distance',
        self.speed_listener_callback,1)
        # self.listener_callback,rmw_qos_profile_sensor_data)

So I like to replace the 1 with sensor profile for QOS

Any hints is appreciated


Originally posted by maxbback on ROS Answers with karma: 11 on 2020-08-31

Post score: 1

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

from rclpy import qos
self.speed_subscription = self.create_subscription(
    Int32,
    'distance',
    self.speed_listener_callback,qos.qos_profile_sensor_data)

Originally posted by doronhi with karma: 31 on 2021-01-05

This answer was NOT ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

I've pull this from my code I use to get images from the RS camera (which requires a non-default QoS policy).

from rclpy.node import Node
from rclpy.qos import QoSProfile, QoSReliabilityPolicy, QoSHistoryPolicy

class MyNode(Node):
    def __init__(self):
        qos_profile = QoSProfile(
            reliability=QoSReliabilityPolicy.RMW_QOS_POLICY_RELIABILITY_BEST_EFFORT,
            history=QoSHistoryPolicy.RMW_QOS_POLICY_HISTORY_KEEP_LAST,
            depth=1
        )

        sub = Subscriber(
            self,
            Image,
            "rgb_img",
            qos_profile=qos_profile
        )
        sub.registerCallback(self._on_rgb)

    def _on_rgb(self, msg):
        ...

Originally posted by SmallJoeMan with karma: 116 on 2021-01-05

This answer was NOT ACCEPTED on the original site

Post score: 3

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.