Skip to content
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

Add to publish facedetected event #56

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ project(naoqi_driver)
set(
CONVERTERS_SRC
src/converters/audio.cpp
src/converters/touch.cpp
src/converters/people.cpp
src/converters/camera.cpp
src/converters/diagnostics.cpp
src/converters/imu.cpp
Expand Down Expand Up @@ -63,6 +65,8 @@ set(
src/event/basic.hxx
src/event/basic.hpp
src/event/audio.cpp
src/event/touch.cpp
src/event/people.cpp
)

# use catkin if qibuild is not found
Expand Down
1 change: 1 addition & 0 deletions CMakeLists_catkin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ find_package(catkin COMPONENTS
image_transport
kdl_parser
naoqi_bridge_msgs
nao_interaction_msgs
naoqi_libqi
naoqi_libqicore
robot_state_publisher
Expand Down
2 changes: 2 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
<build_depend>image_transport</build_depend>
<build_depend>kdl_parser</build_depend>
<build_depend version_gte="0.0.4">naoqi_bridge_msgs</build_depend>
<build_depend>nao_interaction_msgs</build_depend>
<build_depend>naoqi_libqi</build_depend>
<build_depend>naoqi_libqicore</build_depend>
<build_depend>orocos_kdl</build_depend>
Expand All @@ -35,6 +36,7 @@
<run_depend>image_transport</run_depend>
<run_depend>kdl_parser</run_depend>
<run_depend version_gte="0.0.4">naoqi_bridge_msgs</run_depend>
<run_depend>nao_interaction_msgs</run_depend>
<run_depend>naoqi_libqi</run_depend>
<run_depend>naoqi_libqicore</run_depend>
<run_depend>orocos_kdl</run_depend>
Expand Down
4 changes: 4 additions & 0 deletions share/boot_config.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@
"frequency" : 10
},
"audio":
{
"enabled" : true
},
"people":
{
"enabled" : true
}
Expand Down
68 changes: 68 additions & 0 deletions src/converters/people.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2015 Aldebaran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

/*
* LOCAL includes
*/
#include "people.hpp"

/*
* BOOST includes
*/
#include <boost/foreach.hpp>
#define for_each BOOST_FOREACH

namespace naoqi{

namespace converter{

template <class T>
PeopleEventConverter<T>::PeopleEventConverter(const std::string& name, const float& frequency, const qi::SessionPtr& session)
: BaseConverter<PeopleEventConverter<T> >(name, frequency, session)
{
}

template <class T>
PeopleEventConverter<T>::~PeopleEventConverter() {
}

template <class T>
void PeopleEventConverter<T>::reset()
{
}

template <class T>
void PeopleEventConverter<T>::registerCallback( const message_actions::MessageAction action, Callback_t cb )
{
callbacks_[action] = cb;
}

template <class T>
void PeopleEventConverter<T>::callAll(const std::vector<message_actions::MessageAction>& actions, T& msg)
{
msg_ = msg;
for_each( message_actions::MessageAction action, actions )
{
callbacks_[action](msg_);
}
}

// http://stackoverflow.com/questions/8752837/undefined-reference-to-template-class-constructor
template class PeopleEventConverter<nao_interaction_msgs::FaceDetected>;
}

}
68 changes: 68 additions & 0 deletions src/converters/people.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright 2015 Aldebaran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef PEOPLE_EVENT_CONVERTER_HPP
#define PEOPLE_EVENT_CONVERTER_HPP

/*
* LOCAL includes
*/
#include "converter_base.hpp"
#include <naoqi_driver/message_actions.h>

/*
* ROS includes
*/
#include <nao_interaction_msgs/FaceDetected.h>

/*
* ALDEBARAN includes
*/
#include <qi/anymodule.hpp>

namespace naoqi{

namespace converter{

template <class T>
class PeopleEventConverter : public BaseConverter<PeopleEventConverter<T> >
{

typedef boost::function<void(T&) > Callback_t;

public:
PeopleEventConverter(const std::string& name, const float& frequency, const qi::SessionPtr& session);

~PeopleEventConverter();

virtual void reset();

void registerCallback( const message_actions::MessageAction action, Callback_t cb );

void callAll(const std::vector<message_actions::MessageAction>& actions, T& msg);

private:
/** Registered Callbacks **/
std::map<message_actions::MessageAction, Callback_t> callbacks_;
T msg_;
};

}

}

#endif // PEOPLE_CONVERTER_HPP
69 changes: 69 additions & 0 deletions src/converters/touch.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2015 Aldebaran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

/*
* LOCAL includes
*/
#include "touch.hpp"

/*
* BOOST includes
*/
#include <boost/foreach.hpp>
#define for_each BOOST_FOREACH

namespace naoqi{

namespace converter{

template <class T>
TouchEventConverter<T>::TouchEventConverter(const std::string& name, const float& frequency, const qi::SessionPtr& session)
: BaseConverter<TouchEventConverter<T> >(name, frequency, session)
{
}

template <class T>
TouchEventConverter<T>::~TouchEventConverter() {
}

template <class T>
void TouchEventConverter<T>::reset()
{
}

template <class T>
void TouchEventConverter<T>::registerCallback( const message_actions::MessageAction action, Callback_t cb )
{
callbacks_[action] = cb;
}

template <class T>
void TouchEventConverter<T>::callAll(const std::vector<message_actions::MessageAction>& actions, T& msg)
{
msg_ = msg;
for_each( message_actions::MessageAction action, actions )
{
callbacks_[action](msg_);
}
}

// http://stackoverflow.com/questions/8752837/undefined-reference-to-template-class-constructor
template class TouchEventConverter<naoqi_bridge_msgs::Bumper>;
template class TouchEventConverter<naoqi_bridge_msgs::TactileTouch>;
}

}
69 changes: 69 additions & 0 deletions src/converters/touch.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* Copyright 2015 Aldebaran
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#ifndef TOUCH_EVENT_CONVERTER_HPP
#define TOUCH_EVENT_CONVERTER_HPP

/*
* LOCAL includes
*/
#include "converter_base.hpp"
#include <naoqi_driver/message_actions.h>

/*
* ROS includes
*/
#include <naoqi_bridge_msgs/Bumper.h>
#include <naoqi_bridge_msgs/TactileTouch.h>

/*
* ALDEBARAN includes
*/
#include <qi/anymodule.hpp>

namespace naoqi{

namespace converter{

template <class T>
class TouchEventConverter : public BaseConverter<TouchEventConverter<T> >
{

typedef boost::function<void(T&) > Callback_t;

public:
TouchEventConverter(const std::string& name, const float& frequency, const qi::SessionPtr& session);

~TouchEventConverter();

virtual void reset();

void registerCallback( const message_actions::MessageAction action, Callback_t cb );

void callAll(const std::vector<message_actions::MessageAction>& actions, T& msg);

private:
/** Registered Callbacks **/
std::map<message_actions::MessageAction, Callback_t> callbacks_;
T msg_;
};

}

}

#endif // TOUCH_CONVERTER_HPP
Loading