controller.h
Go to the documentation of this file.
1 /*
2  * Copyright 2017, 2018 Simon Rasmussen (refactor)
3  *
4  * Copyright 2015, 2016 Thomas Timm Andersen (original version)
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 
19 #pragma once
25 #include <ros/ros.h>
26 #include <atomic>
27 #include "ur_modern_driver/log.h"
33 
35 {
36 private:
41 
42  // state interfaces
45  // controller interfaces
48 
49  // currently activated controller
51  // map of switchable controllers
52  std::map<std::string, HardwareInterface*> available_interfaces_;
53 
54  std::atomic<bool> service_enabled_;
55  std::atomic<uint32_t> service_cooldown_;
56 
57  // helper functions to map interfaces
58  template <typename T>
59  void registerInterface(T* interface)
60  {
61  RobotHW::registerInterface<typename T::parent_type>(interface);
62  }
63  template <typename T>
64  void registerControllereInterface(T* interface)
65  {
66  registerInterface(interface);
67  available_interfaces_[T::INTERFACE_NAME] = interface;
68  }
69 
70  void read(RTShared& state);
71  bool update();
72  bool write();
73  void reset();
74 
75 public:
76  ROSController(URCommander& commander, TrajectoryFollower& follower, std::vector<std::string>& joint_names,
77  double max_vel_change, std::string wrench_frame);
78  virtual ~ROSController()
79  {
80  }
81  // from RobotHW
82  void doSwitch(const std::list<hardware_interface::ControllerInfo>& start_list,
83  const std::list<hardware_interface::ControllerInfo>& stop_list);
84  // from URRTPacketConsumer
85  virtual void setupConsumer();
86  virtual bool consume(RTState_V1_6__7& state)
87  {
88  read(state);
89  return update();
90  }
91  virtual bool consume(RTState_V1_8& state)
92  {
93  read(state);
94  return update();
95  }
96  virtual bool consume(RTState_V3_0__1& state)
97  {
98  read(state);
99  return update();
100  }
101  virtual bool consume(RTState_V3_2__3& state)
102  {
103  read(state);
104  return update();
105  }
106 
107  virtual void onTimeout();
108 
109  virtual void onRobotStateChange(RobotState state);
110 };
ROSController(URCommander &commander, TrajectoryFollower &follower, std::vector< std::string > &joint_names, double max_vel_change, std::string wrench_frame)
Definition: controller.cpp:21
virtual bool consume(RTState_V3_2__3 &state)
Definition: controller.h:101
virtual void onTimeout()
Definition: controller.cpp:136
virtual bool consume(RTState_V1_8 &state)
Definition: controller.h:91
ros::NodeHandle nh_
Definition: controller.h:37
void registerInterface(T *interface)
Definition: controller.h:59
VelocityInterface velocity_interface_
Definition: controller.h:47
virtual bool consume(RTState_V3_0__1 &state)
Definition: controller.h:96
void doSwitch(const std::list< hardware_interface::ControllerInfo > &start_list, const std::list< hardware_interface::ControllerInfo > &stop_list)
Definition: controller.cpp:41
HardwareInterface * active_interface_
Definition: controller.h:50
JointInterface joint_interface_
Definition: controller.h:43
virtual void onRobotStateChange(RobotState state)
Definition: controller.cpp:141
PositionInterface position_interface_
Definition: controller.h:46
ros::Time lastUpdate_
Definition: controller.h:38
controller_manager::ControllerManager controller_
Definition: controller.h:39
virtual ~ROSController()
Definition: controller.h:78
bool robot_state_received_
Definition: controller.h:40
RobotState
void registerControllereInterface(T *interface)
Definition: controller.h:64
std::atomic< bool > service_enabled_
Definition: controller.h:54
virtual void setupConsumer()
Definition: controller.cpp:36
WrenchInterface wrench_interface_
Definition: controller.h:44
std::map< std::string, HardwareInterface * > available_interfaces_
Definition: controller.h:52
virtual bool consume(RTState_V1_6__7 &state)
Definition: controller.h:86
std::atomic< uint32_t > service_cooldown_
Definition: controller.h:55
void read(RTShared &state)
Definition: controller.cpp:99


ur_modern_driver
Author(s): Thomas Timm Andersen, Simon Rasmussen
autogenerated on Fri Jun 26 2020 03:37:00