-
Notifications
You must be signed in to change notification settings - Fork 390
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from fengqikai1414/master
add image_common, audio_common and vision_opencv, refer to ros-indigo
- Loading branch information
Showing
222 changed files
with
20,554 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
*.pyc |
This file contains 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 @@ | ||
build |
This file contains 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,83 @@ | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
Changelog for package audio_capture | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
0.2.12 (2016-02-29) | ||
------------------- | ||
|
||
0.2.11 (2016-02-16) | ||
------------------- | ||
|
||
0.2.10 (2016-01-21) | ||
------------------- | ||
|
||
0.2.9 (2015-12-02) | ||
------------------ | ||
* [audio_capture] add error handler | ||
* [audio_capture] add option to publish captured audio data as wav format | ||
* Fixed memory leak (see `#18 <https://github.com/ros-drivers/audio_common/issues/18>`_). | ||
* Removed trailing whitespace. | ||
* Contributors: Felix Duvallet, Furushchev | ||
|
||
0.2.8 (2015-10-02) | ||
------------------ | ||
* Update maintainer email | ||
* Contributors: trainman419 | ||
|
||
0.2.7 (2014-07-25) | ||
------------------ | ||
* audio_capture.cpp has to wait for generated AudioData headers | ||
* Contributors: v4hn | ||
|
||
0.2.6 (2014-02-26) | ||
------------------ | ||
* audio_capture and play _require\_ gstreamer, it's not optional | ||
* Contributors: v4hn | ||
|
||
0.2.5 (2014-01-23) | ||
------------------ | ||
* "0.2.5" | ||
* Contributors: trainman419 | ||
|
||
0.2.4 (2013-09-10) | ||
------------------ | ||
* Update CMakeLists.txt | ||
* audio_capture: install launchfiles | ||
* Contributors: David Gossow | ||
|
||
0.2.3 (2013-07-15) | ||
------------------ | ||
* Fix install rule for audio_capture. | ||
* Contributors: Austin Hendrix | ||
|
||
0.2.2 (2013-04-10) | ||
------------------ | ||
|
||
0.2.1 (2013-04-08 13:59) | ||
------------------------ | ||
|
||
0.2.0 (2013-04-08 13:49) | ||
------------------------ | ||
* Finish catkinizing audio_common. | ||
* Catkinize audio_play. | ||
* Catkinize audio_capture. | ||
* Fix typo in package.xml | ||
* Versions and more URLs. | ||
* Convert manifests to package.xml | ||
* Convert audio_capture manifest to package.xml | ||
* Ditch old makefiles. | ||
* Updates manifest | ||
* Updated manifests for rodep2 | ||
* oneiric build fixes, bump version to 0.1.6 | ||
* Removed redundant thread::thread | ||
* Added a rosdep.yaml file | ||
* Fixed to use audio_common_msgs | ||
* Added ability to use different festival voices | ||
* Updated documentation | ||
* Added ability to capture to file | ||
* Fixed ignore files | ||
* Added hgignore files | ||
* Audio_capture and audio_play working | ||
* Making separate audio_capture and audio_play packages | ||
* Moved audio_transport to audio_capture | ||
* Contributors: Austin Hendrix, Brian Gerkey, Nate Koenig, nkoenig |
This file contains 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,24 @@ | ||
cmake_minimum_required(VERSION 2.8.3) | ||
|
||
project(audio_capture) | ||
|
||
find_package(catkin REQUIRED COMPONENTS roscpp audio_common_msgs) | ||
|
||
find_package(PkgConfig) | ||
pkg_check_modules(GST gstreamer-0.10 REQUIRED) | ||
|
||
find_package(Boost REQUIRED COMPONENTS thread) | ||
|
||
include_directories(${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${GST_INCLUDE_DIRS}) | ||
|
||
catkin_package() | ||
|
||
add_executable(audio_capture src/audio_capture.cpp) | ||
target_link_libraries(audio_capture ${catkin_LIBRARIES} ${GST_LIBRARIES} ${Boost_LIBRARIES}) | ||
add_dependencies(audio_capture ${catkin_EXPORTED_TARGETS}) | ||
|
||
install(TARGETS audio_capture | ||
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}) | ||
|
||
install(DIRECTORY launch | ||
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}) |
This file contains 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 name="audio_capture" pkg="audio_capture" type="audio_capture" output="screen"> | ||
<param name="bitrate" value="128"/> | ||
</node> | ||
|
||
</launch> |
This file contains 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,8 @@ | ||
<launch> | ||
|
||
<node name="audio_capture" pkg="audio_capture" type="audio_capture" output="screen"> | ||
<param name="bitrate" value="128"/> | ||
<param name="dst" value="output.mp3"/> | ||
</node> | ||
|
||
</launch> |
This file contains 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,9 @@ | ||
<launch> | ||
<!-- publish audio data as wav format --> | ||
<node name="audio_capture" pkg="audio_capture" type="audio_capture" output="screen"> | ||
<param name="format" value="wave" /> | ||
<param name="channels" value="1" /> | ||
<param name="depth" value="16" /> | ||
<param name="sample_rate" value="16000" /> | ||
</node> | ||
</launch> |
This file contains 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,21 @@ | ||
/** | ||
\mainpage | ||
\htmlinclude manifest.html | ||
|
||
\b audio_capture is a package that records audio from a microphone and makes it available to other ROS nodes. | ||
|
||
\section codeapi Code API | ||
|
||
<!-- | ||
Provide links to specific auto-generated API documentation within your | ||
package that is of particular interest to a reader. Doxygen will | ||
document pretty much every part of your code, so do your best here to | ||
point the reader to the actual API. | ||
|
||
If your codebase is fairly large or has different sets of APIs, you | ||
should use the doxygen 'group' tag to keep these APIs together. For | ||
example, the roscpp documentation has 'libros' group. | ||
--> | ||
|
||
|
||
*/ |
This file contains 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,29 @@ | ||
<package> | ||
<name>audio_capture</name> | ||
<version>0.2.12</version> | ||
<description> | ||
Transports audio from a source to a destination. Audio sources can come | ||
from a microphone or file. The destination can play the audio or save it | ||
to an mp3 file. | ||
</description> | ||
<maintainer email="[email protected]">Austin Hendrix</maintainer> | ||
<author>Nate Koenig</author> | ||
<license>BSD</license> | ||
<url type="website">http://ros.org/wiki/audio_capture</url> | ||
<url type="repository">https://github.com/ros-drivers/audio_common</url> | ||
<url type="bugtracker">https://github.com/ros-drivers/audio_common/issues</url> | ||
|
||
<buildtool_depend>catkin</buildtool_depend> | ||
|
||
<build_depend>roscpp</build_depend> | ||
<build_depend>audio_common_msgs</build_depend> | ||
<build_depend>libgstreamer0.10-dev</build_depend> | ||
<build_depend>libgstreamer-plugins-base0.10-dev</build_depend> | ||
|
||
<run_depend>roscpp</run_depend> | ||
<run_depend>audio_common_msgs</run_depend> | ||
<run_depend>libgstreamer0.10-0</run_depend> | ||
<run_depend>libgstreamer-plugins-base0.10-0</run_depend> | ||
<run_depend>gstreamer0.10-plugins-ugly</run_depend> | ||
<run_depend>gstreamer0.10-plugins-good</run_depend> | ||
</package> |
This file contains 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,186 @@ | ||
#include <stdio.h> | ||
#include <gst/gst.h> | ||
#include <gst/app/gstappsink.h> | ||
#include <boost/thread.hpp> | ||
|
||
#include <ros/ros.h> | ||
|
||
#include "audio_common_msgs/AudioData.h" | ||
|
||
namespace audio_transport | ||
{ | ||
class RosGstCapture | ||
{ | ||
public: | ||
RosGstCapture() | ||
{ | ||
_bitrate = 192; | ||
|
||
std::string dst_type; | ||
|
||
// Need to encoding or publish raw wave data | ||
ros::param::param<std::string>("~format", _format, "mp3"); | ||
|
||
// The bitrate at which to encode the audio | ||
ros::param::param<int>("~bitrate", _bitrate, 192); | ||
|
||
// only available for raw data | ||
ros::param::param<int>("~channels", _channels, 1); | ||
ros::param::param<int>("~depth", _depth, 16); | ||
ros::param::param<int>("~sample_rate", _sample_rate, 16000); | ||
|
||
// The destination of the audio | ||
ros::param::param<std::string>("~dst", dst_type, "appsink"); | ||
|
||
// The source of the audio | ||
//ros::param::param<std::string>("~src", source_type, "alsasrc"); | ||
|
||
_pub = _nh.advertise<audio_common_msgs::AudioData>("audio", 10, true); | ||
|
||
_loop = g_main_loop_new(NULL, false); | ||
_pipeline = gst_pipeline_new("ros_pipeline"); | ||
_bus = gst_pipeline_get_bus(GST_PIPELINE(_pipeline)); | ||
gst_bus_add_signal_watch(_bus); | ||
g_signal_connect(_bus, "message::error", | ||
G_CALLBACK(onMessage), this); | ||
g_object_unref(_bus); | ||
|
||
// We create the sink first, just for convenience | ||
if (dst_type == "appsink") | ||
{ | ||
_sink = gst_element_factory_make("appsink", "sink"); | ||
g_object_set(G_OBJECT(_sink), "emit-signals", true, NULL); | ||
g_object_set(G_OBJECT(_sink), "max-buffers", 100, NULL); | ||
g_signal_connect( G_OBJECT(_sink), "new-buffer", | ||
G_CALLBACK(onNewBuffer), this); | ||
} | ||
else | ||
{ | ||
printf("file sink\n"); | ||
_sink = gst_element_factory_make("filesink", "sink"); | ||
g_object_set( G_OBJECT(_sink), "location", dst_type.c_str(), NULL); | ||
} | ||
|
||
_source = gst_element_factory_make("alsasrc", "source"); | ||
_convert = gst_element_factory_make("audioconvert", "convert"); | ||
|
||
gboolean link_ok; | ||
|
||
if (_format == "mp3"){ | ||
_encode = gst_element_factory_make("lame", "encoder"); | ||
g_object_set( G_OBJECT(_encode), "preset", 1001, NULL); | ||
g_object_set( G_OBJECT(_encode), "bitrate", _bitrate, NULL); | ||
|
||
gst_bin_add_many( GST_BIN(_pipeline), _source, _convert, _encode, _sink, NULL); | ||
link_ok = gst_element_link_many(_source, _convert, _encode, _sink, NULL); | ||
} else if (_format == "wave") { | ||
GstCaps *caps; | ||
caps = gst_caps_new_simple("audio/x-raw-int", | ||
"channels", G_TYPE_INT, _channels, | ||
"width", G_TYPE_INT, _depth, | ||
"depth", G_TYPE_INT, _depth, | ||
"rate", G_TYPE_INT, _sample_rate, | ||
"signed", G_TYPE_BOOLEAN, TRUE, | ||
NULL); | ||
|
||
g_object_set( G_OBJECT(_sink), "caps", caps, NULL); | ||
gst_caps_unref(caps); | ||
gst_bin_add_many( GST_BIN(_pipeline), _source, _sink, NULL); | ||
link_ok = gst_element_link_many( _source, _sink, NULL); | ||
} else { | ||
ROS_ERROR_STREAM("format must be \"wave\" or \"mp3\""); | ||
exitOnMainThread(1); | ||
} | ||
/*} | ||
else | ||
{ | ||
_sleep_time = 10000; | ||
_source = gst_element_factory_make("filesrc", "source"); | ||
g_object_set(G_OBJECT(_source), "location", source_type.c_str(), NULL); | ||
gst_bin_add_many( GST_BIN(_pipeline), _source, _sink, NULL); | ||
gst_element_link_many(_source, _sink, NULL); | ||
} | ||
*/ | ||
|
||
if (!link_ok) { | ||
ROS_ERROR_STREAM("Unsupported media type."); | ||
exitOnMainThread(1); | ||
} | ||
|
||
gst_element_set_state(GST_ELEMENT(_pipeline), GST_STATE_PLAYING); | ||
|
||
_gst_thread = boost::thread( boost::bind(g_main_loop_run, _loop) ); | ||
} | ||
|
||
~RosGstCapture() | ||
{ | ||
g_main_loop_quit(_loop); | ||
gst_element_set_state(_pipeline, GST_STATE_NULL); | ||
gst_object_unref(_pipeline); | ||
g_main_loop_unref(_loop); | ||
} | ||
|
||
void exitOnMainThread(int code) | ||
{ | ||
exit(code); | ||
} | ||
|
||
void publish( const audio_common_msgs::AudioData &msg ) | ||
{ | ||
_pub.publish(msg); | ||
} | ||
|
||
static GstFlowReturn onNewBuffer (GstAppSink *appsink, gpointer userData) | ||
{ | ||
RosGstCapture *server = reinterpret_cast<RosGstCapture*>(userData); | ||
|
||
GstBuffer *buffer; | ||
g_signal_emit_by_name(appsink, "pull-buffer", &buffer); | ||
|
||
audio_common_msgs::AudioData msg; | ||
msg.data.resize( buffer->size ); | ||
memcpy( &msg.data[0], buffer->data, buffer->size); | ||
|
||
server->publish(msg); | ||
|
||
return GST_FLOW_OK; | ||
} | ||
|
||
static gboolean onMessage (GstBus *bus, GstMessage *message, gpointer userData) | ||
{ | ||
RosGstCapture *server = reinterpret_cast<RosGstCapture*>(userData); | ||
GError *err; | ||
gchar *debug; | ||
|
||
gst_message_parse_error(message, &err, &debug); | ||
ROS_ERROR_STREAM("gstreamer: " << err->message); | ||
g_error_free(err); | ||
g_free(debug); | ||
g_main_loop_quit(server->_loop); | ||
server->exitOnMainThread(1); | ||
return FALSE; | ||
} | ||
|
||
private: | ||
ros::NodeHandle _nh; | ||
ros::Publisher _pub; | ||
|
||
boost::thread _gst_thread; | ||
|
||
GstElement *_pipeline, *_source, *_sink, *_convert, *_encode; | ||
GstBus *_bus; | ||
int _bitrate, _channels, _depth, _sample_rate; | ||
GMainLoop *_loop; | ||
std::string _format; | ||
}; | ||
} | ||
|
||
int main (int argc, char **argv) | ||
{ | ||
ros::init(argc, argv, "audio_capture"); | ||
gst_init(&argc, &argv); | ||
|
||
audio_transport::RosGstCapture server; | ||
ros::spin(); | ||
} |
Oops, something went wrong.