Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041 #ifndef JOINTTRAJECTORYACTION_H
00042 #define JOINTTRAJECTORYACTION_H
00043
00044 #include <ros/ros.h>
00045 #include <control_msgs/FollowJointTrajectoryAction.h>
00046 #include <sensor_msgs/JointState.h>
00047 #include <actionlib/server/simple_action_server.h>
00048 #include <brics_actuator/JointPositions.h>
00049 #include <brics_actuator/JointVelocities.h>
00050
00051 namespace KDL
00052 {
00053 class Trajectory_Composite;
00054 }
00055
00056 typedef actionlib::SimpleActionServer<control_msgs::FollowJointTrajectoryAction> Server;
00057
00058 class JointStateObserver;
00059
00060 class JointTrajectoryAction
00061 {
00062 public:
00063 JointTrajectoryAction(JointStateObserver* jointStateObserver);
00064 JointTrajectoryAction(JointStateObserver* youbot,
00065 double velocityGain, double positionGain, double frequency);
00066 JointTrajectoryAction(const JointTrajectoryAction& orig);
00067 virtual ~JointTrajectoryAction();
00068
00069 void execute(const control_msgs::FollowJointTrajectoryGoalConstPtr& goal, Server* as);
00070
00071 void jointStateCallback(const sensor_msgs::JointState& joint_state);
00072 void jointStateCallback(const brics_actuator::JointPositions& position,
00073 const brics_actuator::JointVelocities& velocity);
00074
00075 void setVelocityGain(double velocityGain);
00076 double getVelocityGain() const;
00077
00078
00079 void setPositionGain(double positionGain);
00080 double getPositionGain() const;
00081
00082 void setFrequency(double frequency);
00083 double getFrequency() const;
00084
00085
00086
00087 private:
00088
00089 double velocityGain;
00090 double positionGain;
00091 double frequency;
00092
00093 sensor_msgs::JointState current_state;
00094 JointStateObserver* jointStateObserver;
00095
00096 private:
00097
00098 double calculateVelocity(double actualAngle,
00099 double actualVelocity,
00100 const KDL::Trajectory_Composite& trajectoryComposite,
00101 double elapsedTimeInSec);
00102
00103 void controlLoop(const std::vector<double>& actualJointAngles,
00104 const std::vector<double>& actualJointVelocities,
00105 const KDL::Trajectory_Composite* trajectoryComposite,
00106 int numberOfJoints,
00107 ros::Time startTime,
00108 std::vector<double>& velocities);
00109
00110 void setTargetTrajectory(double angle1,
00111 double angle2,
00112 double duration,
00113 KDL::Trajectory_Composite& trajectoryComposite);
00114
00115 };
00116
00117 #endif
00118