本文整理汇总了C++中ros::NodeHandle::subscribe方法的典型用法代码示例。如果您正苦于以下问题:C++ NodeHandle::subscribe方法的具体用法?C++ NodeHandle::subscribe怎么用?C++ NodeHandle::subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ros::NodeHandle
的用法示例。
在下文中一共展示了NodeHandle::subscribe方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MyClass
MyClass()
:pnh("~")
{
sub = nh.subscribe("/humans/kinect_v2", 1, &MyClass::callback, this);
pub = nh.advertise<std_msgs::String>("/pub_topic", 1);
pnh.param<std::string>("output", output_filename, "test.json");
out_file << output_filename << ".json";
joint_filename = "joint_index.txt";
init_table(joint_filename);
}
示例2: BehaviorBase
BehaviorBase() : nh("~") {
// scanSub = nh.subscribe("scans",1,&CollisionAvoidance::pc_callback,this);
scanSub = nh.subscribe("scans",1,&BehaviorBase::pc_callback,this);
velPub = nh.advertise<geometry_msgs::Twist>("vel_output",1);
nh.param("max_linear_speed",max_linear_speed, 0.0);
nh.param("max_angular_speed",max_angular_speed, 1.0);
nh.param("desired_range",desired_range, 1.0);
nh.param("k_r",k_r, 1.0);
nh.param("k_alpha",k_alpha, 1.0);
}
示例3: SpeechRecog
SpeechRecog()
{
speech_sub
= nh.subscribe("mecab_res", 1,
&SpeechRecog::speechCallback, this);
okao_sub
= nh.subscribe("/humans/RecogInfo", 1,
&SpeechRecog::okaoCallback, this);
word_srv
= nh.advertiseService("word_search",
&SpeechRecog::wordSearchCallback, this);
//recog_pub_ =
// nh.advertise<humans_msgs::Humans>("/humans/RecogInfo", 1);
//ファイルからメモリにこれまでの単語情報を書き込む機能
}
示例4: n
ExportVtk::ExportVtk(ros::NodeHandle& n):
n(n),
cloudTopic(getParam<string>("cloudTopic", "/static_point_cloud")),
mapFrame(getParam<string>("mapFrameId", "/map")),
recordOnce(getParam<bool>("recordOnce", "false")),
transformation(PM::get().TransformationRegistrar.create("RigidTransformation"))
{
// ROS initialization
cloudSub = n.subscribe(cloudTopic, 100, &ExportVtk::gotCloud, this);
// Parameters for 3D map
}
示例5: createSubscribers
void PinholeRGBDevice::createSubscribers(ros::NodeHandle & nh,
image_transport::ImageTransport & image_transport_nh,
const std::string & main_topic)
{
std::stringstream ss;
ss << main_topic << "/image";
image_sub_ = image_transport_nh.subscribe(ss.str(), 1, &PinholeRGBDevice::imageCallback, this);
ss.str("");
ss << main_topic << "/camera_info";
camera_info_sub_ = nh.subscribe(ss.str(), 1, &PinholeRGBDevice::cameraInfoCallback, this);
}
示例6: OculusDb
OculusDb(char choice) :
dbhost("192.168.4.170"),
dbuser("root"),
dbpass("tmsdb"),
dbname("rostmsdb"),
choice(choice)
{
//Init Vicon Stream
ROS_ASSERT(init_oculusdb());
// Subscriber for tms_db_data topic
data_sub = nh.subscribe("tms_db_data", 100, &OculusDb::ocMoveCallback, this);
}
示例7: ImageConverter
ImageConverter()
: it_(nh_)
{
x = 0;
y = 0;
image_sub_ = it_.subscribe("image", 1, &ImageConverter::imageCb, this);
axis_sub = nh_.subscribe("input_joy", 1, &ImageConverter::axis, this);
cv::namedWindow(WINDOW);
}
示例8:
Explore(std::string name):
as_(nh_, name, false),
action_name_(name),
ac_("move_base", true)
{
explore_state_ = STOP;
explore_ = false;
firstGoalSend = false;
as_.registerGoalCallback(boost::bind(&Explore::goalCB, this));
as_.registerPreemptCallback(boost::bind(&Explore::preemptCB, this));
as_.start();
alghoritm_state_sub_ = nh_.subscribe("alghoritm_state", 1, &Explore::alghoritmStateCallBack, this);
posSub = nh_.subscribe("/amcl_pose", 1, &Explore::poseCallback, this);
deadlock_service_state_sub = nh_.subscribe("/deadlock_service_state", 1, &Explore::deadlockServiceStateCb, this);
}
示例9: initHandlers
void BaseStation::initHandlers(ros::NodeHandle & node) {
getObstaclesPositionService = node.advertiseService("basestation/getObstaclesPosition", &BaseStation::getObstaclesPosition, this);
findRobotPositionAndAngleService = node.advertiseService("basestation/findRobotPositionAndAngle", &BaseStation::findRobotPositionAndAngle, this);
showSolvedSudocubeService = node.advertiseService("basestation/showSolvedSudocube", &BaseStation::showSolvedSudocube, this);
traceRealTrajectoryService = node.advertiseService("basestation/traceRealTrajectory", &BaseStation::traceRealTrajectory, this);
loopEndedService = node.advertiseService("basestation/loopEnded", &BaseStation::loopEnded, this);
startLoopClient = node.serviceClient<kinocto::StartLoop>("kinocto/startLoop");
setRobotPositionAndAngleClient = node.serviceClient<kinocto::SetRobotPositionAndAngle>("kinocto/setRobotPositionAndAngle");
updateRobotSubscriber = node.subscribe("basestation/updateRobotPosition", 50, &BaseStation::updateRobotPosition, this);
}
示例10: VelocitySmootherNode
VelocitySmootherNode(): nh_(), pnh_("~") {
latest_time_ = ros::Time::now();
dyn_srv_ = boost::make_shared<dyn::Server<Config> >(pnh_);
dyn::Server<Config>::CallbackType f = boost::bind(&VelocitySmootherNode::dynConfigCallback, this, _1, _2);
dyn_srv_->setCallback(f);
pub_vel_ = boost::shared_ptr<geometry_msgs::Twist>(new geometry_msgs::Twist());
pub_ = nh_.advertise<geometry_msgs::Twist>("output", 100);
sub_ = nh_.subscribe("input", 1, &VelocitySmootherNode::velCallback, this);
timer_ = nh_.createTimer(timerDuration(), &VelocitySmootherNode::timerCallback, this);
};
示例11:
Odometry() {
q = Eigen::Quaterniond(1.0, 0.0, 0.0, 0.0);
first_odo = true;
sub_odo = n.subscribe("input_odo", 1, &Odometry::getOdo, this);
sub_imu = n.subscribe("input_imu", 1, &Odometry::getImu, this);
pub_data = n.advertise<nav_msgs::Odometry>("output_pose", 1);
};
示例12: main
int main()
{
buzzer = 0;
led = 1;
nh.initNode();
nh.subscribe(sub);
while (1)
{
nh.spinOnce();
wait_ms(1);
}
}
示例13: infoCallback
void infoCallback(const sensor_msgs::CameraInfoConstPtr& info_msg)
{
if (calibrated)
return;
cam_model_.fromCameraInfo(info_msg);
pattern_detector_.setCameraMatrices(cam_model_.intrinsicMatrix(), cam_model_.distortionCoeffs());
calibrated = true;
image_sub_ = nh_.subscribe("/camera/rgb/image_mono", 1, &CalibrateKinectCheckerboard::imageCallback, this);
ROS_INFO("[calibrate] Got image info!");
}
示例14: BaseMotionController
BaseMotionController( ros::NodeHandle &n ,float x,float y, float roll,float pitch,float yaw):node_handler(n)
{
xval = x;
yval = y;
rollval=roll;
pitchval=pitch;
yawval = yaw;
// Velocity control for the YouBot base.
base_velocities_publisher = node_handler.advertise<geometry_msgs::Twist>( "/cmd_vel", 1 );
base_odom = node_handler.subscribe("/odom", 1, &BaseMotionController::OdomCallback, this);
odom_received = false;
}
示例15:
// Constructeur
Communication_API_schneider::Communication_API_schneider(ros::NodeHandle noeud,const std::string num_API)
{
// Publishers
pub_sorties = noeud.advertise<automates::Sorties>("/automates/Sorties_ap"+num_API, 1);
// Subscriber
sub_entrees = noeud.subscribe("/automates/Entrees_ap"+num_API, 1, &Communication_API_schneider::Callback_Entrees_api,this);
entrees_api=0;
sorties_api=0;
}