laser_scanner_traj_controller.h
Go to the documentation of this file.
1 /*********************************************************************
2  * Software License Agreement (BSD License)
3  *
4  * Copyright (c) 2008, Willow Garage, Inc.
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
11  * * Redistributions of source code must retain the above copyright
12  * notice, this list of conditions and the following disclaimer.
13  * * Redistributions in binary form must reproduce the above
14  * copyright notice, this list of conditions and the following
15  * disclaimer in the documentation and/or other materials provided
16  * with the distribution.
17  * * Neither the name of the Willow Garage nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *********************************************************************/
34 
35 #pragma once
36 
37 #include <ros/node_handle.h>
38 
40 #include <control_toolbox/pid.h>
41 //#include <robot_mechanism_controllers/joint_position_smoothing_controller.h>
42 
44 #include <tf/tf.h>
45 
46 #include "filters/filter_chain.h"
47 
48 // Messages
49 #include <pr2_msgs/LaserScannerSignal.h>
50 #include <pr2_msgs/PeriodicCmd.h>
51 #include <pr2_mechanism_controllers/TrackLinkCmd.h>
52 #include <pr2_msgs/LaserTrajCmd.h>
53 
54 // Services
55 #include <pr2_mechanism_controllers/SetProfile.h>
56 #include <pr2_msgs/SetPeriodicCmd.h>
57 #include <pr2_msgs/SetLaserTrajCmd.h>
58 
59 #include "boost/thread/mutex.hpp"
60 #include <boost/thread/condition.hpp>
62 
63 namespace controller
64 {
65 
67 {
68 public:
71 
73 
74  virtual void update() ;
75 
76  bool setPeriodicCmd(const pr2_msgs::PeriodicCmd& cmd) ;
77 
78  bool setTrajCmd(const pr2_msgs::LaserTrajCmd& traj_cmd) ;
79 
80  //bool setTrackLinkCmd(const pr2_mechanism_controllers::TrackLinkCmd& track_link_cmd) ;
81 
82  bool setTrajectory(const std::vector<trajectory::Trajectory::TPoint>& traj_points,
83  double max_rate, double max_acc, std::string interp ) ;
84 
86  inline double getCurProfileTime() ;
88  inline double getProfileDuration() ;
90  inline int getCurProfileSegment() ;
91 
92 private:
93 
95  pr2_mechanism_model::JointState *joint_state_ ; // Need this to check the calibrated flag on the joint
96 
97  boost::mutex traj_lock_ ; // Mutex for traj_
98  trajectory::Trajectory traj_ ; // Stores the current trajectory being executed
99 
101 
102  std::string name_ ; // The controller name. Used for ROS_INFO Messages
103 
104  ros::Time traj_start_time_ ; // The time that the trajectory was started (in seconds)
105  double traj_duration_ ; // The length of the current profile (in seconds)
106 
107 
108  double max_rate_ ; // Max allowable rate/velocity
109  double max_acc_ ; // Max allowable acceleration
110 
111  // Control loop state
112  control_toolbox::Pid pid_controller_ ; // Position PID Controller
113  filters::FilterChain<double> d_error_filter_chain_; // Filter on derivative term of error
114  ros::Time last_time_ ; // The previous time at which the control loop was run
115  double last_error_ ; // Error for the previous time at which the control loop was run
116  double tracking_offset_ ; // Position cmd generated by the track_link code
117  double traj_command_ ; // Position cmd generated by the trajectory code
118 };
119 
121 {
122 public:
125 
126  void update() ;
127 
129 
130  // Message Callbacks
131  void setPeriodicCmd(const pr2_msgs::PeriodicCmdConstPtr &cmd);
132  void setTrajCmd(const pr2_msgs::LaserTrajCmdConstPtr &traj_cmd);
133  //void setTrackLinkCmd() ;
134  bool setPeriodicSrv(pr2_msgs::SetPeriodicCmd::Request &req,
135  pr2_msgs::SetPeriodicCmd::Response &res);
136  bool setTrajSrv(pr2_msgs::SetLaserTrajCmd::Request &req,
137  pr2_msgs::SetLaserTrajCmd::Response &res);
138 
139 
140 private:
146 
149  std::string service_prefix_ ;
150 
152 
153  pr2_mechanism_controllers::TrackLinkCmd track_link_cmd_ ;
154 
155  pr2_msgs::LaserScannerSignal m_scanner_signal_ ;
158 };
159 
160 }
pr2_msgs::LaserScannerSignal m_scanner_signal_
Stores the message that we want to send at the end of each sweep, and halfway through each sweep...
filters::FilterChain< double > d_error_filter_chain_
int getCurProfileSegment()
Returns the current trajectory segment we&#39;re executing in our current profile.
bool init(pr2_mechanism_model::RobotState *robot, ros::NodeHandle &n)
double getProfileDuration()
Returns the length (in seconds) of our current profile.
pr2_mechanism_model::JointState * joint_state_
bool setPeriodicCmd(const pr2_msgs::PeriodicCmd &cmd)
bool need_to_send_msg_
Tracks whether we still need to send out the m_scanner_signal_ message.
int prev_profile_segment_
The segment in the current profile when update() was last called.
double getCurProfileTime()
Returns what time we&#39;re currently at in the profile being executed.
bool setTrajCmd(const pr2_msgs::LaserTrajCmd &traj_cmd)
realtime_tools::RealtimePublisher< pr2_msgs::LaserScannerSignal > * publisher_
Publishes the m_scanner_signal msg from the update() realtime loop.
bool setTrajectory(const std::vector< trajectory::Trajectory::TPoint > &traj_points, double max_rate, double max_acc, std::string interp)
pr2_mechanism_controllers::TrackLinkCmd track_link_cmd_


pr2_mechanism_controllers
Author(s): Sachin Chita, John Hsu, Melonee Wise
autogenerated on Mon Jun 10 2019 14:26:33