-
Notifications
You must be signed in to change notification settings - Fork 81
[audio_video_recorder] Add audio_video_recorder_server and client library to audio_video_recorder #1704
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
Open
sktometometo
wants to merge
13
commits into
jsk-ros-pkg:master
Choose a base branch
from
sktometometo:PR/add-audio-video-recorder-server
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[audio_video_recorder] Add audio_video_recorder_server and client library to audio_video_recorder #1704
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
1508a5c
[audio_video_recorder_server] add audio_video_recorder package
sktometometo aef6141
[audio_video_recorder_server] update
sktometometo c2cb8a3
[audio_video_recorder_server] fix bugs and add demo
sktometometo 5e43c71
[audio_video_recorder_server] add README
sktometometo 7b636f4
[audio_video_recorder] make node name of audio_video_recorder anounymous
sktometometo 163e42d
[audio_video_recorder][audio_video_recorder_server] merge audio_video…
sktometometo 5e8f8e5
[audio_video_recorder] Add installation for node_scripts
sktometometo f4a3ea1
[audio_video_recorder] update README.md
sktometometo 3b5928a
[audio_video_recorder_server] remove audio_video_recorder_server package
sktometometo 5a6071d
[audio_video_recorder] fix module import
sktometometo a4de30b
[audio_video_recorder] add euslisp client
sktometometo e285222
[audio_video_recorder] update CMakeLists.txt
sktometometo 80b0286
Merge branch 'master' into PR/add-audio-video-recorder-server
k-okada 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
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
7 changes: 7 additions & 0 deletions
7
audio_video_recorder/launch/audio_video_recorder_server.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,7 @@ | ||
<launch> | ||
<node | ||
pkg="audio_video_recorder" | ||
type="audio_video_recorder_server" | ||
name="audio_video_recorder_server" | ||
/> | ||
</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,14 @@ | ||
string audio_topic_name | ||
string image_topic_name | ||
int32 queue_size | ||
string file_name # This will be used as key | ||
string file_format | ||
string audio_format | ||
string audio_sample_format | ||
int32 audio_channels | ||
int32 audio_depth | ||
int32 audio_sample_rate | ||
string video_encoding | ||
int32 video_height | ||
int32 video_width | ||
int32 video_framerate |
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 @@ | ||
audio_video_recorder/RecordTask[] array |
16 changes: 16 additions & 0 deletions
16
audio_video_recorder/node_scripts/audio_video_recorder_server
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,16 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- | ||
|
||
import rospy | ||
from audio_video_recorder.audio_video_recorder_server import AudioVideoRecorderServer | ||
|
||
|
||
def main(): | ||
|
||
rospy.init_node('audio_video_recorder_server') | ||
server = AudioVideoRecorderServer() | ||
server.spin() | ||
|
||
|
||
if __name__=='__main__': | ||
main() |
38 changes: 38 additions & 0 deletions
38
audio_video_recorder/node_scripts/sample_audio_video_recorder_client.py
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,38 @@ | ||
#!/usr/bin/env python | ||
# -*- encoding: utf-8 -*- | ||
|
||
import rospy | ||
from audio_video_recorder.audio_video_recorder_client import AudioVideoRecorderClient | ||
from sensor_msgs.msg import Image | ||
from audio_common_msgs.msg import AudioData | ||
|
||
|
||
def main(): | ||
|
||
rospy.init_node('audio_video_recorder_client_demo') | ||
|
||
destination = rospy.get_param('~destination','/tmp/') | ||
file_name_01 = destination + 'audio_video_recorder_server_demo_01.avi' | ||
file_name_02 = destination + 'audio_video_recorder_server_demo_02.avi' | ||
|
||
try: | ||
msg_image = rospy.wait_for_message('/usb_cam_node/image_raw', Image, timeout=rospy.Duration(10)) | ||
msg_audio = rospy.wait_for_message('/audio', AudioData, timeout=rospy.Duration(10)) | ||
except rospy.ROSException as e: | ||
rospy.logerr(e) | ||
return | ||
|
||
client = AudioVideoRecorderClient() | ||
rospy.loginfo('Start recording') | ||
client.start_record('/audio','/usb_cam_node/image_raw',file_name_01,30) | ||
rospy.sleep(5) | ||
client.start_record('/audio','/usb_cam_node/image_raw',file_name_02,30) | ||
rospy.sleep(5) | ||
rospy.loginfo('Stop recording') | ||
client.stop_record(file_name_01) | ||
rospy.sleep(5) | ||
client.stop_record(file_name_02) | ||
|
||
|
||
if __name__ == '__main__': | ||
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
37 changes: 37 additions & 0 deletions
37
audio_video_recorder/sample/sample_audio_video_recorder_server.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,37 @@ | ||
<launch> | ||
<node pkg="audio_capture" type="audio_capture" name="audio_capture" output="log"> | ||
<rosparam subst_value="true"> | ||
bitrate: 128 | ||
device: "" | ||
channels: 1 | ||
sample_rate: 16000 | ||
format: mp3 | ||
sample_format: S16LE | ||
</rosparam> | ||
</node> | ||
|
||
<node name="usb_cam_node" pkg="usb_cam" type="usb_cam_node" output="log"> | ||
<rosparam subst_value="true"> | ||
pixel_format: yuyv | ||
image_height: 480 | ||
image_width: 640 | ||
framerate: 30 | ||
</rosparam> | ||
</node> | ||
|
||
<node | ||
pkg="audio_video_recorder" | ||
type="audio_video_recorder_server" | ||
name="audio_video_recorder_server" | ||
output="screen" | ||
/> | ||
|
||
<node | ||
pkg="audio_video_recorder" | ||
type="sample_audio_video_recorder_client.py" | ||
name="sample_audio_video_recorder_client" | ||
required="true" | ||
output="screen" | ||
/> | ||
|
||
</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,10 @@ | ||
from distutils.core import setup | ||
from catkin_pkg.python_setup import generate_distutils_setup | ||
|
||
d = generate_distutils_setup( | ||
packages=['audio_video_recorder'], | ||
scripts=[], | ||
package_dir={'': 'src'} | ||
) | ||
|
||
setup(**d) |
Empty file.
88 changes: 88 additions & 0 deletions
88
audio_video_recorder/src/audio_video_recorder/audio_video_recorder_client.py
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,88 @@ | ||
# -*- encoding: utf-8 -*- | ||
|
||
import rospy | ||
import roslaunch | ||
|
||
from sensor_msgs.msg import Image | ||
from .msg import RecordTask, RecordTaskArray | ||
from .srv import StartRecord, StartRecordRequest, StartRecordResponse | ||
from .srv import StopRecord, StopRecordRequest, StopRecordResponse | ||
|
||
import threading | ||
|
||
|
||
class AudioVideoRecorderClient: | ||
|
||
def __init__(self): | ||
|
||
self.record_task_array = RecordTaskArray() | ||
|
||
self.client_start_record = rospy.ServiceProxy( | ||
'/audio_video_recorder_server/start_record', | ||
StartRecord) | ||
self.client_stop_record = rospy.ServiceProxy( | ||
'/audio_video_recorder_server/stop_record', | ||
StopRecord) | ||
self.sub_record_task_array = rospy.Subscriber( | ||
'/audio_video_recorder_server/record_tasks', | ||
RecordTaskArray, | ||
self.__callback | ||
) | ||
|
||
def __callback(self, msg): | ||
self.record_task_array = msg | ||
|
||
def start_record(self, | ||
audio_topic_name, | ||
image_topic_name, | ||
file_name, | ||
video_framerate, | ||
queue_size=100, | ||
file_format='avi', | ||
audio_format='mp3', | ||
audio_sample_format='S16LE', | ||
audio_channels=1, | ||
audio_depth=16, | ||
audio_sample_rate=16000, | ||
video_encoding='RGB', | ||
video_height=None, | ||
video_width=None | ||
): | ||
# Get width and height from message | ||
if video_height is None or video_width is None: | ||
try: | ||
msg_image = rospy.wait_for_message(image_topic_name,Image,timeout=rospy.Duration(5)) | ||
video_height = msg_image.height | ||
video_width = msg_image.width | ||
except rospy.ROSException as e: | ||
return False, 'Image topic not published.' | ||
# | ||
req = StartRecordRequest() | ||
req.task.audio_topic_name = audio_topic_name | ||
req.task.image_topic_name = image_topic_name | ||
req.task.queue_size = queue_size | ||
req.task.file_name = file_name | ||
req.task.file_format = file_format | ||
req.task.audio_format = audio_format | ||
req.task.audio_sample_format = audio_sample_format | ||
req.task.audio_channels = audio_channels | ||
req.task.audio_depth = audio_depth | ||
req.task.audio_sample_rate = audio_sample_rate | ||
req.task.video_encoding = video_encoding | ||
req.task.video_height = video_height | ||
req.task.video_width = video_width | ||
req.task.video_framerate = video_framerate | ||
# | ||
res = self.client_start_record(req) | ||
return res.success, res.message | ||
|
||
def get_record_task_array(self): | ||
return self.record_task_array | ||
|
||
def stop_record(self, file_name): | ||
# | ||
req = StopRecordRequest() | ||
req.file_name = file_name | ||
# | ||
res = self.client_stop_record(req) | ||
return res.success, res.message |
Oops, something went wrong.
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.