Program Listing for File utils.hpp

Return to documentation for file (/tmp/ws/src/gazebo_ros_pkgs/gazebo_ros/include/gazebo_ros/utils.hpp)

// Copyright 2018 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef GAZEBO_ROS__UTILS_HPP_
#define GAZEBO_ROS__UTILS_HPP_

#include <gazebo/common/Time.hh>
#include <gazebo/sensors/Noise.hh>
#include <gazebo/sensors/Sensor.hh>
#include <gazebo_ros/utils_visibility_control.h>

#include <string>

#ifdef _WIN32

#include <chrono>
#include <thread>
#define usleep(usec) (std::this_thread::sleep_for(std::chrono::microseconds(usec)))

#endif  // _WIN32

namespace gazebo_ros
{

GAZEBO_ROS_UTILS_PUBLIC
double NoiseVariance(const gazebo::sensors::Noise & _noise);

GAZEBO_ROS_UTILS_PUBLIC
double NoiseVariance(const gazebo::sensors::NoisePtr & _noise_ptr);

GAZEBO_ROS_UTILS_PUBLIC
std::string ScopedNameBase(const std::string & str);

//           or the value of the sdf tag below if it is present.
GAZEBO_ROS_UTILS_PUBLIC
std::string SensorFrameID(const gazebo::sensors::Sensor & _sensor, const sdf::Element & _sdf);

class GAZEBO_ROS_UTILS_PUBLIC Throttler
{
public:
  explicit Throttler(const double _hz);
  bool IsReady(const gazebo::common::Time & _time);

private:
  double period_;
  gazebo::common::Time last_time_;
};

}  // namespace gazebo_ros
#endif  // GAZEBO_ROS__UTILS_HPP_