-
Notifications
You must be signed in to change notification settings - Fork 41
(color_extractor) Create a node listener and call service #228
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a first good step. Though the current implementation does create a service client on each image. This is very inefficient. Please change it to a class, i.e. https://github.com/tue-robotics/hero_bringup/blob/aadf90641a2517e71c790ceb2e7c00d14a865a80/scripts/gazebo_pose_setter
And make sure to add the new script to be executable and add it to the list of scripts to be installed, (keep the list alphabetical) As right now catkin_lint is complaining... |
class ExtractColorClient(object): | ||
def __init__(self, image_topic, color_service): | ||
self.image_sub = rospy.Subscriber(image_topic, Image, self.color_callback) | ||
self.color_proxy = rospy.ServiceProxy(color_service, Recognize) | ||
self.color_proxy.wait_for_service(timeout=20) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class ExtractColorClient(object): | |
def __init__(self, image_topic, color_service): | |
self.image_sub = rospy.Subscriber(image_topic, Image, self.color_callback) | |
self.color_proxy = rospy.ServiceProxy(color_service, Recognize) | |
self.color_proxy.wait_for_service(timeout=20) | |
class ExtractColorClient: | |
def __init__(self, image_topic, color_service): | |
self.color_proxy = rospy.ServiceProxy(color_service, Recognize) | |
self.color_proxy.wait_for_service(timeout=20) | |
self.image_sub = rospy.Subscriber(image_topic, Image, self.color_callback) |
As the subscriber will start immediately, but the service client will not be ready yet. So that could lead to an error.
parser.add_argument('--topic', default='/image', type=str, help='Topic') | ||
args = parser.parse_args() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add an argument for the service
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe good to let rospy filter the ros args
parser.add_argument('--topic', default='/image', type=str, help='Topic') | |
args = parser.parse_args() | |
parser.add_argument('--topic', default='/image', type=str, help='Topic') | |
args = parser.parse_args(rospy.myargv()) |
I want to receive the messages from /pose_estimation node. Then, I will try to crop an specific part of the image (for example: head or chest) to call the service to extract the color.