26 #include <sensor_msgs/JointState.h> 66 ROS_FATAL(
"Gazebo_ROS_Create controller requires a Model as its parent");
71 if (_sdf->HasElement(
"robotNamespace"))
75 if (_sdf->HasElement(
"max_torque"))
76 torque_ = _sdf->Get<
float>(
"max_torque");
80 if (_sdf->HasElement(
"r_finger_joint"))
81 joint_names_[0] = _sdf->Get<std::string>(
"r_finger_joint");
84 if (_sdf->HasElement(
"l_finger_joint"))
85 joint_names_[1] = _sdf->Get<std::string>(
"l_finger_joint");
91 ros::init(argc, argv,
"gazebo_ros_katana_gripper",
103 gzthrow(
"The controller couldn't get joint " <<
joint_names_[i]);
109 ROS_FATAL(
"gazebo_ros_katana_gripper could not construct PID controller!");
127 std::string modelName = _sdf->GetParent()->Get<std::string>(
"name");
133 gzdbg <<
"plugin model name: " << modelName <<
"\n";
135 ROS_INFO(
"gazebo_ros_katana_gripper plugin initialized");
141 #if GAZEBO_MAJOR_VERSION >= 8 156 #if GAZEBO_MAJOR_VERSION >= 8 157 common::Time time_now = this->
my_world_->SimTime();
159 common::Time time_now = this->
my_world_->GetSimTime();
162 prev_update_time_ = time_now;
181 #if GAZEBO_MAJOR_VERSION >= 8 182 actual_pos[i] =
joints_[i]->Position(0);
184 actual_pos[i] =
joints_[i]->GetAngle(0).Radian();
188 if (commanded_effort[i] >
torque_)
190 else if (commanded_effort[i] < -
torque_)
191 commanded_effort[i] = -
torque_;
193 joints_[i]->SetForce(0, commanded_effort[i]);
198 if (fabs(commanded_effort[0]) > 0.001)
199 ROS_DEBUG(
"efforts: r %f, l %f (max: %f)", commanded_effort[0], commanded_effort[1],
torque_);
208 #if GAZEBO_MAJOR_VERSION >= 8 223 katana_msgs::GripperControllerState controller_state;
227 controller_state.name.push_back(
joints_[i]->GetName());
228 controller_state.actual.push_back(actual_pos[i]);
229 controller_state.desired.push_back(desired_pos[i]);
230 controller_state.error.push_back(desired_pos[i] - actual_pos[i]);
287 double p, i,
d, i_max, i_min;
control_toolbox::Pid pid_controller_
ros::Publisher controller_state_pub_
void publish(const boost::shared_ptr< M > &message) const
virtual bool hasActiveGoal() const =0
katana_gazebo_plugins::IGazeboRosKatanaGripperAction * active_gripper_action_
ROSCPP_DECL bool isInitialized()
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ros::NodeHandle * rosnode_
virtual void Load(physics::ModelPtr _parent, sdf::ElementPtr _sdf)
GZ_REGISTER_MODEL_PLUGIN(GazeboRosKatanaGripper)
virtual void getGains(double &p, double &i, double &d, double &i_max, double &i_min)=0
void updateActiveGripperAction()
std::vector< std::string > joint_names_
virtual ~GazeboRosKatanaGripper()
common::Time prev_update_time_
virtual void UpdateChild()
event::ConnectionPtr updateConnection
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
virtual GRKAPoint getNextDesiredPoint(ros::Time time)=0
physics::ModelPtr my_parent_
std::vector< katana_gazebo_plugins::IGazeboRosKatanaGripperAction * > gripper_action_list_
physics::WorldPtr my_world_
std::string node_namespace_
static const size_t NUM_JOINTS
physics::JointPtr joints_[NUM_JOINTS]
boost::thread * spinner_thread_
ROSCPP_DECL void spinOnce()
float torque_
Torque applied to the joints.