本文整理汇总了C++中ros::Rate::expectedCycleTime方法的典型用法代码示例。如果您正苦于以下问题:C++ Rate::expectedCycleTime方法的具体用法?C++ Rate::expectedCycleTime怎么用?C++ Rate::expectedCycleTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ros::Rate
的用法示例。
在下文中一共展示了Rate::expectedCycleTime方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
hmc5883l::hmc5883l(i2cfile* i2c_ptr, ros::NodeHandle* nh_ptr, ros::Rate rate, hmc5883l_callBackFunc dataReadyCallBack = 0) {
ROS_INFO("HMC5883L : Initializing");
char str[80];
i2c = i2c_ptr;
sem_init(&lock, 0, 1);
ctl_reg_a = (0x03 << HMC5883L_MA0) | (0x06 << HMC5883L_DO0) | (0x00 << HMC5883L_MS0);
i2c->write_byte(addr, HMC5883L_CONF_REG_A, ctl_reg_a);
mode_reg = (0x00 << HMC5883L_MD0);
i2c->write_byte(addr, HMC5883L_MODE_REG, mode_reg);
setScale(hmc5883l_scale_130);
nh = nh_ptr;
timer = nh->createTimer(rate, &hmc5883l::timerCallback, this);
if (dataReadyCallBack)
dataCallback = dataReadyCallBack;
sprintf(str, "Sampling @ %2.2f Hz", (float) 1.0f / rate.expectedCycleTime().toSec());
ROS_INFO("HMC5883L : \t%s", str);
ROS_INFO("HMC5883L : Initialization done");
}
示例2:
micromag::micromag(i2cfile* i2c_ptr, ros::NodeHandle* nh_ptr, ros::Rate rate,
micromag_callBackFunc dataReadyCallBack = 0, int windowSize = 32) {
ROS_INFO("micromag : Initializing");
char str[80];
i2c = i2c_ptr;
sem_init(&lock, 0, 1);
double freq = 1 / rate.expectedCycleTime().toSec();
setWindow(windowSize);
nh = nh_ptr;
timer = nh->createTimer(rate, µmag::timerCallback, this);
if (dataReadyCallBack)
dataCallback = dataReadyCallBack;
sprintf(str, "Sampling @ %2.2f Hz", freq);
ROS_INFO("micromag : \t%s", str);
ROS_INFO("micromag : Initialization done");
// Probe device... Return 0 on failure..
}