32 #include <std_msgs/Float32.h> 34 #include <turtlebot_actions/TurtlebotMoveAction.h> 35 #include <geometry_msgs/Twist.h> 48 turtlebot_actions::TurtlebotMoveResult
result_;
49 turtlebot_actions::TurtlebotMoveGoalConstPtr
goal_;
63 nh_(
"~"), as_(nh_, name, false), action_name_(name)
77 cmd_vel_pub_ = nh_.
advertise<geometry_msgs::Twist>(
"cmd_vel", 1);
83 feedback_.forward_distance = 0.0;
84 feedback_.turn_distance = 0.0;
86 result_.forward_distance = 0.0;
87 result_.turn_distance = 0.0;
105 ROS_INFO(
"%s: Preempted", action_name_.c_str());
113 if (fabs(distance) < 0.01)
137 geometry_msgs::Twist base_cmd;
139 base_cmd.linear.y = base_cmd.angular.z = 0;
143 base_cmd.linear.x = -base_cmd.linear.x;
150 cmd_vel_pub_.
publish(base_cmd);
165 start_transform.
inverse() * current_transform;
169 feedback_.forward_distance = dist_moved;
170 result_.forward_distance = dist_moved;
173 if(fabs(dist_moved) > fabs(distance))
178 base_cmd.linear.x = 0.0;
179 base_cmd.angular.z = 0.0;
180 cmd_vel_pub_.
publish(base_cmd);
182 if (done)
return true;
189 if (fabs(radians) < 0.01)
192 while(radians < -
M_PI) radians += 2*
M_PI;
193 while(radians >
M_PI) radians -= 2*
M_PI;
216 geometry_msgs::Twist base_cmd;
218 base_cmd.linear.x = base_cmd.linear.y = 0.0;
231 cmd_vel_pub_.
publish(base_cmd);
245 start_transform.
inverse() * current_transform;
251 feedback_.turn_distance = angle_turned;
252 result_.turn_distance = angle_turned;
255 if ( fabs(angle_turned) < 1.0
e-2)
continue;
260 if (fabs(angle_turned) > fabs(radians)) done =
true;
262 if (done)
return true;
269 int main(
int argc,
char** argv)
271 ros::init(argc, argv,
"turtlebot_move_action_server");
bool turnOdom(double radians)
boost::shared_ptr< const Goal > acceptNewGoal()
void publishFeedback(const FeedbackConstPtr &feedback)
int main(int argc, char **argv)
tfScalar getAngle() const
void publish(const boost::shared_ptr< M > &message) const
actionlib::SimpleActionServer< turtlebot_actions::TurtlebotMoveAction > as_
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ros::Publisher cmd_vel_pub_
GLsizei GLsizei GLfloat distance
void setSucceeded(const Result &result=Result(), const std::string &text=std::string(""))
ROSCPP_DECL void spin(Spinner &spinner)
void setPreempted(const Result &result=Result(), const std::string &text=std::string(""))
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
tf::TransformListener listener_
void registerPreemptCallback(boost::function< void()> cb)
turtlebot_actions::TurtlebotMoveGoalConstPtr goal_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool driveForwardOdom(double distance)
void setAborted(const Result &result=Result(), const std::string &text=std::string(""))
turtlebot_actions::TurtlebotMoveResult result_
GLuint const GLchar * name
void registerGoalCallback(boost::function< void()> cb)
MoveActionServer(const std::string name)
turtlebot_actions::TurtlebotMoveFeedback feedback_
TFSIMD_FORCE_INLINE tfScalar length() const