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
[audio_to_spectrogram] Enable publishing frequency vs amplitude plot #2654
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.
Thank you very much for the nice feature!
I think it would be helpful to publish spectrum plot as sensor_msgs/Image
.
Please consider about my reviews.
@@ -35,10 +57,16 @@ def _cb(self, msg): | |||
self.ax.set_xlim((self.freq.min(), self.freq.max())) | |||
self.ax.set_ylim((0.0, 20)) | |||
self.ax.legend(loc='upper right') | |||
print(self.pub_img.get_num_connections()) |
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.
You may forget to remove this line?
If you need this line, rospy.loginfo
or rospy.logdebug
seems better.
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.
Thanks. I forgot to remove the debug print.
Fixed.
@@ -35,10 +57,16 @@ def _cb(self, msg): | |||
self.ax.set_xlim((self.freq.min(), self.freq.max())) | |||
self.ax.set_ylim((0.0, 20)) | |||
self.ax.legend(loc='upper right') | |||
print(self.pub_img.get_num_connections()) | |||
if self.pub_img.get_num_connections() > 0: |
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.
How about using ConnectionBasedTransport
?
https://jsk-docs.readthedocs.io/projects/jsk_common/en/latest/jsk_topic_tools/class/python_connection_based_transport.html
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.
That's good idea, thanks. I modified the code. 2e86235
self.sub_spectrum = rospy.Subscriber( | ||
'~spectrum', Spectrum, self._cb, queue_size=1000) | ||
|
||
def unsupported(self): |
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.
Typo: unsubscribe?
Traceback (most recent call last):
File "/home/leus/ros/melodic/src/jsk-ros-pkg/jsk_recognition/audio_to_spectrogram/scripts/spectrum_plot.py", line 77, in <module>
SpectrumPlot()
File "/home/leus/ros/melodic/src/jsk-ros-pkg/jsk_common/jsk_topic_tools/src/jsk_topic_tools/transport.py", line 26, in __call__
obj = type.__call__(cls, *args, **kwargs)
TypeError: Can't instantiate abstract class SpectrumPlot with abstract methods unsubscribe
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.
Sorry, I was wrong. Fixed. 4fa0c14
I am sorry for the many comments, but the last thing. How about moving these lines to outside of
This is because the new |
Don't worry about it. That's a good idea. Modified 6cd009c |
Thank you so much! I think this PR is OK to be merged after tests pass. |
@iory please add plotted graph image on this comment thread or document |
1f390c6
to
c57662c
Compare
I added the image in the README.md. |
9ea3974
to
bf7c688
Compare
What is this?
This PR enables publishing frequency vs amplitude plot images in
spectrum_plot.py
.