20 #include <nav_msgs/Odometry.h> 22 #include <boost/thread/mutex.hpp> 23 #include "geometry_msgs/Twist.h" 24 #include "geometry_msgs/PoseWithCovarianceStamped.h" 25 #include <gazebo_msgs/ModelState.h> 47 boost::mutex::scoped_lock scoped_lock(
mutex);
54 x = initialPose.pose.pose.position.x;
55 y = initialPose.pose.pose.position.y;
64 geometry_msgs::TransformStamped odom_trans;
65 odom_trans.header.stamp = current_time;
66 odom_trans.header.frame_id =
"odom";
67 odom_trans.child_frame_id =
"base_link";
69 odom_trans.transform.translation.x =
x;
70 odom_trans.transform.translation.y =
y;
71 odom_trans.transform.translation.z = 0.0;
72 odom_trans.transform.rotation = odom_quat;
83 nav_msgs::Odometry odom;
84 odom.header.stamp = current_time;
85 odom.header.frame_id =
"odom";
88 odom.pose.pose.position.x =
x;
89 odom.pose.pose.position.y =
y;
90 odom.pose.pose.position.z = 0.0;
91 odom.pose.pose.orientation = odom_quat;
94 odom.child_frame_id =
"base_link";
95 odom.twist.twist.linear.x =
vx;
96 odom.twist.twist.linear.y =
vy;
97 odom.twist.twist.angular.z =
vth;
108 gazebo_msgs::ModelState state;
109 state.model_name =
"mild";
111 state.pose.position.x =
x;
112 state.pose.position.y =
y;
113 state.pose.position.z = 0.0;
114 state.pose.orientation = odom_quat;
115 state.twist.linear.x =
vx;
116 state.twist.linear.y =
vy;
117 state.twist.angular.z =
vth;
123 int main(
int argc,
char** argv){
147 boost::mutex::scoped_lock scoped_lock(
mutex);
156 double dt = (current_time - last_time).toSec();
157 double delta_x = (
vx * cos(
th) -
vy * sin(
th)) * dt;
158 double delta_y = (
vx * sin(
th) +
vy * cos(
th)) * dt;
159 double delta_th =
vth * dt;
166 odom_broadcaster.sendTransform(
getOdomTF(current_time));
174 last_time = current_time;
nav_msgs::Odometry getOdomMsg(ros::Time current_time)
void publish(const boost::shared_ptr< M > &message) const
gazebo_msgs::ModelState getRobotStateGazebo()
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
geometry_msgs::Twist velocity_cmd
static double getYaw(const Quaternion &bt_q)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void fakeSetTargetVelocity(const geometry_msgs::Twist &cmd_vel)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
static geometry_msgs::Quaternion createQuaternionMsgFromYaw(double yaw)
geometry_msgs::TransformStamped getOdomTF(ros::Time current_time)
int main(int argc, char **argv)
ROSCPP_DECL void spinOnce()
void gotInitialRobotPose(const geometry_msgs::PoseWithCovarianceStamped &initialPose)