Skip to content

Commit

Permalink
made some corrections to mil_tools
Browse files Browse the repository at this point in the history
  • Loading branch information
anvitD authored and anvitD committed Apr 17, 2024
1 parent bfee1ad commit 271a761
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 13 deletions.
18 changes: 10 additions & 8 deletions mil_common/utils/mil_tools/mil_ros_tools/image_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,16 @@ def get_parameter_range(parameter_root: str):
"""
low_param, high_param = parameter_root + "/hsv_low", parameter_root + "/hsv_high"

rclpy.logwarn(f"Blocking -- waiting for parameters {low_param} and {high_param}")
Node.get_logger().warn(
f"Blocking -- waiting for parameters {low_param} and {high_param}",
)

wait_for_param(low_param)
wait_for_param(high_param)
low = Node.declare_parameter(low_param)
high = Node.declare_parameter(high_param)

Node.get_logger.info()(f"Got {low_param} and {high_param}")
Node.get_logger().info()(f"Got {low_param} and {high_param}")
return np.array([low, high]).transpose()


Expand Down Expand Up @@ -82,7 +84,7 @@ def publish(self, cv_image: np.ndarray):
self.im_pub.publish(image_message)
except CvBridgeError as e:
# Intentionally absorb CvBridge Errors
rclpy.logerr(str(e))
self.get_logger().warn(str(e))


class Image_Subscriber:
Expand Down Expand Up @@ -142,7 +144,7 @@ def wait_for_camera_info(self, timeout: int = 10):
Raises:
Exception: No camera info was found after the timeout had finished.
"""
rclpy.logwarn(
self.get_logger().warn(
"Blocking -- waiting at most %d seconds for camera info." % timeout,
)

Expand All @@ -152,11 +154,11 @@ def wait_for_camera_info(self, timeout: int = 10):

while (rclpy.Time.now() - start_time < timeout) and (not rclpy.is_shutdown()):
if self.camera_info is not None:
rclpy.loginfo("Camera info found!")
self.get_logger().info("Camera info found!")
return self.camera_info
rclpy.sleep(0.2)

rclpy.logerr("Camera info not found.")
self.get_logger().warn("Camera info not found.")
raise Exception("Camera info not found.")

def wait_for_camera_model(self, **kwargs):
Expand Down Expand Up @@ -204,7 +206,7 @@ def convert(self, data: Image):
self.callback(image)
except CvBridgeError as e:
# Intentionally absorb CvBridge Errors
rclpy.logerr(e)
self.get_logger().warn(e)


class StereoImageSubscriber:
Expand Down Expand Up @@ -377,4 +379,4 @@ def _image_callback(self, left_img: Image, right_img: Image):
self.callback(img_left, img_right)
except CvBridgeError as e:
# Intentionally absorb CvBridge Errors
rclpy.logerr(e)
self.get_logger().warn(e)
2 changes: 1 addition & 1 deletion mil_common/utils/mil_tools/mil_ros_tools/init_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,5 @@ def wait_for_service(
except rclpy.ROSException:
if timeout is not None:
timeout = timeout - warn_time
rclpy.logwarn(warn_msg)
Node.get_logger().warm(warn_msg)
service.wait_for_service(timeout)
2 changes: 1 addition & 1 deletion mil_common/utils/mil_tools/mil_ros_tools/mag_to_marker.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def publish(self, vec: MagneticField):
if self.length is not None:
norm = np.linalg.norm(vec)
if norm == 0:
rclpy.logwarn("Zero vector received, skipping")
self.get_logger().warn("Zero vector received, skipping")
return
vec = (self.length / norm) * vec
marker.points.append(numpy_to_point(vec))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def publish(self, vec):
if self.length is not None:
norm = np.linalg.norm(vec)
if norm == 0:
rclpy.logwarn("Zero vector received, skipping")
self.get_logger().warn("Zero vector received, skipping")
return
vec = (self.length / norm) * vec
marker.points.append(numpy_to_point(vec))
Expand Down
2 changes: 1 addition & 1 deletion mil_common/utils/mil_tools/nodes/network_broadcaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self):
hz = self.declare_parameter("~hz", 20)
topic = self.declare_parameter("~topic", "network")

rclpy.loginfo(f"NETWORK BROADCASTER: publishing to {topic} at {hz}hz")
self.get_logger().info(f"NETWORK BROADCASTER: publishing to {topic} at {hz}hz")
self.msg = Header()
self.msg.seq = 0
self.num_connections = -1
Expand Down
2 changes: 1 addition & 1 deletion mil_common/utils/mil_tools/nodes/online_bagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def __init__(self):
self.streaming = True
self.get_params()
if len(self.subscriber_list) == 0:
rclpy.logwarn("No topics selected to subscribe to. Closing.")
self.get_logger().warn("No topics selected to subscribe to. Closing.")
rclpy.signal_shutdown("No topics to subscribe to")
return
self.make_dicts()
Expand Down

0 comments on commit 271a761

Please sign in to comment.