control_multi_plugin.cpp
Go to the documentation of this file.
1 #include "GeomController.h"
2 #include "WheelControllerBase.h"
5 
7 {
8 
9 class GeomMultiController : public GeomControllerBase< hardware_interface::JointHandle, UndercarriageDirectCtrl>,
10  public controller_interface::MultiInterfaceController<hardware_interface::VelocityJointInterface, hardware_interface::PositionJointInterface> {
11 };
12 
13 class WheelMultiController : public WheelControllerBase< GeomMultiController >
14 {
15 public:
16  virtual bool init(hardware_interface::RobotHW* robot_hw, ros::NodeHandle &root_nh, ros::NodeHandle& controller_nh){
17  std::vector<UndercarriageDirectCtrl::WheelParams> wheel_params;
18  if(!parseWheelParams(wheel_params, controller_nh)) return false;
19  if(!GeomControllerBase::setup(wheel_params)) return false;
20 
23 
24  try{
25  for (unsigned i=0; i<wheel_params.size(); i++){
26  this->steer_joints_.push_back(p->getHandle(wheel_params[i].geom.steer_name));
27  this->drive_joints_.push_back(v->getHandle(wheel_params[i].geom.drive_name));
28  }
29  }
30  catch(const std::exception &e){
31  ROS_ERROR_STREAM("Error while attaching handles: " << e.what());
32  return false;
33  }
34  return this->setup(root_nh,controller_nh);
35  }
36  virtual void update(const ros::Time& time, const ros::Duration& period){
37 
38  updateState();
39 
40  updateCtrl(time, period);
41 
42  for (unsigned i=0; i<wheel_commands_.size(); i++){
43  steer_joints_[i].setCommand(wheel_commands_[i].dAngGearSteerRad);
44  drive_joints_[i].setCommand(wheel_commands_[i].dVelGearDriveRadS);
45  }
46 
47  }
48 };
49 
50 }
51 
bool parseWheelParams(std::vector< UndercarriageGeom::WheelParams > &params, const ros::NodeHandle &nh, bool read_urdf=true)
virtual void update(const ros::Time &time, const ros::Duration &period)
virtual bool init(hardware_interface::RobotHW *robot_hw, ros::NodeHandle &root_nh, ros::NodeHandle &controller_nh)
bool setup(const std::vector< typename Controller::WheelParams > &wheel_params)
JointHandle getHandle(const std::string &name)
#define ROS_ERROR_STREAM(args)
#define PLUGINLIB_EXPORT_CLASS(class_type, base_class_type)


cob_omni_drive_controller
Author(s): Christian Connette, Mathias Lüdtke
autogenerated on Thu Apr 8 2021 02:39:52