当前位置: 首页>>代码示例>>C++>>正文


C++ Time::to_double方法代码示例

本文整理汇总了C++中ros::Time::to_double方法的典型用法代码示例。如果您正苦于以下问题:C++ Time::to_double方法的具体用法?C++ Time::to_double怎么用?C++ Time::to_double使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ros::Time的用法示例。


在下文中一共展示了Time::to_double方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: imu_callback

void imu_callback(std::string name, std_msgs::PoseWithRatesStamped* imu, ros::Time t, void* f)
{
  FILE* file = (FILE*)f;

  fprintf(file, "%.5f %.5f %.5f %.5f %.5f %.5f %.5f %.5f\n",
          t.to_double(),
          imu->header.stamp.to_double(),
          imu->acc.acc.ax, imu->acc.acc.ay, imu->acc.acc.az,
          imu->vel.ang_vel.vx, imu->vel.ang_vel.vy, imu->vel.ang_vel.vz);
}
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:10,代码来源:imu_extract.cpp

示例2: imu_callback

void imu_callback(std::string name, imu_node::ImuData* imu, ros::Time t, void* f)
{
  FILE* file = (FILE*)f;

  fprintf(file, "%.5f %.5f %.5f %.5f %.5f %.5f %.5f %.5f\n",
          t.to_double(),
          imu->header.stamp.to_double(),
          imu->accel.ax, imu->accel.ay, imu->accel.az,
          imu->angrate.vx, imu->angrate.vy, imu->angrate.vz);
}
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:10,代码来源:imu_extract.cpp

示例3: odom_callback

void odom_callback(string name, std_msgs::RobotBase2DOdom* odom, ros::Time t, void* n)
{
  double rel_time = t.to_double();

  static bool vel_init = false;
  static double yaw_offset = 0;

  if (!vel_init)
  {
    vel_init = true;
    dumb_rv = dumb_tv = 0;
    prev_time = rel_time;
    test_log = fopen("test.txt", "w");
  }
  else
  {
    double next_th = odom->pos.th + yaw_offset;
    if (fabs(next_th - prev_th) > M_PI)
    {
      if (next_th > prev_th)
        yaw_offset -= 2 * M_PI;
      else
        yaw_offset += 2 * M_PI;
    }
    odom->pos.th += yaw_offset;
    double dt = rel_time - prev_time;
    double dx = odom->pos.x - prev_x;
    double dy = odom->pos.y - prev_y;
    dumb_rv = (odom->pos.th - prev_th) / dt;
    dumb_tv = sqrt(dx*dx + dy*dy) / dt;
    fprintf(test_log, "%f %f %f %f %f %f\n", 
            odom->pos.x, odom->pos.y, odom->pos.th, dumb_tv, dumb_rv, dt);
  }
  prev_x  = odom->pos.x;
  prev_y  = odom->pos.y;
  prev_th = odom->pos.th;
  prev_time = rel_time;
  fprintf(clog, "ODOM %f %f %f %f %f 0 %f logsetta %f\n", 
          odom->pos.x, odom->pos.y, odom->pos.th,
          dumb_tv, dumb_rv, rel_time, rel_time);
}
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:41,代码来源:genlog_carmen.cpp

示例4: scan_callback

void scan_callback(string name, std_msgs::LaserScan* scan, ros::Time t, void* n)
{

  double rel_time = t.to_double();

  const double fov = fabs(scan->angle_max - scan->angle_min);
  // only make an exception for the SICK LMS2xx running in centimeter mode
  const double acc = (scan->range_max >= 81 ? 0.05 : 0.005); 
  fprintf(clog, "ROBOTLASER1 0 %f %f %f %f %f 0 %d ",
          scan->angle_min, fov, fov / scan->angle_increment,
          scan->range_max, acc, scan->get_ranges_size());
  for (uint32_t i = 0; i < scan->get_ranges_size(); i++)
    fprintf(clog, "%.3f ", scan->ranges[scan->get_ranges_size() - i - 1]);
  double laser_x = prev_x + 0.30 * cos(prev_th); // in the robot frame
  double laser_y = prev_y + 0.30 * sin(prev_th);
  double laser_th = prev_th;
  double laser_rv = dumb_rv; // not really
  double laser_tv = dumb_tv; // not really
  fprintf(clog, " 0 %f %f %f %f %f %f %f %f 0.3 0.3 1000000 %f logsetta %f\n",
          laser_x, laser_y, laser_th,
          prev_x, prev_y, prev_th,
          laser_tv, laser_rv, rel_time,
          rel_time);
}
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:24,代码来源:genlog_carmen.cpp


注:本文中的ros::Time::to_double方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。