text: /*
   *  ______                   __  __              __
   * /\  _  \           __    /\ \/\ \            /\ \__
   * \ \ \L\ \  __  __ /\_\   \_\ \ \ \____    ___\ \ ,_\   ____
   *  \ \  __ \/\ \/\ \\/\ \  /'_` \ \ '__`\  / __`\ \ \/  /',__\
   *   \ \ \/\ \ \ \_/ |\ \ \/\ \L\ \ \ \L\ \/\ \L\ \ \ \_/\__, `\
   *    \ \_\ \_\ \___/  \ \_\ \___,_\ \_,__/\ \____/\ \__\/\____/
   *     \/_/\/_/\/__/    \/_/\/__,_ /\/___/  \/___/  \/__/\/___/
   * @copyright Copyright 2017 Avidbots Corp.
   * @name	diff_drive.h
   * @brief   Diff drive plugin
   * @author  Mike Brousseau
   *
   * Software License Agreement (BSD License)
   *
   *  Copyright (c) 2017, Avidbots Corp.
   *  All rights reserved.
   *
   *  Redistribution and use in source and binary forms, with or without
   *  modification, are permitted provided that the following conditions
   *  are met:
   *
   *   * Redistributions of source code must retain the above copyright
   *     notice, this list of conditions and the following disclaimer.
   *   * Redistributions in binary form must reproduce the above
   *      copyright notice, this list of conditions and the following
   *     disclaimer in the documentation and/or other materials provided
   *     with the distribution.
   *   * Neither the name of the Avidbots Corp. nor the names of its
   *     contributors may be used to endorse or promote products derived
   *     from this software without specific prior written permission.
   *
   *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
   *  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
   *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
   *  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
   *  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
   *  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
   *  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   *  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
   *  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   *  POSSIBILITY OF SUCH DAMAGE.
   */
  
  #include <Box2D/Box2D.h>
  #include <flatland_plugins/update_timer.h>
  #include <flatland_server/model_plugin.h>
  #include <flatland_server/timekeeper.h>
  #include <geometry_msgs/Twist.h>
  #include <nav_msgs/Odometry.h>
  #include <tf/transform_broadcaster.h>
  #include <random>
  
  #ifndef FLATLAND_PLUGINS_DIFFDRIVE_H
  #define FLATLAND_PLUGINS_DIFFDRIVE_H
  
  using namespace flatland_server;
  
  namespace flatland_plugins {
  
  class DiffDrive : public flatland_server::ModelPlugin {
   public:
    ros::Subscriber twist_sub_;
    ros::Publisher odom_pub_;
    ros::Publisher ground_truth_pub_;
    ros::Publisher twist_pub_;
    ros::Time timestamp_;
    Body* body_;
    geometry_msgs::Twist twist_msg_;
    nav_msgs::Odometry odom_msg_;
    nav_msgs::Odometry ground_truth_msg_;
    UpdateTimer update_timer_;
    tf::TransformBroadcaster tf_broadcaster;  ///< For publish ROS TF
    bool enable_odom_pub_;   ///< YAML parameter to enable odom publishing
    bool enable_twist_pub_;  ///< YAML parameter to enable twist publishing
  
    std::default_random_engine rng_;
    std::array<std::normal_distribution<double>, 6> noise_gen_;
  
    /**
     * @name          OnInitialize
     * @brief         override the BeforePhysicsStep method
     * @param[in]     config The plugin YAML node
     */
    void OnInitialize(const YAML::Node& config) override;
    /**
     * @name          BeforePhysicsStep
     * @brief         override the BeforePhysicsStep method
     * @param[in]     config The plugin YAML node
     */
    void BeforePhysicsStep(const Timekeeper& timekeeper) override;
    /**
     * @name        TwistCallback
     * @brief       callback to apply twist (velocity and omega)
     * @param[in]   timestep how much the physics time will increment
     */
    void TwistCallback(const geometry_msgs::Twist& msg);
  };
  };
  
  #endif
  