Go to the documentation of this file.
39 constexpr
char LOGNAME[] =
"pose_tracking";
40 constexpr
double DEFAULT_LOOP_RATE = 100;
41 constexpr
double ROS_STARTUP_WAIT = 10;
50 , loop_rate_(DEFAULT_LOOP_RATE)
51 , transform_listener_(transform_buffer_)
52 , stop_requested_(false)
53 , angular_error_(
boost::none)
76 nh_.
advertise<geometry_msgs::TwistStamped>(
servo_->getParameters().cartesian_command_in_topic, 1);
80 const double angular_tolerance,
const double target_pose_timeout)
153 <<
"planning_frame");
157 std::size_t error = 0;
167 double publish_period;
202 bool use_anti_windup =
true;
229 return ((std::abs(x_error) < positional_tolerance(0)) && (std::abs(y_error) < positional_tolerance(1)) &&
230 (std::abs(z_error) < positional_tolerance(2)) && (std::abs(*
angular_error_) < angular_tolerance));
261 auto msg = moveit::util::make_shared_from_pool<geometry_msgs::TwistStamped>();
264 geometry_msgs::Twist& twist = msg->twist;
265 Eigen::Quaterniond q_desired;
289 Eigen::Quaterniond q_error = q_desired * q_current.inverse();
292 Eigen::AngleAxisd axis_angle(q_error);
295 double ang_vel_magnitude =
297 twist.angular.x = ang_vel_magnitude * axis_angle.axis()[0];
298 twist.angular.y = ang_vel_magnitude * axis_angle.axis()[1];
299 twist.angular.z = ang_vel_magnitude * axis_angle.axis()[2];
311 auto msg = moveit::util::make_shared_from_pool<geometry_msgs::TwistStamped>();
334 const double x_derivative_gain,
const double y_proportional_gain,
335 const double y_integral_gain,
const double y_derivative_gain,
336 const double z_proportional_gain,
const double z_integral_gain,
337 const double z_derivative_gain,
const double angular_proportional_gain,
338 const double angular_integral_gain,
const double angular_derivative_gain)
368 double dummy1, dummy2;
#define ROS_WARN_STREAM_THROTTLE_NAMED(period, name, args)
bool haveRecentTargetPose(const double timeout)
Return true if a target pose has been received within timeout [seconds].
@ NO_RECENT_END_EFFECTOR_POSE
planning_scene_monitor::PlanningSceneMonitorPtr planning_scene_monitor_
bool haveRecentEndEffectorPose(const double timeout)
Return true if an end effector pose has been received within timeout [seconds].
Duration expectedCycleTime() const
void getPIDErrors(double &x_error, double &y_error, double &z_error, double &orientation_error)
void resetTargetPose()
Re-initialize the target pose to an empty message. Can be used to reset motion between waypoints.
bool get(const std::string &parent_name, const ros::NodeHandle &nh, const std::string ¶m_name, bool &value)
std::vector< control_toolbox::Pid > cartesian_orientation_pids_
std::vector< control_toolbox::Pid > cartesian_position_pids_
std::string move_group_name_
geometry_msgs::PoseStamped target_pose_
template Halfspace< double > transform(const Halfspace< double > &a, const Transform3< double > &tf)
ros::Time command_frame_transform_stamp_
void publish(const boost::shared_ptr< M > &message) const
Publisher advertise(AdvertiseOptions &ops)
void doPostMotionReset()
Reset flags and PID controllers after a motion completes.
bool satisfiesPoseTolerance(const Eigen::Vector3d &positional_tolerance, const double angular_tolerance)
Check if XYZ, roll/pitch/yaw tolerances are satisfied.
void updatePIDConfig(const double x_proportional_gain, const double x_integral_gain, const double x_derivative_gain, const double y_proportional_gain, const double y_integral_gain, const double y_derivative_gain, const double z_proportional_gain, const double z_integral_gain, const double z_derivative_gain, const double angular_proportional_gain, const double angular_integral_gain, const double angular_derivative_gain)
Change PID parameters. Motion is stopped before the udpate.
static const char LOGNAME[]
robot_model::RobotModelConstPtr robot_model_
geometry_msgs::TwistStampedConstPtr calculateTwistCommand()
Use PID controllers to calculate a full spatial velocity toward a pose.
#define ROS_ERROR_STREAM_NAMED(name, args)
Eigen::Isometry3d command_frame_transform_
void stopMotion()
A method for a different thread to stop motion and return early from control loop.
bool hasParam(const std::string &key) const
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())
boost::optional< double > angular_error_
#define ROS_WARN_STREAM_NAMED(name, args)
ros::Publisher twist_stamped_pub_
const ROSCPP_DECL std::string & getName()
std::mutex target_pose_mtx_
void doTransform(const T &data_in, T &data_out, const geometry_msgs::TransformStamped &transform)
std::atomic< bool > stop_requested_
#define ROS_INFO_STREAM_NAMED(name, args)
PIDConfig angular_pid_config_
const moveit::core::JointModelGroup * joint_model_group_
PoseTrackingStatusCode moveToPose(const Eigen::Vector3d &positional_tolerance, const double angular_tolerance, const double target_pose_timeout)
ros::Subscriber target_pose_sub_
tf2_ros::Buffer transform_buffer_
PoseTracking(const ros::NodeHandle &nh, const planning_scene_monitor::PlanningSceneMonitorPtr &planning_scene_monitor)
Constructor. Loads ROS parameters under the given namespace.
void readROSParams()
Load ROS parameters for controller settings.
void targetPoseCallback(const geometry_msgs::PoseStampedConstPtr &msg)
Subscribe to the target pose on this topic.
void shutdownIfError(const std::string &parent_name, std::size_t error_count)
std::unique_ptr< moveit_servo::Servo > servo_
virtual geometry_msgs::TransformStamped lookupTransform(const std::string &target_frame, const ros::Time &target_time, const std::string &source_frame, const ros::Time &source_time, const std::string &fixed_frame, const ros::Duration timeout) const
std::string planning_frame_
bool getCommandFrameTransform(geometry_msgs::TransformStamped &transform)
void initializePID(const PIDConfig &pid_config, std::vector< control_toolbox::Pid > &pid_vector)
Initialize a PID controller and add it to vector of controllers.
moveit_servo
Author(s): Brian O'Neil, Andy Zelenak
, Blake Anderson, Alexander Rössler , Tyler Weaver
autogenerated on Sat May 3 2025 02:27:56