Go to the documentation of this file.
30 ROS_INFO(
"Initialized mobile robot simulator");
54 ROS_INFO(
"Started mobile robot simulator update loop, listening on cmd_vel topic");
61 ROS_INFO(
"Stopped mobile robot simulator");
86 ROS_DEBUG_STREAM(
"Velocity - x: " << vel.linear.x <<
" y: " << vel.linear.y <<
" th: " << vel.angular.z);
88 double delta_x = (vel.linear.x * cos(
th) - vel.linear.y * sin(
th)) * time_diff.
toSec();
89 double delta_y = (vel.linear.x * sin(
th) + vel.linear.y * cos(
th)) * time_diff.
toSec();
90 double delta_th = vel.angular.z * time_diff.
toSec();
91 ROS_DEBUG_STREAM(
"Delta - x: " << delta_x <<
" y: " << delta_y <<
" th: " << delta_th);
95 odom.header.frame_id =
"odom";
96 odom.pose.pose.position.x += delta_x;
97 odom.pose.pose.position.y += delta_y;
103 odom.twist.twist = vel;
109 geometry_msgs::TransformStamped odom_tmp;
111 odom_tmp.header =
odom.header;
112 odom_tmp.child_frame_id =
odom.child_frame_id;
113 odom_tmp.transform.translation.x =
odom.pose.pose.position.x;
114 odom_tmp.transform.translation.y =
odom.pose.pose.position.y;
115 odom_tmp.transform.translation.z = 0.0;
116 odom_tmp.transform.rotation =
odom.pose.pose.orientation;
123 ROS_DEBUG(
"Received message on cmd_vel");
129 geometry_msgs::Twist vel = *msg;
135 if (msg->header.frame_id !=
"map") {
136 ROS_ERROR(
"Initial pose not specified in map frame, ignoring");
139 ROS_INFO(
"Received pose estimate of mobile base");
143 msg_t.
setOrigin(tf::Vector3(msg->pose.pose.position.x,msg->pose.pose.position.y,msg->pose.pose.position.z));
144 msg_t.
setRotation(
tf::Quaternion(msg->pose.pose.orientation.x,msg->pose.pose.orientation.y,msg->pose.pose.orientation.z,msg->pose.pose.orientation.w));
tf::StampedTransform map_trans
tf::TransformBroadcaster tf_broadcaster
void get_tf_from_odom(nav_msgs::Odometry odom)
std::string base_link_frame
#define ROS_DEBUG_STREAM(args)
void publish(const boost::shared_ptr< M > &message) const
Publisher advertise(AdvertiseOptions &ops)
void vel_callback(const geometry_msgs::Twist::ConstPtr &msg)
bool publish_map_transform
void update_loop(const ros::TimerEvent &event)
void init_pose_callback(const geometry_msgs::PoseWithCovarianceStamped::ConstPtr &msg)
static void transformStampedMsgToTF(const geometry_msgs::TransformStamped &msg, StampedTransform &bt)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, const boost::function< void(C)> &callback, const VoidConstPtr &tracked_object=VoidConstPtr(), const TransportHints &transport_hints=TransportHints())
std::string velocity_topic
T param(const std::string ¶m_name, const T &default_val) const
ros::Subscriber init_pose_sub
void update_odom_from_vel(geometry_msgs::Twist vel, ros::Duration time_diff)
MobileRobotSimulator(ros::NodeHandle *nh)
static geometry_msgs::Quaternion createQuaternionMsgFromYaw(double yaw)
Timer createTimer(Duration period, const TimerCallback &callback, bool oneshot=false, bool autostart=true) const
std::string odometry_topic
tf::StampedTransform odom_trans