vehicle_model.h
Go to the documentation of this file.
00001 /* -*- mode: C++ -*-
00002  *
00003  *  Copyright (C) 2005, 2007, 2009 Austin Robot Technology
00004  *
00005  *  License: Modified BSD Software License Agreement
00006  * 
00007  *  $Id: vehicle_model.h 698 2010-10-25 15:27:01Z jack.oquin $
00008  */
00009 
00018 #ifndef _VEHICLE_MODEL_H_
00019 #define _VEHICLE_MODEL_H_ 1
00020 
00021 #include <string>
00022 #include <boost/thread/mutex.hpp>
00023 
00024 // libstage
00025 #include <stage.hh>
00026 
00027 // ROS interfaces
00028 #include <ros/ros.h>
00029 #include <tf/transform_broadcaster.h>
00030 
00031 #include <art_msgs/BrakeState.h>
00032 #include <sensor_msgs/Imu.h>
00033 #include <nav_msgs/Odometry.h>
00034 #include <art_msgs/Shifter.h>
00035 #include <art_msgs/SteeringState.h>
00036 #include <art_msgs/ThrottleState.h>
00037 
00038 // Corresponding ROS relative names
00039 #define BRAKE_STATE    "brake/state"
00040 #define SHIFTER_STATE  "shifter/state"
00041 #define STEERING_STATE "steering/state"
00042 #define THROTTLE_STATE "throttle/state"
00043 
00044 class ArtVehicleModel
00045 {
00046 public:
00047     
00048   // Constructor
00049   ArtVehicleModel(Stg::ModelPosition *stgPos,
00050                   tf::TransformBroadcaster *tfBroad,
00051                   std::string ns_prefix)
00052   {
00053     stgp_ = stgPos;                     // Stage position model
00054     tf_ = tfBroad;                      // ROS transform broadcaster
00055     ns_prefix_ = ns_prefix;             // namespace prefix
00056     tf_prefix_ = ns_prefix + "/";       // transform ID prefix
00057 
00058     // servo control status
00059     brake_position_ = 1.0;
00060     shifter_gear_ = art_msgs::Shifter::Drive;
00061     steering_angle_ = 0.0;
00062     throttle_position_ = 0.0;
00063   }
00064   ~ArtVehicleModel() {};
00065 
00066   void update(ros::Time sim_time);      // update vehicle model
00067   void setup(void);                     // set up ROS topics
00068         
00069 private:
00070 
00071   void ModelAcceleration(geometry_msgs::Twist *odomVel,
00072                          sensor_msgs::Imu *imu_msg,
00073                          ros::Time sim_time);
00074 
00075   // Stage interfaces
00076   Stg::ModelPosition *stgp_;
00077 
00078   // ROS interfaces
00079   ros::NodeHandle node_;                // simulation node handle
00080   tf::TransformBroadcaster *tf_;        // ROS transform broadcaster
00081   std::string ns_prefix_;               // vehicle namespace
00082   std::string tf_prefix_;               // transform ID prefix
00083 
00084   nav_msgs::Odometry odomMsg_;
00085   ros::Publisher odom_pub_;
00086   nav_msgs::Odometry groundTruthMsg_;
00087   ros::Publisher ground_truth_pub_;
00088   ros::Time last_update_time_;
00089 
00090   ros::Publisher imu_pub_;
00091   ros::Publisher gps_pub_;
00092 
00093   // servo device interfaces
00094   ros::Subscriber brake_sub_;
00095   ros::Subscriber shifter_sub_;
00096   ros::Subscriber steering_sub_;
00097   ros::Subscriber throttle_sub_;
00098 
00099   // servo message callbacks
00100   void brakeReceived(const art_msgs::BrakeState::ConstPtr &msg);
00101   void shifterReceived(const art_msgs::Shifter::ConstPtr &msg);
00102   void steeringReceived(const art_msgs::SteeringState::ConstPtr &msg);
00103   void throttleReceived(const art_msgs::ThrottleState::ConstPtr &msg);
00104 
00105   // servo control status
00106   //
00107   // The mutex serializes access to these fields, which are set by
00108   // message callbacks running in a separate thread.
00109   boost::mutex msg_lock_;
00110   float brake_position_;
00111   uint8_t shifter_gear_;
00112   float steering_angle_;
00113   float throttle_position_;
00114 
00115   void publishGPS(ros::Time sim_time);
00116 
00117   double origin_lat_;
00118   double origin_long_;
00119   double origin_elev_;
00120   double origin_easting_;
00121   double origin_northing_;
00122   char   origin_zone_[20];
00123   double map_origin_x_;
00124   double map_origin_y_;
00125 };
00126 
00127 #endif // _VEHICLE_MODEL_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


simulator_art
Author(s): Jack O'Quin
autogenerated on Tue Sep 24 2013 10:41:35