本文整理汇总了C++中ros::NodeHandlePtr类的典型用法代码示例。如果您正苦于以下问题:C++ NodeHandlePtr类的具体用法?C++ NodeHandlePtr怎么用?C++ NodeHandlePtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了NodeHandlePtr类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char** argv) {
ros::init(argc, argv, "batteryInfo");
nodeHandle = ros::NodeHandlePtr(new ros::NodeHandle("~"));
getNamePrefix();
ROS_INFO("Subscribing to /diagnostics ...");
ros::Subscriber diagnosticsSub = nodeHandle->subscribe("/diagnostics", 1, diagnosticsCallback);
ros::spin();
return 0;
}
示例2: main
int main(int argc, char **argv)
{
ros::init(argc, argv, "pose_generator");
_handle = ros::NodeHandlePtr(new ros::NodeHandle(""));
_odom.header.frame_id = "map";
_x = _y = 0;
_theta = 0;
_correct_theta = false;
_correct_lateral = false;
_iteration_theta = 0; _iteration_lateral = 0;
_turn_accum = 0;
_heading = 0;
_see_front_plane = false;
_ringbuffer.reserve(_ringbuffer_max_size);
ros::Subscriber sub_enc = _handle->subscribe("/arduino/encoders",10,callback_encoders);
ros::Subscriber sub_turn_angle = _handle->subscribe("/controller/turn/angle",10,callback_turn_angle);
ros::Subscriber sub_turn_done = _handle->subscribe("/controller/turn/done",10,callback_turn_done);
ros::Subscriber sub_ir = _handle->subscribe("/perception/ir/distance",10,callback_ir);
ros::Subscriber sub_planes = _handle->subscribe("/vision/obstacles/planes",10,callback_planes);
ros::Subscriber sub_crash = _handle->subscribe("/perception/imu/peak", 10, callback_crash);
_pub_odom = _handle->advertise<nav_msgs::Odometry>("/pose/odometry/",10,(ros::SubscriberStatusCallback)connect_odometry_callback);
_pub_viz = _handle->advertise<visualization_msgs::Marker>( "visualization_marker", 0 );
_pub_compass = _handle->advertise<std_msgs::Int8>("/pose/compass", 10, (ros::SubscriberStatusCallback)connect_compass_callback);
_srv_raycast = _handle->serviceClient<navigation_msgs::Raycast>("/mapping/raycast");
ros::spin();
return 0;
}
示例3: init
int init()
{
// Use global namespace for node
node_ = ros::NodeHandlePtr(new ros::NodeHandle());
// Get tf_prefix from global namespace
node_->param("tf_prefix", tf_prefix_, std::string(""));
// Use private namespace for parameters
pnode_ = ros::NodeHandlePtr(new ros::NodeHandle("~"));
pnode_->param("publish_rate", publish_rate_, PUBLISH_RATE);
pnode_->param("fixed_frame_id", fixed_frame_id_, std::string("odom"));
fixed_frame_id_ = tf::resolve(tf_prefix_, fixed_frame_id_);
pnode_->param("publish_odom_tf", publish_odom_tf_, true);
pnode_->param("crio/ip", crio_ip_, std::string("127.0.0.1"));
pnode_->param("crio/command_port", crio_cmd_port_, std::string("39000"));
pnode_->param("crio/state_port", crio_state_port_, std::string("39001"));
pnode_->param("crio/socket_timeout", socket_timeout_, 10);
VehicleKinematics::Parameters kin_params;
tfScalar minimum_radius_outer;
if (!pnode_->getParam("kinematics/frame_id", kin_params.frame_id))
{
ROS_WARN_STREAM(pnode_->getNamespace() << "/kinematics/frame_id parameter is not set");
}
else
{
kin_params.frame_id = tf::resolve(tf_prefix_, kin_params.frame_id);
}
if (!pnode_->getParam("kinematics/wheelbase", kin_params.wheelbase_length))
{
ROS_FATAL_STREAM(pnode_->getNamespace() << "/kinematics/wheelbase parameter is not set");
return -1;
}
if (!pnode_->getParam("kinematics/track", kin_params.track_width))
{
ROS_FATAL_STREAM( pnode_->getNamespace() << "/kinematics/track parameter is not set");
return -1;
}
if (!pnode_->getParam("kinematics/rotation_center", kin_params.rotation_center))
{
ROS_WARN_STREAM(
pnode_->getNamespace()
<< "/kinematics/rotation_center parameter is not set. Using default: wheelbase/2 = "
<< kin_params.wheelbase_length / 2);
kin_params.rotation_center = kin_params.wheelbase_length / 2;
}
if (!pnode_->getParam("kinematics/minimum_radius_outer", minimum_radius_outer))
{
ROS_FATAL_STREAM(pnode_->getNamespace() << "/kinematics/minimum_radius_outer parameter is not set");
return -1;
}
else
{
kin_params.minimum_radius = minimum_radius_outer - kin_params.track_width / 2;
}
if (!pnode_->getParam("kinematics/steering_ratio", kin_params.steering_ratio))
{
ROS_FATAL_STREAM(pnode_->getNamespace() << "/kinematics/steering_ratio parameter is not set");
return -1;
}
// kin_(2.7, 1.626, 1.35);
kin_ = boost::make_shared<VehicleKinematics>(kin_params);
sub_ = node_->subscribe<kut_ugv_msgs::MotionCommandStamped>("motion_command", 200,
&CompactRIOCommunicationNode::motionCommand, this);
odom_pub_ = node_->advertise<nav_msgs::Odometry>("odom", 200);
state_pub_ = node_->advertise<kut_ugv_vehicle::StateStamped>("state", 200);
tf_br_ = boost::shared_ptr<tf::TransformBroadcaster>(new tf::TransformBroadcaster);
timeout_ = boost::posix_time::seconds(socket_timeout_);
send_ep_ = udp::endpoint(boost::asio::ip::address::from_string(crio_ip_), std::atoi(crio_cmd_port_.c_str()));
receive_ep_ = udp::endpoint(udp::v4(), std::atoi(crio_state_port_.c_str()));
socket_.open(udp::v4());
deadline_.expires_at(boost::posix_time::pos_infin);
this->deadlineCallback(deadline_, socket_);
return 0;
}
示例4: init
int init(PhantomState *s)
{
if(!s)
{
ROS_FATAL("Internal error. PhantomState is NULL.");
return -1;
}
node_ = ros::NodeHandlePtr(new ros::NodeHandle);
pnode_ = ros::NodeHandlePtr(new ros::NodeHandle("~"));
pnode_->param(std::string("tf_prefix"), tf_prefix_, std::string(""));
// Vertical displacement from base_link to link_0. Defaults to Omni offset.
pnode_->param(std::string("table_offset"), table_offset_, .135);
// Force feedback damping coefficient
pnode_->param(std::string("damping_k"), damping_k_, 0.001);
// On startup device will generate forces to hold end-effector at origin.
pnode_->param(std::string("locked"), locked_, false);
// Check calibration status on start up and calibrate if necessary.
pnode_->param(std::string("calibrate"), calibrate_, false);
//Frame attached to the base of the phantom (NAME/base_link)
base_link_name_ = "base_link";
//Publish on NAME/pose
std::string pose_topic_name = "pose";
pose_publisher_ = node_->advertise<geometry_msgs::PoseStamped>(pose_topic_name, 100);
//Publish button state on NAME/button
std::string button_topic = "button";
button_publisher_ = node_->advertise<sensable_phantom::PhantomButtonEvent>(button_topic, 100);
//Subscribe to NAME/force_feedback
std::string force_feedback_topic = "force_feedback";
wrench_sub_ = node_->subscribe(force_feedback_topic, 100, &PhantomROS::wrench_callback, this);
//Frame of force feedback (NAME/sensable_origin)
sensable_frame_name_ = "sensable_origin";
for (int i = 0; i < 7; i++)
{
std::ostringstream stream1;
stream1 << "link_" << i;
link_names_[i] = std::string(stream1.str());
}
state_ = s;
state_->buttons[0] = 0;
state_->buttons[1] = 0;
state_->buttons_prev[0] = 0;
state_->buttons_prev[1] = 0;
hduVector3Dd zeros(0, 0, 0);
state_->velocity = zeros;
state_->inp_vel1 = zeros; //3x1 history of velocity
state_->inp_vel2 = zeros; //3x1 history of velocity
state_->inp_vel3 = zeros; //3x1 history of velocity
state_->out_vel1 = zeros; //3x1 history of velocity
state_->out_vel2 = zeros; //3x1 history of velocity
state_->out_vel3 = zeros; //3x1 history of velocity
state_->pos_hist1 = zeros; //3x1 history of position
state_->pos_hist2 = zeros; //3x1 history of position
state_->lock = locked_;
state_->lock_pos = zeros;
state_->hd_cur_transform = hduMatrix::createTranslation(0, 0, 0);
return 0;
}
示例5: main
int main(int argc, char **argv) {
if (argc < 2) {
printf("\nusage: relay TOPIC [VARIANT_TOPIC]\n\n");
return 1;
}
if (!getTopicBase((argv[1]), publisherTopic)) {
ROS_ERROR("Failed to extract topic base from [%s]", argv[1]);
return 1;
}
ros::init(argc, argv, publisherTopic+"_relay",
ros::init_options::AnonymousName);
if (argc == 2)
publisherTopic = std::string(argv[1])+"_relay";
else
publisherTopic = argv[2];
subscriberTopic = argv[1];
nodeHandle.reset(new ros::NodeHandle("~"));
bool unreliable = false;
nodeHandle->getParam("unreliable", unreliable);
nodeHandle->getParam("lazy", lazy);
if (unreliable)
subscriberTransportHints.unreliable().reliable();
subscribe();
ros::spin();
return 0;
}
示例6: OnInit
bool OnInit()
{
// create our own copy of argv, with regular char*s.
local_argv_ = new char*[argc];
for (int i = 0; i < argc; ++i)
{
local_argv_[ i ] = strdup( wxString( argv[ i ] ).mb_str() );
}
ros::init(argc, local_argv_, "remote_monitor");
nh_.reset(new ros::NodeHandle);
//wxInitAllImageHandlers();
CRemoteFrame* frame = new CRemoteFrame(
nh_,
NULL,
wxID_ANY,
wxT("Remote Frame"),
wxDefaultPosition,
wxSize(700, 350),
wxDEFAULT_FRAME_STYLE & ~wxRESIZE_BORDER);
SetTopWindow(frame);
frame->Show();
return true;
}
示例7: callback_crash
void callback_crash(const std_msgs::TimeConstPtr& time)
{
_mute = true;
revert_applied_readings_since(time->data);
_timer = _handle->createTimer(ros::Duration(_muting_time), callback_timer, true, true );
ROS_ERROR("[PoseGenerator::callbackCrash] Crash signal received. Will mute encoder readings for %.2lf seconds", _muting_time);
}
示例8: main
int main(int argc, char** argv)
{
ros::init(argc, argv, "db_cloud_extraction");
nh.reset(new ros::NodeHandle);
ros::NodeHandle pn("~");
//plane filter
pn.param<float>("normal_angle", normal_angle, 15.0);
//filter1
pn.param<float>("search_radius", search_radius, 0.8);
pn.param<int>("neighbour_required", neighbour_required, 20);
//filter2
pn.param<int>("statistical_knn", statistical_knn, 50);
pn.param<float>("std_dev_dist", std_dev_dist, 1.0);
ros::ServiceServer table_srv = nh->advertiseService("db_table_clouds", extract);
ros::ServiceServer table_srv2 = nh->advertiseService("db_table", extract2);
ros::spin();
}
示例9: main
int main(int argc, char** argv)
{
ros::init(argc, argv, "centreview");
n.reset(new ros::NodeHandle);
ros::NodeHandle pn("~");
std::string collection;
std::vector<int> indices;
pn.param<std::string>("collection",collection, "table_centre_group");
pn.getParam("specify_index",indices);
if(collection=="table_centre_group"){
mongodb_store::MessageStoreProxy table_centre_group(*n, collection);
std::vector<boost::shared_ptr<geometry_msgs::Polygon> > result_tables;
table_centre_group.query<geometry_msgs::Polygon>(result_tables);
VIZ_Points vv(n,"/table_centre_group");
std::vector<float> color;
color.push_back(0.0);
color.push_back(1.0);
color.push_back(0.0);
VIZ_Points vv2(n,"/table_centre_group2");
std::vector<float> color2;
color2.push_back(0.0);
color2.push_back(0.0);
color2.push_back(1.0);
VIZ_Points vv3(n,"/table_centre_group3");
std::vector<float> color3;
color3.push_back(1.0);
color3.push_back(0.0);
color3.push_back(0.0);
while (ros::ok()){
vv.pub_polygonASpoints(result_tables,0,color);
vv2.pub_polygonASpoints(result_tables,1,color2);
vv3.pub_polygonASpoints(result_tables,2,color3);
sleep(1);
}
return 0;
}
}
示例10: main
int main(int argc, char *argv[])
{
/*
* INITIALIZE ROS NODE
*/
ros::init(argc, argv, "perception_node");
ros::NodeHandle priv_nh_("~");
priv_nh_.param<double>("leaf_size", leaf_size_, 0.0f);
// priv_nh_.param<double>("passThrough_max", passThrough_max_, 1.0f);
// priv_nh_.param<double>("passThrough_min", passThrough_min_, -1.0f);
// priv_nh_.param<double>("maxIterations", maxIterations_, 200.0f);
// priv_nh_.param<double>("distThreshold", distThreshold_, 0.01f);
// priv_nh_.param<double>("clustTol", clustTol_, 0.01f);
// priv_nh_.param<double>("clustMax", clustMax_, 10000.0);
// priv_nh_.param<double>("clustMin", clustMin_, 300.0f);
nh_.reset(new ros::NodeHandle());
// ros::ServiceServer server = nh_->advertiseService("filter_cloud", &filterCallback);
ros::spin();
return 0;
}
示例11: main
int main(int argc, char **argv) {
if (argc < 2) {
printf("\nusage: echo TOPIC\n\n");
return 1;
}
if (!getTopicBase((argv[1]), subscriberTopic)) {
ROS_ERROR("Failed to extract topic base from [%s]", argv[1]);
return 1;
}
ros::init(argc, argv, subscriberTopic+"_echo",
ros::init_options::AnonymousName);
subscriberTopic = argv[1];
nodeHandle.reset(new ros::NodeHandle("~"));
subscribe();
ros::spin();
return 0;
}
示例12: getNamePrefix
void getNamePrefix() {
if (!nodeHandle->getParam("batteryDiagnosticsPublisherNode", namePrefix)) {
ROS_INFO_STREAM("No prefix parameter specified. using: nifti_robot_driver");
namePrefix = "nifti_robot_driver";
}
}
示例13: TurtleApp
TurtleApp(int& argc, char** argv)
: QApplication(argc, argv)
{
ros::init(argc, argv, "turtlesim", ros::init_options::NoSigintHandler);
nh_.reset(new ros::NodeHandle);
}
示例14: subscribe
void subscribe() {
subscriber = nodeHandle->subscribe(subscriberTopic, subscriberQueueSize,
&callback, subscriberTransportHints);
}