3 #include <semio_msgs_ros/AttentionRecognitionResult.h> 4 #include <semio_msgs_ros/AttentionTargets.h> 45 result_pub_( nh_rel_.advertise<_AttentionRecognitionResultMsg>(
"result", 100 ) ),
47 humanoid_source_ptr_( humanoid_source_ptr )
55 ros::Rate loop_rate( 30 );
63 attention_recognizer_.
getHumanoids() = humanoid_source_ptr_->update();
69 _AttentionRecognitionResultMsg result_msg;
71 result_msg.humanoids.reserve( result.size() );
73 for(
auto const & humanoid_item : result )
77 _AttentionRecognitionHumanoidItemMsg humanoid_msg;
78 humanoid_msg.id =
static_cast<uint32_t
>( humanoid_item.first );
79 humanoid_msg.joints.reserve( joints.size() );
81 for(
auto const & joint_item : joints )
85 _AttentionRecognitionJointItemMsg joint_msg;
86 joint_msg.id =
static_cast<uint32_t
>( joint_item.first );
87 joint_msg.top_n_list.reserve( top_n_list.size() );
89 for(
auto const & list_item : top_n_list.
values() )
91 _AttentionRecognitionTopNItemMsg top_n_item_msg;
92 top_n_item_msg.likelihood = list_item.getValue();
93 top_n_item_msg.target_name = list_item.getData();
95 joint_msg.top_n_list.push_back( std::move( top_n_item_msg ) );
98 humanoid_msg.joints.push_back( std::move( joint_msg ) );
101 result_msg.humanoids.push_back( std::move( humanoid_msg ) );
106 result_pub_.publish( std::move( result_msg ) );
116 void targetsCB( _AttentionTargetsMsg::ConstPtr
const & msg_ptr )
118 auto const & targets_msg = *msg_ptr;
124 for(
auto const & target_msg : targets_msg.targets )
126 auto const & name = target_msg.name;
127 auto const & position = target_msg.position;
129 attention_targets.emplace( name, Eigen::Vector3d( position.x, position.y, position.z ) );
134 attention_recognizer_.
getTargets() = attention_targets;
138 int main(
int argc,
char ** argv )
140 ros::init( argc, argv,
"semio_attention_node" );
142 ros::NodeHandle nh_rel(
"~" );
150 semio_attention_node.
spin();
void targetsCB(_AttentionTargetsMsg::ConstPtr const &msg_ptr)
ROS callback for attention targets.
AttentionHumanoidMap AttentionRecognitionResult
std::set< AttentionTarget > AttentionTargetArray
std::map< HumanoidJoint::JointType, AttentionTopNList > AttentionSourceMap
AttentionRecognitionResult const & calculateResult()
AttentionTargetArray & getTargets()
HumanoidArray & getHumanoids()
semio::AttentionRecognizer attention_recognizer_
Semio attention recognizer.
semio_msgs_ros::AttentionTarget _AttentionTargetMsg
ROS message for a single attention target.
SemioAttentionNode(ros::NodeHandle &nh_rel, semio::HumanoidSource::Ptr humanoid_source_ptr)
semio_msgs_ros::AttentionRecognitionResult _AttentionRecognitionResultMsg
ROS message for the result of attention recognition for all humanoids.
ros::NodeHandle nh_rel_
NodeHandle copy used to interface with ROS.
semio_msgs_ros::AttentionRecognitionHumanoidItem _AttentionRecognitionHumanoidItemMsg
ROS message for the result of attention recognition for a single humanoid.
decltype(std::make_shared< HumanoidSource >()) typedef Ptr
semio_msgs_ros::AttentionTargets _AttentionTargetsMsg
ROS message for a vector of attention targets.
ros::Subscriber targets_sub_
Attention targets subscriber.
semio_msgs_ros::AttentionRecognitionTopNItem _AttentionRecognitionTopNItemMsg
ROS message for the result of attention recognition for a single attention target.
Utility class to simplify the creation of semio::HumanoidSource instances.
Simple ROS wrapper around semio::AttentionRecognizer.
HumanoidSource::Ptr getHumanoidSource(std::string const &source="param")
Create a semio::HumanoidSource.
int main(int argc, char **argv)
semio_msgs_ros::AttentionRecognitionJointItem _AttentionRecognitionJointItemMsg
ROS message for the result of attention recognition for a single humanoid joint.
semio::HumanoidSource::Ptr humanoid_source_ptr_
Pointer to the input source for humanoids.
ros::Publisher result_pub_
Attention recognition result publisher.