RobotState.h
Go to the documentation of this file.
1 
20 #ifndef __ROBOT_STATE__
21 #define __ROBOT_STATE__
22 
23 #include <boost/thread/mutex.hpp>
24 #include "ros/ros.h"
25 #include "nav_msgs/Odometry.h"
32 {
33 
34  protected:
36 
37  //Position at x-axis
38  double x;
39  //Position at y-axis
40  double y;
41  //Alignment in radien
42  double th;
43  //Velocity x-axis [m/s]
44  double vx;
45  //Velocity y-axis [m/s]
46  double vy;
47  //Velocity z-axis [rad]
48  double vth;
49  boost::mutex mutex;
50  //Connection with can-bus
51  int socket;
52 
53  public:
56  RobotState(ros::NodeHandle* n, int socket) : socket(socket), n(n)
57  {
58  odom_pub = n->advertise<nav_msgs::Odometry>("odom", 50);
59  x = 0.0;
60  y = 0.0;
61  th = 0.0;
62  vx = 0.0;
63  vy = 0.0;
64  vth = 0.0;
65  };
66 
67  void sendTransformOdomTF(geometry_msgs::TransformStamped odom_trans) { odom_broadcaster.sendTransform(odom_trans); }
68 
69  void publishOdomMsg(nav_msgs::Odometry odom) { odom_pub.publish(odom); }
70 
72 
73  double getX()
74  {
75  boost::mutex::scoped_lock scoped_lock(mutex);
76  return x;
77  };
78 
79  double getY()
80  {
81  boost::mutex::scoped_lock scoped_lock(mutex);
82  return y;
83  };
84 
85  double getTh()
86  {
87  boost::mutex::scoped_lock scoped_lock(mutex);
88  return th;
89  };
90 
91  double getVX()
92  {
93  boost::mutex::scoped_lock scoped_lock(mutex);
94  return vx;
95  };
96 
97  double getVY()
98  {
99  boost::mutex::scoped_lock scoped_lock(mutex);
100  return vy;
101  };
102 
103  double getVTh()
104  {
105  boost::mutex::scoped_lock scoped_lock(mutex);
106  return vth;
107  };
108 
109  int getSocket()
110  {
111  return socket;
112  }
113 
114  void setX(double x)
115  {
116  boost::mutex::scoped_lock scoped_lock(mutex);
117  this->x = x;
118  };
119 
120  void setY(double y)
121  {
122  boost::mutex::scoped_lock scoped_lock(mutex);
123  this->y = y;
124  };
125 
126  void setTh(double th)
127  {
128  boost::mutex::scoped_lock scoped_lock(mutex);
129  this->th = th;
130  };
131 
132  void setVX(double vx)
133  {
134  boost::mutex::scoped_lock scoped_lock(mutex);
135  this->vx = vx;
136  };
137 
138  void setVY(double vy)
139  {
140  boost::mutex::scoped_lock scoped_lock(mutex);
141  this->vy = vy;
142  };
143 
144  void setVTh(double vth)
145  {
146  boost::mutex::scoped_lock scoped_lock(mutex);
147  this->vth = vth;
148  };
149 
150 };
151 
152 #endif
153 
int getSocket()
Definition: RobotState.h:109
void sendTransformOdomTF(geometry_msgs::TransformStamped odom_trans)
Definition: RobotState.h:67
double x
Definition: RobotState.h:38
void setTh(double th)
Definition: RobotState.h:126
double vth
Definition: RobotState.h:48
void setX(double x)
Definition: RobotState.h:114
void publish(const boost::shared_ptr< M > &message) const
void setVTh(double vth)
Definition: RobotState.h:144
void setY(double y)
Definition: RobotState.h:120
double getX()
Definition: RobotState.h:73
int socket
Definition: RobotState.h:51
double getTh()
Definition: RobotState.h:85
tf::TransformBroadcaster odom_broadcaster
Definition: RobotState.h:35
double getVY()
Definition: RobotState.h:97
double vy
Definition: RobotState.h:46
double th
Definition: RobotState.h:42
double y
Definition: RobotState.h:40
void setVX(double vx)
Definition: RobotState.h:132
void sendTransform(const StampedTransform &transform)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
void publishOdomMsg(nav_msgs::Odometry odom)
Definition: RobotState.h:69
double vx
Definition: RobotState.h:44
double getVTh()
Definition: RobotState.h:103
ros::Publisher odom_pub
Definition: RobotState.h:54
double getVX()
Definition: RobotState.h:91
ros::NodeHandle * n
Definition: RobotState.h:55
ros::NodeHandle * getNodeHandle()
Definition: RobotState.h:71
boost::mutex mutex
Definition: RobotState.h:49
void setVY(double vy)
Definition: RobotState.h:138
RobotState(ros::NodeHandle *n, int socket)
Definition: RobotState.h:56
double getY()
Definition: RobotState.h:79


asr_mild_base_driving
Author(s): Aumann Florian, Borella Jocelyn, Dehmani Souheil, Marek Felix, Meißner Pascal, Reckling Reno
autogenerated on Mon Jun 10 2019 12:43:40