Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions mrobosub_perception/launch/perception.launch
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<launch>
<include file="$(find mrobosub_perception)/launch/ml_executor_launch.xml" />
<include file="$(find mrobosub_perception)/launch/ml_srv_launch.xml" />
<include file="$(find mrobosub_perception)/launch/pathmarker_hsv_launch.xml" />
<!-- <include file="$(find mrobosub_perception)/launch/buoy_hsv.launch" /> -->
<include file="$(find mrobosub_perception)/launch/bin_hsv_launch.xml" />
<include file="$(find-pkg-share mrobosub_perception)/launch/ml_executor_launch.xml" />
<include file="$(find-pkg-share mrobosub_perception)/launch/ml_srv_launch.xml" />
<include file="$(find-pkg-share mrobosub_perception)/launch/pathmarker_hsv_launch.xml" />
<include file="$(find-pkg-share mrobosub_perception)/launch/bin_hsv_launch.xml" />
</launch>
7 changes: 0 additions & 7 deletions mrobosub_perception/launch/perception_sim.launch

This file was deleted.

5 changes: 5 additions & 0 deletions mrobosub_perception/launch/perception_sim_launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<launch>
<include file="$(find-pkg-share mrobosub_perception)/launch/ml_srv_launch.xml" />
<include file="$(find-pkg-share mrobosub_perception)/launch/pathmarker_hsv_launch.xml" />
<include file="$(find-pkg-share mrobosub_perception)/launch/bin_hsv_launch.xml" />
</launch>
3 changes: 3 additions & 0 deletions mrobosub_perception/launch/png_pub_launch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<launch>
<node name="png_pub" pkg="mrobosub_perception" exec="png_pub"/>
</launch>
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<launch>
<node
<!-- <node
pkg="mrobosub_perception"
type="webcam_pub.py"
exec="webcam_pub"
name="webcam_pub"
output="screen"
/>
/> -->
<node
pkg="mrobosub_perception"
type="hsv_tuner.py"
exec="hsv_tuner"
name="hsv_tuner"
output="screen"
>
Expand Down
Binary file added mrobosub_perception/mrobosub_perception/bbox.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions mrobosub_perception/mrobosub_perception/bin_hsv.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,12 @@

from cv_bridge import CvBridge
import rclpy
from rclpy import utilities
from rclpy.node import Node
from mrobosub_lib import Node
from mrobosub_msgs.srv import ObjectPosition
from mrobosub_perception.timed_service import TimedService
from sensor_msgs.msg import Image

from mrobosub_perception.hsv_pipeline import HsvPipeline
from hsv_pipeline import HsvPipeline

def pixels_to_angles(frame, x_pos: int, y_pos: int, fov_x=110, fov_y=70) -> Tuple[int, int]:
height, width = frame.shape[0:2]
Expand Down
54 changes: 26 additions & 28 deletions mrobosub_perception/mrobosub_perception/png_pub.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,38 @@
#!/usr/bin/env python

import rospy # Python library for ROS
import rclpy
from sensor_msgs.msg import Image # Image is the message type
import cv2 # OpenCV library
from cv_bridge import CvBridge # Package to convert between ROS and OpenCV Images
from mrobosub_lib import Node
import os

def publish_message():
class PngPub(Node):
def __init__(self):
super().__init__("png_pub")
# Node is publishing to the video_frames topic using the message type Image
self.pub = self.create_publisher(Image, '/zed2/zed_node/rgb/image_rect_color', qos_profile=10)

# Node is publishing to the video_frames topic using
# the message type Image
pub = rospy.Publisher('/zed2/zed_node/rgb/image_rect_color', Image, queue_size=10)
current_dir = os.path.dirname(os.path.realpath(__file__))
img_path = os.path.join(current_dir, "bbox.png")
self.img = cv2.imread(img_path)
if self.img is None:
print("Error: image not found!")
# when I run this, this input is currently "not a numpy array"
# but we can think about the processing here once we actually have an image we wanna publish

rospy.init_node('png_pub_py', anonymous=True)
#cap.set(cv2.CAP_PROP_EXPOSURE, -8)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#cap.set(cv2.CAP_PROP_EXPOSURE, -8)


# Go through the loop 10 times per second
rate = rospy.Rate(10) # 10hz
# Used to convert between ROS and OpenCV images
self.br = CvBridge()
self.timer = self.create_timer(0.1, self.publish_message) # Go through the loop 10 times per second

# Create a VideoCapture object
# The argument '0' gets the default webcam.
img = cv2.imread("./bbox.png")
#cap.set(cv2.CAP_PROP_EXPOSURE, -8)
def publish_message(self):
self.pub.publish(self.br.cv2_to_imgmsg(self.img, encoding='bgr8'))

# Used to convert between ROS and OpenCV images
br = CvBridge()

#print(type(img))

# While ROS is still running.
while not rospy.is_shutdown():
pub.publish(br.cv2_to_imgmsg(img, encoding='bgr8'))

# Sleep just enough to maintain the desired rate
rate.sleep()
def main():
rclpy.init()
node = PngPub()
rclpy.spin(node)

if __name__ == '__main__':
try:
publish_message()
except rospy.ROSInterruptException as e:
raise e
main()
1 change: 1 addition & 0 deletions mrobosub_perception/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
'pathmarker_hsv= mrobosub_perception.pathmarker_hsv:main',
'ml_executor = mrobosub_perception.ml_executor:main',
'ml_srv = mrobosub_perception.ml_srv:main',
'png_pub = mrobosub_perception.png_pub:main'
],
},
)