PowerCubeCtrl.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017 Fraunhofer Institute for Manufacturing Engineering and Automation (IPA)
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9 
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 
18 #ifndef __POWER_CUBE_CTRL_H_
19 #define __POWER_CUBE_CTRL_H_
20 
21 #define VERSION_ELECTR3_FIRST 0x3518
22 #define VERSION_ELECTR2_LAST 0x3000
23 #define VERSION_ELECTR2_FIRST 0x2518
24 
25 // standard includes
26 #include <iostream>
27 #include <sstream>
28 #include <string>
29 #include <deque>
30 #include <pthread.h>
31 
32 // own includes
36 
38 {
39 public:
42 
45 
46  typedef enum
47  {
53 
55  // Functions for initialization and close: //
57 
61  bool Init(PowerCubeCtrlParams* params);
62 
66  bool isInitialized() const
67  {
68  return m_Initialized;
69  }
70 
74  std::string getErrorMessage() const
75  {
76  return m_ErrorMessage;
77  }
78 
83  {
84  return m_pc_status;
85  }
86 
90  bool Close();
91 
93  // Functions for control: //
95 
99  bool MoveJointSpaceSync(const std::vector<double>& angles);
100 
104  bool MoveVel(const std::vector<double>& velocities);
105 
109  bool Stop();
110 
114  bool Recover();
115 
117  // functions to set parameters: //
119 
125  bool setMaxVelocity(double velocity);
126  bool setMaxVelocity(const std::vector<double>& velocities);
127 
133  bool setMaxAcceleration(double acceleration);
134  bool setMaxAcceleration(const std::vector<double>& accelerations);
135 
142  bool setHorizon(double horizon);
143 
150  double getHorizon();
151 
157  bool setSyncMotion();
158 
164  bool setASyncMotion();
165 
167  // Functions for getting state and monitoring: //
169 
173  bool updateStates();
174 
178  bool getStatus(PC_CTRL_STATUS& status, std::vector<std::string>& errorMessages);
179 
183  std::vector<unsigned long> getVersion();
184 
190  bool statusMoving();
191 
195  std::vector<double> getPositions();
196 
200  std::vector<double> getVelocities();
201 
205  std::vector<double> getAccelerations();
206 
210  bool getJointAngles(std::vector<double>& result);
211 
215  bool getJointVelocities(std::vector<double>& result);
216 
222  bool doHoming();
223 
224  void updateVelocities(std::vector<double> pos_temp, double delta_t);
225 
226 protected:
227  pthread_mutex_t m_mutex;
228 
232 
235 
236  std::vector<unsigned long> m_status;
237  std::vector<std::string> m_ModuleTypes;
238  std::vector<unsigned long> m_version;
239  std::vector<unsigned char> m_dios;
240  std::vector<double> m_positions;
241  std::deque< std::vector<double> > m_cached_pos;
242  std::vector<double> m_velocities;
243  std::vector<double> m_accelerations;
244 
245  double m_horizon;
246 
248 
249  std::string m_ErrorMessage;
250 
251  bool getPositionAndStatus(int module_id, unsigned long* state, unsigned char* dio, float* position);
252 };
253 
254 #endif
bool setHorizon(double horizon)
Sets the horizon (sec).
std::vector< double > getPositions()
Gets the current positions.
std::vector< double > m_accelerations
bool getJointVelocities(std::vector< double > &result)
get the current joint velocities (Rad/s)
std::vector< unsigned char > m_dios
std::string m_ErrorMessage
std::vector< double > m_positions
bool MoveVel(const std::vector< double > &velocities)
Moves all cubes by the given velocities.
bool m_CANDeviceOpened
std::vector< unsigned long > m_status
bool getStatus(PC_CTRL_STATUS &status, std::vector< std::string > &errorMessages)
Gets the status of the modules.
PC_CTRL_STATUS m_pc_status
bool setSyncMotion()
Configure powercubes to start all movements synchronously.
~PowerCubeCtrl()
Destructor.
pthread_mutex_t m_mutex
std::vector< unsigned long > m_version
bool Init(PowerCubeCtrlParams *params)
Initializing.
bool getJointAngles(std::vector< double > &result)
get the current joint angles
bool setMaxAcceleration(double acceleration)
Sets the maximum angular velocity (rad/s) for the Joints, use with care!
bool Recover()
Recovery after emergency stop or power supply failure.
std::vector< double > getAccelerations()
Gets the current accelerations.
std::deque< std::vector< double > > m_cached_pos
std::vector< double > getVelocities()
Gets the current velcities.
ros::Time m_last_time_pub
PC_CTRL_STATUS getPC_Status() const
Get PC_Status message.
Definition: PowerCubeCtrl.h:82
bool setMaxVelocity(double velocity)
Sets the maximum angular velocity (rad/s) for the Joints, use with care!
bool getPositionAndStatus(int module_id, unsigned long *state, unsigned char *dio, float *position)
bool isInitialized() const
Checking if is initialized.
Definition: PowerCubeCtrl.h:66
void updateVelocities(std::vector< double > pos_temp, double delta_t)
bool statusMoving()
Returns true if any of the Joints are still moving.
std::vector< double > m_velocities
bool doHoming()
Waits until all Modules are homed.
bool updateStates()
Returns the state of all modules.
bool Close()
Close.
std::vector< std::string > m_ModuleTypes
PowerCubeCtrlParams * m_params
std::string getErrorMessage() const
Get error message.
Definition: PowerCubeCtrl.h:74
bool Stop()
Stops the Manipulator immediately.
std::vector< unsigned long > getVersion()
Gets the firmware version of the modules.
bool setASyncMotion()
Configure powercubes to start all movements asynchronously.
PowerCubeCtrl(PowerCubeCtrlParams *params)
Constructor.
double getHorizon()
Gets the horizon (sec).
Parameters for cob_powercube_chain.
bool MoveJointSpaceSync(const std::vector< double > &angles)
Send position goals to powercubes, the final angles will be reached simultaneously.


schunk_powercube_chain
Author(s): Florian Weisshardt
autogenerated on Mon Nov 25 2019 03:48:21