-
Notifications
You must be signed in to change notification settings - Fork 3
png_pub.py works now #128
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
png_pub.py works now #128
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> |
8 changes: 4 additions & 4 deletions
8
mrobosub_perception/launch/tuner.launch → mrobosub_perception/launch/tuner_launch.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) | ||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
|
|
||||
| # 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() | ||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.