3 #include <semio_msgs_ros/DeicticRecognitionResult.h> 4 #include <semio_msgs_ros/DeicticTargets.h> 45 result_pub_( nh_rel_.advertise<_DeicticRecognitionResultMsg>(
"result", 100 ) ),
47 humanoid_source_ptr_( humanoid_source_ptr )
49 typedef std::function<void(std::string const &)> _ParamFunc;
50 typedef std::pair<std::string, _ParamFunc> _ParamOp;
51 for(
auto const & param_op : {
54 [
this]( std::string
const & param_name ){
55 this->deictic_recognizer_.
setFilterMaxSize( this->nh_rel_.param<
int>( std::string( param_name ), 0 ) );
57 _ParamOp(
"filter/max_duration",
58 [
this]( std::string
const & param_name ){
59 this->deictic_recognizer_.
setFilterMaxDuration( this->nh_rel_.param<
double>( std::string( param_name ), 0 ) );
62 if( nh_rel_.hasParam( param_op.first ) ) param_op.second( param_op.first );
69 ros::Rate loop_rate( 30 );
77 deictic_recognizer_.
getHumanoids() = humanoid_source_ptr_->update();
83 _DeicticRecognitionResultMsg result_msg;
85 result_msg.humanoids.reserve( result.size() );
87 for(
auto const & humanoid_item : result )
91 _DeicticRecognitionHumanoidItemMsg humanoid_msg;
92 humanoid_msg.id =
static_cast<uint32_t
>( humanoid_item.first );
93 humanoid_msg.sources.reserve( sources.size() );
95 for(
auto const & source_item : sources )
99 _DeicticRecognitionSourceItemMsg source_msg;
100 source_msg.name = source_item.first;
101 source_msg.top_n_list.reserve( top_n_list.size() );
103 for(
auto const & list_item : top_n_list.
values() )
105 _DeicticRecognitionTopNItemMsg top_n_item_msg;
106 top_n_item_msg.likelihood = list_item.getValue();
107 top_n_item_msg.target_name = list_item.getData();
109 source_msg.top_n_list.push_back( std::move( top_n_item_msg ) );
112 humanoid_msg.sources.push_back( std::move( source_msg ) );
115 result_msg.humanoids.push_back( std::move( humanoid_msg ) );
120 result_pub_.publish( std::move( result_msg ) );
130 void targetsCB( _DeicticTargetsMsg::ConstPtr
const & msg_ptr )
132 auto const & targets_msg = *msg_ptr;
138 for(
auto const & target_msg : targets_msg.targets )
140 auto const & name = target_msg.name;
141 auto const & position = target_msg.position;
143 deictic_targets.emplace( name, Eigen::Vector3d( position.x, position.y, position.z ) );
148 deictic_recognizer_.
getTargets() = deictic_targets;
152 int main(
int argc,
char ** argv )
154 ros::init( argc, argv,
"semio_deixis_node" );
156 ros::NodeHandle nh_rel(
"~" );
164 semio_deixis_node.
spin();
Simple ROS wrapper around semio::DeicticRecognizer.
semio_msgs_ros::DeicticRecognitionResult _DeicticRecognitionResultMsg
ROS message for the result of deictic recognition for all humanoids.
std::set< DeicticTarget > DeicticTargetArray
DeixisHumanoidMap DeicticRecognitionResult
void setFilterMaxSize(size_t const &max_size=30)
semio_msgs_ros::DeicticTarget _DeicticTargetMsg
ROS message for a single deictic target.
HumanoidArray & getHumanoids()
DeicticTargetArray & getTargets()
semio::DeicticRecognizer deictic_recognizer_
Semio deictic recognizer.
semio::HumanoidSource::Ptr humanoid_source_ptr_
Pointer to the input source for humanoids.
DeicticRecognitionResult const & calculateResult()
decltype(std::make_shared< HumanoidSource >()) typedef Ptr
SemioDeixisNode(ros::NodeHandle &nh_rel, semio::HumanoidSource::Ptr humanoid_source_ptr)
void targetsCB(_DeicticTargetsMsg::ConstPtr const &msg_ptr)
ROS callback for deictic targets.
Utility class to simplify the creation of semio::HumanoidSource instances.
ros::Publisher result_pub_
Deictic recognition result publisher.
HumanoidSource::Ptr getHumanoidSource(std::string const &source="param")
Create a semio::HumanoidSource.
int main(int argc, char **argv)
semio_msgs_ros::DeicticRecognitionHumanoidItem _DeicticRecognitionHumanoidItemMsg
ROS message for the result of deictic recognition for a single humanoid.
semio_msgs_ros::DeicticRecognitionTopNItem _DeicticRecognitionTopNItemMsg
ROS message for the result of deictic recognition for a single deictic target.
semio_msgs_ros::DeicticRecognitionSourceItem _DeicticRecognitionSourceItemMsg
ROS message for the result of deictic recognition for a single humanoid joint.
ros::Subscriber targets_sub_
Deictic targets subscriber.
semio_msgs_ros::DeicticTargets _DeicticTargetsMsg
ROS message for a vector of deictic targets.
std::map< std::string, DeixisTopNList > DeixisSourceMap
ros::NodeHandle nh_rel_
NodeHandle copy used to interface with ROS.
void setFilterMaxDuration(double const &max_duration=0.5)