47 geometry_msgs::PoseStamped pose = target;
53 if (!std::isfinite(theta))
59 pose.pose.position.x += cos(theta) * -
dist_;
60 pose.pose.position.y += sin(theta) * -
dist_;
77 double r = std::sqrt(pose.pose.position.x * pose.pose.position.x +
78 pose.pose.position.y * pose.pose.position.y);
99 double delta = std::atan2(-pose.pose.position.y, pose.pose.position.x);
107 double a = atan(-
k1_ * theta);
109 double k = -1.0/r * (
k2_ * (delta - a) + (1 + (
k1_/1+((
k1_*theta)*(
k1_*theta))))*sin(delta));
141 plan.header.frame_id =
"base_link";
143 geometry_msgs::PoseStamped path_pose;
144 path_pose.header.frame_id =
"base_link";
145 path_pose.pose.orientation.w = 1.0;
146 plan.poses.push_back(path_pose);
148 for (
int i = 0; i < 20; i++)
150 path_pose.pose.position.x += 0.1 *
command_.linear.x * cos(yaw);
151 path_pose.pose.position.y += 0.1 *
command_.linear.x * sin(yaw);
153 path_pose.pose.orientation.z = sin(theta/2.0);
154 path_pose.pose.orientation.w = cos(theta/2.0);
156 double dx = path_pose.pose.position.x - pose.pose.position.x;
157 double dy = path_pose.pose.position.y - pose.pose.position.y;
158 if ((dx * dx + dy * dy) < 0.005)
163 plan.poses.push_back(path_pose);
166 plan.poses.push_back(pose);
176 if (!std::isfinite(distance) ||
177 !std::isfinite(rotate_distance))
185 geometry_msgs::PoseStamped pose;
186 pose.header.frame_id =
"base_link";
187 pose.pose.orientation.w = 1.0;
192 pose.header.frame_id,
221 if (fabs(error) < 0.05)
226 else if (rotate_distance > 0.0)
228 command_.angular.z = std::min(2.0, fabs(error)*2.0);
232 command_.angular.z = std::max(-2.0, -fabs(error)*2.0);
238 double dx = pose.pose.position.x -
start_.pose.position.x;
239 double dy = pose.pose.position.y -
start_.pose.position.y;
240 if ((dx * dx + dy * dy) > (distance * distance))
242 if (rotate_distance == 0.0)
bool approach(const geometry_msgs::PoseStamped &target)
Implements something loosely based on "A Smooth Control Law for Graceful Motion of Differential Wheel...
void stop()
send stop command to robot base
bool backup(double distance, double rotate_distance)
Back off dock, then rotate. Robot is first reversed by the prescribed distance, and then rotates with...
#define ROS_WARN_STREAM_THROTTLE(period, args)
#define ROS_ERROR_STREAM_NAMED(name, args)
static double getYaw(const Quaternion &bt_q)
ros::Publisher cmd_vel_pub_
double max_angular_velocity_
bool getCommand(geometry_msgs::Twist &command)
Get the last command sent.
void publish(const boost::shared_ptr< M > &message) const
tf::TransformListener listener_
static void quaternionMsgToTF(const geometry_msgs::Quaternion &msg, Quaternion &bt)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
def normalize_angle(angle)
geometry_msgs::PoseStamped start_
BaseController(ros::NodeHandle &nh)
geometry_msgs::Twist command_