Skip to content

Commit

Permalink
Merge pull request #121 from brendandburns/patch
Browse files Browse the repository at this point in the history
Fix rosboard for unknown qos.
  • Loading branch information
dheera authored Jun 20, 2024
2 parents 2f034e5 + def5758 commit dc169eb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion rosboard/rosboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import rospy # ROS1
elif os.environ.get("ROS_VERSION") == "2":
import rosboard.rospy2 as rospy # ROS2
from rclpy.qos import QoSProfile, QoSReliabilityPolicy, QoSDurabilityPolicy
from rclpy.qos import HistoryPolicy, QoSProfile, QoSReliabilityPolicy, QoSDurabilityPolicy
else:
print("ROS not detected. Please source your ROS environment\n(e.g. 'source /opt/ros/DISTRO/setup.bash')")
exit(1)
Expand Down Expand Up @@ -134,6 +134,8 @@ def get_topic_qos(self, topic_name: str) -> QoSProfile:
if rospy.__name__ == "rospy2":
topic_info = rospy._node.get_publishers_info_by_topic(topic_name=topic_name)
if len(topic_info):
if topic_info[0].qos_profile.history == HistoryPolicy.UNKNOWN:
topic_info[0].qos_profile.history = HistoryPolicy.KEEP_LAST
return topic_info[0].qos_profile
else:
rospy.logwarn(f"No publishers available for topic {topic_name}. Returning sensor data QoS")
Expand Down

0 comments on commit dc169eb

Please sign in to comment.