generator  1.2
RoboticLine.h
Go to the documentation of this file.
1 /*
2  This file is part of the GeneratorOfDatasets program.
3 
4  GeneratorOfDatasets is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  GeneratorOfDatasets is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with GeneratorOfDatasets. If not, see <http://www.gnu.org/licenses/>.
16 */
17 #ifndef HLIDAC_PES_ROBOTIC_LINE_H
18 #define HLIDAC_PES_ROBOTIC_LINE_H
19 
26 #include <iostream>
27 #include <stdint.h>
28 #include <sstream>
29 #include <string>
30 #include <vector>
31 #include <utility>
32 #include "ProjectParameters.h"
33 
37 struct Monomial {
38  int32_t degree;
39  double coeff;
40 };
41 
50  IN, OUT, INNER, WAIT, MOVEMENT,
51 };
52 
60 template <class T>
61 std::string numberToString(const T& number) {
62  std::ostringstream ss;
63  ss<<number;
64  return ss.str();
65 }
66 
70 class Movement {
71  public:
78  Movement(const uint32_t& from, const uint32_t& to, const ProjectParameters& par);
79 
80  uint32_t from() const { return mFrom; }
81  uint32_t to() const { return mTo; }
82  double minDuration() const { return mMinDuration; }
83  double maxDuration() const { return mMaxDuration; }
84  std::vector<Monomial> energyFunction() const { return mEnergyFunction; }
85  private:
87  uint32_t mFrom;
89  uint32_t mTo;
91  double mMinDuration;
93  double mMaxDuration;
98  std::vector<Monomial> mEnergyFunction;
99 };
100 
108  public:
115  RobotPowerMode(const uint32_t& pid, const double& delay) : mPid(pid), mMinimalDelay(delay), mExpectedInputPower(-1.0) { }
116 
117  uint32_t pid() const { return mPid; }
118  void pid(const uint32_t& pid) { mPid = pid; }
119  void powerSaveModeName(const std::string& name) { mName = name; }
120  std::string powerSaveModeName() const { return mName; }
121  double minimalDelay() const { return mMinimalDelay; }
122  double expectedInputPower() const { return mExpectedInputPower; }
123  void expectedInputPower(const double& expectedInputPower) { mExpectedInputPower = expectedInputPower; }
124  private:
126  uint32_t mPid;
128  std::string mName;
133 };
134 
143  public:
150  LocationDependentPowerConsumption(RobotPowerMode* mode, const uint32_t& modeIdx, const ProjectParameters& par);
151 
152  RobotPowerMode* robotModeRef() const { return mMode; }
153  double inputPower() const { return mInputPower; }
154  private:
158  double mInputPower;
159 };
160 
166 class Location {
167  public:
174  Location(const uint32_t& point, const std::vector<RobotPowerMode*>& robotModes, const ProjectParameters& par);
175 
176  uint32_t point() const { return mPoint; }
177  std::vector<LocationDependentPowerConsumption> locationDependentPowerConsumption() const {
179  }
180  private:
182  uint32_t mPoint;
184  std::vector<LocationDependentPowerConsumption> mLocationDependentPowerConsumption;
185 };
186 
193 class Activity {
194  public:
200  Activity(const uint32_t& aid, const ActivityType& type) : mAid(aid), mType(type),
201  mMinAbsDuration(std::numeric_limits<double>::max()), mMaxAbsDuration(std::numeric_limits<double>::min()) { }
202 
203  uint32_t aid() const { return mAid; }
204  ActivityType type() const { return mType; }
205  void successors(const std::vector<Activity*>& successors) { mSuccessors = successors; }
206  void addSuccessor(Activity* successor) { mSuccessors.push_back(successor); }
207  std::vector<Activity*> successors() const { return mSuccessors; }
208  void predecessors(const std::vector<Activity*>& predecessors) { mPredecessors = predecessors; }
209  void addPredecessor(Activity* predecessor) { mPredecessors.push_back(predecessor); }
210  std::vector<Activity*> predecessors() const { return mPredecessors; }
211  void minAbsDuration(const double& minAbsDuration) { mMinAbsDuration = minAbsDuration; }
212  double minAbsDuration() const { return mMinAbsDuration; }
213  void maxAbsDuration(const double& maxAbsDuration) { mMaxAbsDuration = maxAbsDuration; }
214  double maxAbsDuration() const { return mMaxAbsDuration; }
215  virtual size_t numberOfModes() const = 0;
216 
217  virtual ~Activity() { }
218  private:
219  Activity(const Activity&) = delete;
220  Activity& operator=(const Activity&) = delete;
221  protected:
223  uint32_t mAid;
227  std::vector<Activity*> mSuccessors;
229  std::vector<Activity*> mPredecessors;
234 };
235 
241 class StaticActivity : public Activity {
242  public:
251  StaticActivity(const uint32_t& aid, uint32_t& fromPoint, const ActivityType& type,
252  const std::vector<RobotPowerMode*>& robotModes, const ProjectParameters& par);
253 
254  std::vector<Location*> locations() const { return mLocations; }
255  virtual size_t numberOfModes() const override { return mLocations.size(); }
256 
258  virtual ~StaticActivity() override;
259  private:
261  std::vector<Location*> mLocations;
262 };
263 
270 class DynamicActivity: public Activity {
271  public:
279  DynamicActivity(const uint32_t& aid, StaticActivity* fromActivity,
280  StaticActivity* toActivity, const ProjectParameters& par);
281 
282  std::vector<Movement*> movements() const { return mMovements; }
283  virtual size_t numberOfModes() const override { return mMovements.size(); }
284 
286  virtual ~DynamicActivity() override;
287  private:
289  std::vector<Movement*> mMovements;
290 };
291 
297 class Robot {
298  private:
308  std::vector<StaticActivity*> in, w, out;
309  std::vector<DynamicActivity*> mv;
310  std::vector<StaticActivity*> con1, con2;
311  };
312 
313  public:
322  Robot(uint32_t& fromActivityId, uint32_t& fromPointId, const uint32_t& numberOfInputs, const uint32_t& numberOfOutputs, const ProjectParameters& par);
323 
324  std::vector<Activity*> activities() const { return mActivities; }
325  std::vector<RobotPowerMode*> robotModes() const { return mRobotModes; }
326 
331  double lowerBoundOfCycleTime() const;
332 
334  ~Robot();
335  private:
336 
337  Robot(const Robot&) = delete;
338  Robot& operator=(const Robot&) = delete;
339 
340 
347  mCompositeBlock createSerialSequence(uint32_t& fromActivityId, uint32_t& fromPointId) const;
356  mCompositeBlock createAssemblyBlock(uint32_t& fromActivityId, uint32_t& fromPointId, const uint32_t& numberOfInputs) const;
365  mCompositeBlock createDisassemblyBlock(uint32_t& fromActivityId, uint32_t& fromPointId, const uint32_t& numberOfOutputs) const;
375  mCompositeBlock createComplexBlockHelper(uint32_t& fromActivityId, uint32_t& fromPointId, const uint32_t& numberOfSeq, const std::string& op) const;
376 
388  mCompositeBlock createBlockOfOperations(uint32_t& fromActivityId, uint32_t& fromPointId, const ActivityType& t1,
389  const ActivityType& t2, const Interval<uint32_t>& numSeq, const Interval<uint32_t>& seqLength) const;
397  void connect(uint32_t& fromActivityId, mCompositeBlock& b, const std::vector<StaticActivity*>& from,
398  const std::vector<StaticActivity*>& to, bool fullyConnected = true) const;
399 
406  mCompositeBlock mergeBlocks(const std::vector<mCompositeBlock>& blocks) const;
407 
408 
412  std::vector<Activity*> mActivities;
414  std::vector<RobotPowerMode*> mRobotModes;
415 };
416 
423 class TimeLag {
424  public:
431  TimeLag(Activity* from, Activity* to, const double& length, const int32_t& height)
432  : mFrom(from), mTo(to), mLength(length), mHeight(height) { }
433 
434  Activity* from() const { return mFrom; }
435  Activity* to() const { return mTo; }
436  double length() const { return mLength; }
437  int32_t height() const { return mHeight; }
438  private:
444  double mLength;
446  int32_t mHeight;
447 };
448 
453 class Pair {
454  public:
460  Pair(Activity* activity1, const uint32_t& mode1, Activity* activity2, const uint32_t& mode2) :
461  mActivity1(activity1), mActivity2(activity2), mMode1(mode1), mMode2(mode2) { }
462 
463  Activity* activity1() const { return mActivity1; }
464  uint32_t mode1() const { return mMode1; }
465  Activity* activity2() const { return mActivity2; }
466  uint32_t mode2() const { return mMode2; }
467 
473  bool operator==(const Pair& p) const;
474 
475  private:
476 
482  uint32_t mMode1;
484  uint32_t mMode2;
485 };
486 
487 namespace std {
491  template <>
492  struct hash<Pair> {
498  size_t operator() (const Pair& p) const {
499  hash<Activity*> ptrHash;
500  hash<uint32_t> modeHash;
501  return ptrHash(p.activity1())^ptrHash(p.activity2())^modeHash(p.mode1())^modeHash(p.mode2());
502  }
503  };
504 }
505 
513  public:
521  InterRobotOperation(uint32_t oid, Activity* out, Activity* in, const ProjectParameters& par);
522 
523  uint32_t oid() const { return mOid; }
524  std::string name() const { return mName; }
525  void name(const std::string& name) { mName = name; }
526  std::vector<TimeLag> timeLags() const { return mTimeLags; }
527  void timeLags(const std::vector<TimeLag>& timeLags) { mTimeLags = timeLags; }
528  std::vector<Pair> spatialCompatibility() const { return mSpatialCompatibility; }
529 
530  private:
531 
537 
539  uint32_t mOid;
541  std::string mName;
543  std::vector<TimeLag> mTimeLags;
545  std::vector<Pair> mSpatialCompatibility;
546 };
547 
553 class RoboticLine {
554  public:
559  RoboticLine(const ProjectParameters& par);
560 
561  std::vector<Robot*> robots() const { return mRobots; }
562  std::vector<InterRobotOperation> interRobotOperations() const { return mInterRobotOperations; }
563  std::vector<Pair> collisions() const { return mCollisions; }
564  double productionCycleTime() const { return mProductionCycleTime; }
565  std::vector<std::string> warnings() const { return mWarnings; }
566 
568  ~RoboticLine();
569  private:
570  RoboticLine(const RoboticLine&) = delete;
571  RoboticLine& operator=(const RoboticLine&) = delete;
572 
577  void generateCollisions(const ProjectParameters& par);
583 
585  std::vector<Robot*> mRobots;
587  std::vector<InterRobotOperation> mInterRobotOperations;
589  std::vector<Pair> mCollisions;
592 
594  std::vector<std::string> mWarnings;
595 };
596 
597 #endif
The class represents the robot movement between two coordinates.
Definition: RoboticLine.h:70
double mProductionCycleTime
The calculated production cycle time for *this robotic cell.
Definition: RoboticLine.h:591
mCompositeBlock createBlockOfOperations(uint32_t &fromActivityId, uint32_t &fromPointId, const ActivityType &t1, const ActivityType &t2, const Interval< uint32_t > &numSeq, const Interval< uint32_t > &seqLength) const
It is a core method for the decomposition of the robot work to well-defined blocks.
Auxiliary class encapsulating two activities to form collision or spatial compatibility pair...
Definition: RoboticLine.h:453
Activity * mActivity2
Second activity.
Definition: RoboticLine.h:480
void generateSpatialCompatibilityPairs(Activity *a1, Activity *a2)
It is an auxiliary method for the constructor that helps to generate the compatibility pairs...
The base class incorporating common properties for robot operations and movements.
Definition: RoboticLine.h:193
The structure with desired properties for the generated instances.
TimeLag(Activity *from, Activity *to, const double &length, const int32_t &height)
It initializes the time lag between two activities.
Definition: RoboticLine.h:431
ActivityType mType
The type of the activity, see ActivityType enum.
Definition: RoboticLine.h:225
The class specifies input power of the robot for a particular robot configuration.
Definition: RoboticLine.h:142
uint32_t mAid
Identification of the activity.
Definition: RoboticLine.h:223
Instance of the class includes all the data structures and methods related to a robot.
Definition: RoboticLine.h:297
RobotPowerMode * mMode
A pointer to the related power saving mode of the robot.
Definition: RoboticLine.h:156
Pair(Activity *activity1, const uint32_t &mode1, Activity *activity2, const uint32_t &mode2)
It initializes the structure representing the pair of activities.
Definition: RoboticLine.h:460
Activity * mFrom
The activity from which the arc is leaving.
Definition: RoboticLine.h:440
Location(const uint32_t &point, const std::vector< RobotPowerMode * > &robotModes, const ProjectParameters &par)
It constructs the object representing a location of an operation from the robot point of view...
Definition: RoboticLine.cpp:51
bool operator==(const Pair &p) const
It compares two Pair data-structures and returns the result of comparison.
std::vector< InterRobotOperation > mInterRobotOperations
Inter-robot operations for a weldment/workpiece passing.
Definition: RoboticLine.h:587
std::vector< Location * > mLocations
The collection of possible robot configurations, i.e. locations, for this operation.
Definition: RoboticLine.h:261
~Robot()
It frees the memory occupied by dynamically allocated activities and power saving modes...
double mExpectedInputPower
Expected input power of the robot if it is not dependent on the robot configuration (joint values)...
Definition: RoboticLine.h:132
Collection of movements between two static activities.
Definition: RoboticLine.h:270
void generateCollisions(const ProjectParameters &par)
It generates collisions between robots.
uint32_t mOid
Integer identification of the inter-robot operation.
Definition: RoboticLine.h:539
Activity(const uint32_t &aid, const ActivityType &type)
The base constructor called from the derived classes for initialization of attributes.
Definition: RoboticLine.h:200
STL namespace.
ProjectParameters mParameters
Desired properties of generated instances defined in the input configuration file.
Definition: RoboticLine.h:410
std::vector< RobotPowerMode * > mRobotModes
Available power saving modes for this robot.
Definition: RoboticLine.h:414
uint32_t mPid
Identification of the robot power saving mode, unique for the robot.
Definition: RoboticLine.h:126
std::vector< std::string > mWarnings
Warnings produced during the generation of this robotic cell. Written to the console later to not mix...
Definition: RoboticLine.h:594
std::vector< Pair > mCollisions
Collisions between robots.
Definition: RoboticLine.h:589
std::vector< Robot * > mRobots
Robots incorporated in the robotic cell.
Definition: RoboticLine.h:585
uint32_t mMode2
The mode of the second activity, i.e. a movement or location identification.
Definition: RoboticLine.h:484
uint32_t mPoint
Identification of the robot configuration for the given location and operation.
Definition: RoboticLine.h:182
InterRobotOperation(uint32_t oid, Activity *out, Activity *in, const ProjectParameters &par)
It creates the inter-robot operation according the desired parameters stated in ProjectParameters dat...
virtual ~DynamicActivity() override
It frees the memory occupied by dynamically allocated movements.
ActivityType
Definition: RoboticLine.h:49
Movement(const uint32_t &from, const uint32_t &to, const ProjectParameters &par)
The constructor creates the movement according to the desired properties given in the project configu...
Definition: RoboticLine.cpp:34
virtual ~StaticActivity() override
It frees the memory occupied by dynamically allocated locations.
Definition: RoboticLine.cpp:85
uint32_t mTo
Identification of the end coordinate of the movement.
Definition: RoboticLine.h:89
double mLength
The time offset of the inter-robot arc.
Definition: RoboticLine.h:444
Collection of locations in which a robot operation can be performed.
Definition: RoboticLine.h:241
Activity * mTo
The activity to which the arc is entering.
Definition: RoboticLine.h:442
The file declares the structure for storing the properties of generated instances.
It represents the part of energy functions, i.e. where is the duration of the movement.
Definition: RoboticLine.h:37
~RoboticLine()
It frees all the memory occupied by robots.
It represents the power saving mode of the robot.
Definition: RoboticLine.h:107
double mMaxAbsDuration
The maximal absolute duration of the activity to remain feasible.
Definition: RoboticLine.h:233
double mMinDuration
The minimal possible duration of the robot movement.
Definition: RoboticLine.h:91
StaticActivity(const uint32_t &aid, uint32_t &fromPoint, const ActivityType &type, const std::vector< RobotPowerMode * > &robotModes, const ProjectParameters &par)
It generates the static activity, i.e. robot operation, according to the configuration.
Definition: RoboticLine.cpp:58
std::vector< Activity * > mSuccessors
The successors of the activity.
Definition: RoboticLine.h:227
The structure containing the activities in a block.
Definition: RoboticLine.h:307
Instance of TimeLag class defines a time relation between two different robots.
Definition: RoboticLine.h:423
int32_t mHeight
The time offset in the number of cycles.
Definition: RoboticLine.h:446
void connect(uint32_t &fromActivityId, mCompositeBlock &b, const std::vector< StaticActivity * > &from, const std::vector< StaticActivity * > &to, bool fullyConnected=true) const
It interconnects two sub-blocks and adds the generated dynamic activities to the block b...
std::string mName
The name of the inter-robot operation.
Definition: RoboticLine.h:541
Activity * mActivity1
First activity.
Definition: RoboticLine.h:478
std::vector< LocationDependentPowerConsumption > mLocationDependentPowerConsumption
It defines the power consumption for the robot power saving modes that input power is dependent on th...
Definition: RoboticLine.h:184
Robot(uint32_t &fromActivityId, uint32_t &fromPointId, const uint32_t &numberOfInputs, const uint32_t &numberOfOutputs, const ProjectParameters &par)
It constructs the robot according to the desired parameters.
std::vector< Activity * > mPredecessors
The predecessors of the activity.
Definition: RoboticLine.h:229
mCompositeBlock createDisassemblyBlock(uint32_t &fromActivityId, uint32_t &fromPointId, const uint32_t &numberOfOutputs) const
It creates a block composed of disassembling/cutting the workpiece and taking its parts to other robo...
mCompositeBlock createComplexBlockHelper(uint32_t &fromActivityId, uint32_t &fromPointId, const uint32_t &numberOfSeq, const std::string &op) const
It is an auxiliary method wrapping complex calls to createBlockOfOperations method.
LocationDependentPowerConsumption(RobotPowerMode *mode, const uint32_t &modeIdx, const ProjectParameters &par)
It constructs the object encapsulating the information about the input power for the given robot conf...
Definition: RoboticLine.cpp:46
double mMaxDuration
The maximal duration of the movement.
Definition: RoboticLine.h:93
std::vector< Monomial > mEnergyFunction
Definition: RoboticLine.h:98
The inter-robot operation corresponding to the workpiece/weldment handling.
Definition: RoboticLine.h:512
RobotPowerMode(const uint32_t &pid, const double &delay)
It constructs the robot's power saving mode.
Definition: RoboticLine.h:115
double mInputPower
Input power of the robot for a given robot configuration, see also the Location class.
Definition: RoboticLine.h:158
mCompositeBlock mergeBlocks(const std::vector< mCompositeBlock > &blocks) const
It copies the activities (their pointers) in blocks to the one composite block.
mCompositeBlock createAssemblyBlock(uint32_t &fromActivityId, uint32_t &fromPointId, const uint32_t &numberOfInputs) const
It creates a block composed of gathering required parts to a bench and their assembly/welding to one ...
double mMinAbsDuration
The minimal absolute duration of the activity to remain feasible.
Definition: RoboticLine.h:231
It represents the location of robotic work.
Definition: RoboticLine.h:166
The robotic cell corresponds to an instance of this class.
Definition: RoboticLine.h:553
double mMinimalDelay
The minimal time in seconds which is required for the stationary robot to apply this power saving mod...
Definition: RoboticLine.h:130
std::vector< Activity * > mActivities
A collection of activities belonging to the robot.
Definition: RoboticLine.h:412
mCompositeBlock createSerialSequence(uint32_t &fromActivityId, uint32_t &fromPointId) const
The method creates a block of a fixed sequence of operations, e.g. welding, cutting, without alternatives and updates the identification values.
std::string numberToString(const T &number)
It converts the number to string.
Definition: RoboticLine.h:61
void calculateProductionCycleTime(const ProjectParameters &par)
It calculates production cycle time with respect to the desired dilatation factor.
double lowerBoundOfCycleTime() const
The method calculates an estimation of cycle time.
std::string mName
The name of the power saving mode, e.g. "motors", "brakes", etc.
Definition: RoboticLine.h:128
uint32_t mFrom
Identification of the start coordinate of the movement.
Definition: RoboticLine.h:87
std::vector< Pair > mSpatialCompatibility
Spatial compatibility pairs, i.e. a handover takes place at the right location for both involved robo...
Definition: RoboticLine.h:545
RoboticLine(const ProjectParameters &par)
It generates all the required data-structures for the robotic cell, i.e. an instance of a robotic cel...
uint32_t mMode1
The mode of the first activity, i.e. a movement or location identification.
Definition: RoboticLine.h:482
std::vector< Movement * > mMovements
The collection of movements between two static activities.
Definition: RoboticLine.h:289
DynamicActivity(const uint32_t &aid, StaticActivity *fromActivity, StaticActivity *toActivity, const ProjectParameters &par)
It generates the dynamic activity with respect to the desired properties.
Definition: RoboticLine.cpp:90
std::vector< TimeLag > mTimeLags
Time lags ensuring the correct time synchronization between robots.
Definition: RoboticLine.h:543