22 m_audioRecorder_interface =
nullptr;
31 driver->
view(m_audioRecorder_interface);
36 if (m_audioRecorder_interface ==
nullptr)
44 return PeriodicThread::start();
50 if (PeriodicThread::isRunning())
52 PeriodicThread::stop();
54 m_audioRecorder_interface =
nullptr;
75 rclcpp::NodeOptions node_options;
76 node_options.allow_undeclared_parameters(
true);
77 node_options.automatically_declare_parameters_from_overrides(
true);
83 if (m_node ==
nullptr) {
87 m_ros2Publisher_status = m_node->create_publisher<std_msgs::msg::Int16MultiArray>(
m_topic_name, 10);
100 if (m_audioRecorder_interface!=
nullptr && m_ros2Publisher_status)
102 if(m_ros2Publisher_status->get_subscription_count()>0)
104 double synchronized_timestamp = 0;
111 m_audioRecorder_interface->
isRecording(isRecording);
113 if (std::isnan(synchronized_timestamp) ==
false)
115 m_timeStamp.
update(synchronized_timestamp);
122 std_msgs::msg::Int16MultiArray statusMsg;
123 statusMsg.data.resize(3);
124 statusMsg.data[0] =
static_cast<int>(isRecording);
125 statusMsg.data[1] =
static_cast<int>(device_buffer_current_size.
getBufferElements());
126 statusMsg.data[2] =
static_cast<int>(device_buffer_max_size.
getBufferElements());
127 m_ros2Publisher_status->publish(statusMsg);
138 if (PeriodicThread::isRunning())
140 PeriodicThread::stop();
const yarp::os::LogComponent & AUDIORECORDER_NWS_ROS2()
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool attach(yarp::dev::PolyDriver *driver) override
Attach to another object.
bool detach() override
Detach the object (you must have first called attach).
void run() override
Loop function.
~AudioRecorder_nws_ros2()
bool open(yarp::os::Searchable ¶ms) override
Open the DeviceDriver.
void threadRelease() override
Release method.
bool threadInit() override
Initialization method.
bool close() override
Close the DeviceDriver.
static rclcpp::Node::SharedPtr createNode(std::string name)
bool view(T *&x)
Get an interface to the device driver.
virtual yarp::dev::ReturnValue getRecordingAudioBufferCurrentSize(yarp::sig::AudioBufferSize &size)=0
virtual yarp::dev::ReturnValue isRecording(bool &recording_enabled)=0
Check if the recording has been enabled (e.g.
virtual yarp::dev::ReturnValue getRecordingAudioBufferMaxSize(yarp::sig::AudioBufferSize &size)=0
A container for a device driver.
bool isValid() const
Check if device is valid.
A base class for nested structures that can be searched.
void update()
Set the timestamp to the current time, and increment the sequence number (wrapping to 0 if the sequen...
size_t getBufferElements()
#define yCInfo(component,...)
#define yCError(component,...)
#define yCTrace(component,...)
#define YARP_LOG_COMPONENT(name,...)
double now()
Return the current time in seconds, relative to an arbitrary starting point.
The main, catch-all namespace for YARP.