JointTrajectoryController.hpp
Go to the documentation of this file.
1 #ifndef YOUBOT_JOINTTRAJECTORYCONTROLLER_H
2 #define YOUBOT_JOINTTRAJECTORYCONTROLLER_H
3 
4 /****************************************************************
5  *
6  * Copyright (c) 2011
7  * All rights reserved.
8  *
9  * Hochschule Bonn-Rhein-Sieg
10  * University of Applied Sciences
11  * Computer Science Department
12  *
13  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14  *
15  * Author:
16  * Jan Paulus, Nico Hochgeschwender, Michael Reckhaus, Azamat Shakhimardanov
17  * Supervised by:
18  * Gerhard K. Kraetzschmar
19  *
20  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
21  *
22  * This sofware is published under a dual-license: GNU Lesser General Public
23  * License LGPL 2.1 and BSD license. The dual-license implies that users of this
24  * code may choose which terms they prefer.
25  *
26  * +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
27  *
28  * Redistribution and use in source and binary forms, with or without
29  * modification, are permitted provided that the following conditions are met:
30  *
31  * * Redistributions of source code must retain the above copyright
32  * notice, this list of conditions and the following disclaimer.
33  * * Redistributions in binary form must reproduce the above copyright
34  * notice, this list of conditions and the following disclaimer in the
35  * documentation and/or other materials provided with the distribution.
36  * * Neither the name of the Hochschule Bonn-Rhein-Sieg nor the names of its
37  * contributors may be used to endorse or promote products derived from
38  * this software without specific prior written permission.
39  *
40  * This program is free software: you can redistribute it and/or modify
41  * it under the terms of the GNU Lesser General Public License LGPL as
42  * published by the Free Software Foundation, either version 2.1 of the
43  * License, or (at your option) any later version or the BSD license.
44  *
45  * This program is distributed in the hope that it will be useful,
46  * but WITHOUT ANY WARRANTY; without even the implied warranty of
47  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
48  * GNU Lesser General Public License LGPL and the BSD license for more details.
49  *
50  * You should have received a copy of the GNU Lesser General Public
51  * License LGPL and BSD license along with this program.
52  *
53  ****************************************************************/
54 #include <vector>
55 #include <string>
56 #include <cstdio>
57 #include <stdexcept>
58 #include <iostream>
65 
66 namespace youbot {
67 
68 
69 
72 struct Spline
73 {
74  std::vector<double> coef;
75 
76  Spline() : coef(6, 0.0) {}
77 };
78 
80 struct Segment
81  {
82  boost::posix_time::ptime start_time;
83  boost::posix_time::time_duration duration;
85 };
86 
91  public:
93 
94  virtual ~JointTrajectoryController();
95 
96 
97  private:
99 
100  JointTrajectoryController & operator=(const JointTrajectoryController & source);
101 
102 
103  public:
104  void getConfigurationParameter(double& PParameter, double& IParameter, double& DParameter, double& IClippingMax, double& IClippingMin);
105 
106  void setConfigurationParameter(const double PParameter, const double IParameter, const double DParameter, const double IClippingMax, const double IClippingMin);
107 
108  void setTrajectory(const JointTrajectory& input_traj);
109 
110  void cancelCurrentTrajectory();
111 
112  bool isTrajectoryControllerActive();
113 
114  bool updateTrajectoryController(const SlaveMessageInput& actual, SlaveMessageOutput& velocity);
115 
116  void getLastTargetPosition(JointAngleSetpoint& position);
117 
118  void getLastTargetVelocity(JointVelocitySetpoint& velocity);
119 
120  void setGearRatio(const double& ratio) {this->gearRatio = ratio;};
121 
122  void setEncoderTicksPerRound(const int& encoderTicks) {this->encoderTicksPerRound = encoderTicks;};
123 
124  void setInverseMovementDirection(const bool invDirection) {this->inverseDirection = invDirection;};
125 
126 
127  private:
128  void getQuinticSplineCoefficients(const double start_pos, const double start_vel, const double start_acc, const double end_pos, const double end_vel, const double end_acc, const double time, std::vector<double>& coefficients);
129 
130  void sampleQuinticSpline(const std::vector<double>& coefficients, const double time, double& position, double& velocity, double& acceleration);
131 
132  void getCubicSplineCoefficients(const double start_pos, const double start_vel, const double end_pos, const double end_vel, const double time, std::vector<double>& coefficients);
133 
134  void generatePowers(const int n, const double x, double* powers);
135 
136  void sampleSplineWithTimeBounds(const std::vector<double>& coefficients, const double duration, const double time, double& position, double& velocity, double& acceleration);
137 
139 
141 
142  boost::posix_time::ptime time;
143 
144  boost::posix_time::ptime last_time;
145 
146  typedef std::vector<Segment> SpecifiedTrajectory;
147 
149 
151 
153 
155 
157 
158  double gearRatio;
159 
161 
162  double pose_error;
163 
165 
166  double velsetpoint;
167 
169  double duration;
170  double actualpose;
171  double actualvel;
172 
173 };
174 
175 } // namespace youbot
176 #endif
DataObjectLockFree< boost::shared_ptr< const SpecifiedTrajectory > > current_trajectory_box_
boost::posix_time::ptime start_time
Set-point velocity of the joint.
Definition: JointData.hpp:182
Output part from the EtherCat message of the youBot EtherCat slaves.
void setEncoderTicksPerRound(const int &encoderTicks)
std::vector< double > coef
This DataObject is a Lock-Free implementation, such that reads and writes can happen concurrently wit...
Joint Trajectory representation.
A basic pid class.
Joint trajectory segment.
Input part from the EtherCat message of the youBot EtherCat slaves.
boost::posix_time::time_duration duration
void setInverseMovementDirection(const bool invDirection)
Set-point angle / position of the joint.
Definition: JointData.hpp:170


youbot_driver
Author(s): Jan Paulus
autogenerated on Mon Jun 10 2019 15:46:24