Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
liuhomewreckers
liu-home-wreckers
Commits
a46ce619
Commit
a46ce619
authored
Jan 24, 2021
by
Daniel Engelsons
Browse files
Microphone Done
parent
9f7bcbfd
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lhw_qi/include/lhw_qi/microphone_component.hpp
View file @
a46ce619
...
...
@@ -22,9 +22,9 @@ namespace lhw_qi
LHW_QI_PUBLIC
explicit
Microphone
(
const
rclcpp
::
NodeOptions
&
options
);
void
initiate
(
qi
::
SessionPtr
session
,
boost
::
shared_ptr
<
Microphone
>
microphone_ptr
);
void
init
iateService
(
void
);
void
init
(
void
);
virtual
~
Microphone
(
void
);
void
process
(
const
int
&
nbOfChannels
,
void
process
Remote
(
const
int
&
nbOfChannels
,
const
int
&
nbrOfSamplesByChannel
,
const
qi
::
AnyValue
&
timestamp
,
const
qi
::
AnyValue
&
buffer
);
...
...
src/lhw_qi/src/microphone_component.cpp
View file @
a46ce619
...
...
@@ -16,7 +16,7 @@ namespace lhw_qi
pub_
=
this
->
create_publisher
<
std_msgs
::
msg
::
Int16
>
(
"microphone_buffer"
,
1000
);
}
QI_REGISTER_MT_OBJECT
(
Microphone
,
init
iateService
,
process
)
QI_REGISTER_MT_OBJECT
(
Microphone
,
init
,
process
Remote
)
Microphone
::~
Microphone
(
void
)
{
...
...
@@ -24,35 +24,37 @@ namespace lhw_qi
listener_
.
call
<
qi
::
AnyValue
>
(
"unsubscribe"
,
"Microphone"
);
}
void
Microphone
::
init
iateService
(
void
)
void
Microphone
::
init
(
void
)
{
listener_
.
call
<
qi
::
AnyValue
>
(
"setClientPreferences"
,
"Microphone"
,
48000
,
0
,
1
);
listener_
.
call
<
qi
::
AnyValue
>
(
"subscribe"
,
"Microphone"
);
}
void
Microphone
::
initiate
(
qi
::
SessionPtr
session
,
boost
::
shared_ptr
<
Microphone
>
microphone_ptr
)
{
session_
=
session
;
RCUTILS_LOG_INFO
(
"timestamp inne i initiate"
);
session_
->
waitForService
(
"ALAudioDevice"
);
RCUTILS_LOG_INFO
(
"initiate2"
);
listener_
=
session_
->
service
(
"ALAudioDevice"
);
session_
->
registerService
(
"Microphone"
,
qi
::
AnyObject
(
microphone_ptr
)
);
RCUTILS_LOG_INFO
(
"initiate3"
);
qi
::
AnyObject
microphone
=
session_
->
service
(
"Microphone"
);
RCUTILS_LOG_INFO
(
"initiate4"
);
microphone
.
call
<
qi
::
AnyValue
>
(
"init
iateService
"
);
RCUTILS_LOG_INFO
(
"initiate5"
);
microphone
.
call
<
qi
::
AnyValue
>
(
"init"
);
}
void
Microphone
::
process
(
const
int
&
nbOfChannels
,
void
Microphone
::
process
Remote
(
const
int
&
nbOfChannels
,
const
int
&
nbrOfSamplesByChannel
,
const
qi
::
AnyValue
&
timestamp
,
const
qi
::
AnyValue
&
buffer
)
{
...
...
@@ -60,7 +62,7 @@ namespace lhw_qi
std
::
pair
<
char
*
,
size_t
>
charBuffer
=
buffer
.
unwrap
().
asRaw
();
//RCUTILS_LOG_INFO("buffer %s", qi::encodeJSON(qibuffer).c_str());
RCUTILS_LOG_INFO
(
"timestamp %s"
,
qi
::
encodeJSON
(
timestamp
).
c_str
());
//
RCUTILS_LOG_INFO("timestamp %s", qi::encodeJSON(timestamp).c_str());
auto
msg
=
std_msgs
::
msg
::
Int16
();
msg
.
data
=
*
(
signed
short
*
)
charBuffer
.
first
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment