00001 /* 00002 * ViconSegment.cpp 00003 * 00004 * Created on: Sep 3, 2012 00005 * Author: mriedel 00006 */ 00007 00008 #include <telekyb_vicon/ViconSegment.hpp> 00009 00010 #include <telekyb_base/ROS/ROSModule.hpp> 00011 #include <telekyb_vicon/ViconSubject.hpp> 00012 00013 00014 namespace TELEKYB_NAMESPACE { 00015 00016 ViconSegment::ViconSegment(ViconSubject& parent_, int segmentID_, const std::string segmentName_) 00017 : parent(parent_), segmentID(segmentID_), segmentName(segmentName_) 00018 { 00019 ros::NodeHandle n(ROSModule::Instance().getMainNodeHandle(), parent.getName()); 00020 posePublisher = n.advertise<geometry_msgs::PoseStamped>(segmentName,10); 00021 00022 poseMsg.header.frame_id = parent.getName() + "/" + segmentName; 00023 00024 ROS_INFO("Created Segment %s/%s",parent.getName().c_str(), segmentName.c_str()); 00025 00026 } 00027 00028 ViconSegment& ViconSegment::operator= (const ViconSegment & other) 00029 { 00030 segmentID = other.segmentID; 00031 segmentName = other.segmentName; 00032 posePublisher = other.posePublisher; 00033 poseMsg = other.poseMsg; 00034 return *this; 00035 } 00036 00037 ViconSegment::~ViconSegment() 00038 { 00039 00040 } 00041 00042 void ViconSegment::publish(const Eigen::Vector3d& globalTranslation, const Eigen::Quaterniond& globalOrientation) 00043 { 00044 00045 poseMsg.header.stamp = ros::Time::now(); 00046 00047 poseMsg.pose.position.x = globalTranslation(0); 00048 poseMsg.pose.position.y = globalTranslation(1); 00049 poseMsg.pose.position.z = globalTranslation(2); 00050 00051 poseMsg.pose.orientation.w = globalOrientation.w(); 00052 poseMsg.pose.orientation.x = globalOrientation.x(); 00053 poseMsg.pose.orientation.y = globalOrientation.y(); 00054 poseMsg.pose.orientation.z = globalOrientation.z(); 00055 00056 posePublisher.publish(poseMsg); 00057 } 00058 00059 int ViconSegment::getSegmentID() const 00060 { 00061 return segmentID; 00062 } 00063 00064 std::string ViconSegment::getSegmentName() const 00065 { 00066 return segmentName; 00067 } 00068 00069 00070 } /* namespace telekyb */