Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kinetic] wheel multi controller refactored #140

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cob_omni_drive_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ add_library(cob_omni_drive_geom src/UndercarriageCtrlGeom.cpp src/param_parser.c
add_dependencies(cob_omni_drive_geom ${catkin_EXPORTED_TARGETS})
target_link_libraries(cob_omni_drive_geom ${catkin_LIBRARIES})

add_library(cob_omni_drive_controller src/odom_plugin.cpp src/control_plugin.cpp)
add_library(cob_omni_drive_controller src/odom_plugin.cpp src/control_plugin.cpp src/control_multi_plugin.cpp)
add_dependencies(cob_omni_drive_controller ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
target_link_libraries(cob_omni_drive_controller cob_omni_drive_geom ${catkin_LIBRARIES} ${Boost_LIBRARIES})

Expand Down
4 changes: 4 additions & 0 deletions cob_omni_drive_controller/controller_plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,9 @@
<description>
</description>
</class>
<class name="cob_omni_drive_controller/WheelMultiController" type="cob_omni_drive_controller::WheelMultiController" base_class_type="controller_interface::ControllerBase">
<description>
</description>
</class>
</library>
</class_libraries>
52 changes: 52 additions & 0 deletions cob_omni_drive_controller/src/control_multi_plugin.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#include "GeomController.h"
#include "WheelControllerBase.h"
#include <controller_interface/multi_interface_controller.h>
#include <hardware_interface/joint_command_interface.h>

namespace cob_omni_drive_controller
{

class GeomMultiController : public GeomControllerBase< hardware_interface::JointHandle, UndercarriageDirectCtrl>,
public controller_interface::MultiInterfaceController<hardware_interface::VelocityJointInterface, hardware_interface::PositionJointInterface> {
};

class WheelMultiController : public WheelControllerBase< GeomMultiController >
{
public:
virtual bool init(hardware_interface::RobotHW* robot_hw, ros::NodeHandle &root_nh, ros::NodeHandle& controller_nh){
std::vector<UndercarriageDirectCtrl::WheelParams> wheel_params;
if(!parseWheelParams(wheel_params, controller_nh)) return false;
if(!GeomControllerBase::setup(wheel_params)) return false;

hardware_interface::VelocityJointInterface* v = robot_hw->get<hardware_interface::VelocityJointInterface>();
hardware_interface::PositionJointInterface* p = robot_hw->get<hardware_interface::PositionJointInterface>();

try{
for (unsigned i=0; i<wheel_params.size(); i++){
this->steer_joints_.push_back(p->getHandle(wheel_params[i].geom.steer_name));
this->drive_joints_.push_back(v->getHandle(wheel_params[i].geom.drive_name));
}
}
catch(const std::exception &e){
ROS_ERROR_STREAM("Error while attaching handles: " << e.what());
return false;
}
return this->setup(root_nh,controller_nh);
}
virtual void update(const ros::Time& time, const ros::Duration& period){

updateState();

updateCtrl(time, period);

for (unsigned i=0; i<wheel_commands_.size(); i++){
steer_joints_[i].setCommand(wheel_commands_[i].dAngGearSteerRad);
drive_joints_[i].setCommand(wheel_commands_[i].dVelGearDriveRadS);
}

}
};

}

PLUGINLIB_EXPORT_CLASS( cob_omni_drive_controller::WheelMultiController, controller_interface::ControllerBase)