Matrix3x3 & getBasis()//Return the basis matrix for the rotation const Vector3 & getOrigin()//Return the origin vector translation Quaternion getRotation()//Return a quaternion representing the rotation Transform operator* (const Transform &t)const//Return the product of this transform and the other. Transform inverse()//Return the inverse of this transform
//get the starting pose of the robot tf::Stamped<tf::Pose> global_pose; if(!planner_costmap_ros_->getRobotPose(global_pose)) { ROS_WARN("Unable to get starting pose of robot, unable to create global plan"); returnfalse; } geometry_msgs::PoseStamped start_pose; tf::poseStampedTFToMsg(global_pose, start_pose);
还有类似的函数: poseTFToMsg 和 transformMsgToTF
angles包
static double from_degrees (double degrees): Convert degrees to radians
typedef std::vector<std::string> ros::V_string // Retreives the currently-known list of nodes from the master. 放入 ROSCPP_DECL boolgetNodes(V_string &nodes)
用这个函数很简单:
1 2 3 4 5 6 7
std::vector<std::string> nodes; ros::master::getNodes(nodes); // bool int len = nodes.size(); for (int i =0; i < len; i ++) { cout<<"node: "<<nodes.at(i)<<endl; }
获得当前运行的所有话题名
1 2 3 4 5 6 7 8 9 10 11
structros::master::TopicInfo { TopicInfo () TopicInfo (const std::string &_name, const std::string &_datatype) public: std::string datatype // Datatype of the topic. std::string name // Name of the topic. } typedef std::vector<TopicInfo> ros::master::V_TopicInfo ROSCPP_DECL boolgetTopics(V_TopicInfo &topics)
使用是类似的:
1 2 3 4 5 6 7 8
std::vector<ros::master::TopicInfo> topics; ros::master::getTopics(topics); int len = topics.size(); for (int i =0; i < len; i ++) { cout<<"topic: "<<topics.at(i).name<<" type: " <<topics.at(i).datatype<<endl; }
// Get the hostname where the master runs. ROSCPP_DECL const std::string & getHost() // Get the port where the master runs. ROSCPP_DECL uint32_tgetPort() // Get the full URI to the master (eg. http://host:port/) ROSCPP_DECL const std::string & getURI()
function subscribe() returns a Subscriber object that you must hold on to until you want to unsubscribe. When all copies of the Subscriber object go out of scope, this callback will automatically be unsubscribed from this topic.
function shutdown() Unsubscribe the callback associated with this Subscriber. This method usually does not need to be explicitly called, as automatic shutdown happens when all copies of this Subscriber go out of scope This method overrides the automatic reference counted unsubscribe, and immediately unsubscribes the callback associated with this Subscriber
queue_size Maximum number of outgoing messages to be queued for delivery to subscribers。 消息队列是为了缓存发布节点发布的消息,一旦队列中消息的数量超过了queue_size,那么最先进入队列的(最老的)消息被舍弃。
latch (optional) If true, the last message published on this topic will be saved and sent to new subscribers when they connect
订阅者Subscriber ros::NodeHandle::subscribe函数里也有一个queue_size: Number of incoming messages to queue up for processing,消息队列是为了缓存节点接收到的信息,一旦自己处理的速度过慢,接收到的消息数量超过了queue_size,那么最先进入队列的(最老的)消息会被舍弃。