55 ROS_INFO(
"SET Gazebo Simulation Mode(Gripper)");
91 open_manipulator_msgs::SetJointPosition::Response &res)
93 open_manipulator_msgs::JointPosition msg = req.joint_position;
102 bool isPlanned =
false;
104 const robot_state::JointModelGroup *joint_model_group =
move_group->getCurrentState()->getJointModelGroup(
"gripper");
106 moveit::core::RobotStatePtr current_state =
move_group->getCurrentState();
108 std::vector<double> joint_group_positions;
109 current_state->copyJointGroupPositions(joint_model_group, joint_group_positions);
111 msg.joint_name.push_back(
"grip_joint");
112 msg.joint_name.push_back(
"grip_joint_sub");
116 joint_group_positions[
index] = msg.position[0];
117 joint_group_positions[
index] = msg.position[0];
120 move_group->setJointValueTarget(joint_group_positions);
122 move_group->setMaxVelocityScalingFactor(msg.max_velocity_scaling_factor);
123 move_group->setMaxAccelerationScalingFactor(msg.max_accelerations_scaling_factor);
129 bool success = (
move_group->plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS);
137 ROS_WARN(
"Planning (joint space goal) is FAILED");
154 open_manipulator_msgs::JointPosition joint_msg;
156 joint_msg.max_velocity_scaling_factor = 0.3;
157 joint_msg.max_accelerations_scaling_factor = 0.01;
159 if (msg->data ==
"grip_on")
161 joint_msg.position.push_back(
GRIP_ON);
164 else if (msg->data ==
"grip_off")
166 joint_msg.position.push_back(
GRIP_OFF);
169 else if (msg->data ==
"neutral")
171 joint_msg.position.push_back(
NEUTRAL);
176 ROS_ERROR(
"If you want to grip or release something, publish 'grip_on', 'grip_off' or 'neutral'");
183 if (msg->trajectory[0].joint_trajectory.joint_names[0].find(
"grip") != std::string::npos)
185 ROS_INFO(
"Get Gripper Planned Path");
186 uint8_t gripper_num = 2;
194 for (uint8_t num = 0; num < gripper_num; num++)
196 float joint_position = msg->trajectory[0].joint_trajectory.points[point_num].positions[num];
213 static uint16_t step_cnt = 0;
214 std_msgs::Float64 gazebo_goal_gripper_position;
215 sensor_msgs::JointState goal_gripper_position;
216 open_manipulator_msgs::State state;
248 state.robot = state.IS_MOVING;
253 state.robot = state.STOPPED;
258 int main(
int argc,
char **argv)
260 ros::init(argc, argv,
"gripper_controller_for_OpenManipulator");
ros::Subscriber gripper_onoff_sub_
void publish(const boost::shared_ptr< M > &message) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
Eigen::MatrixXd planned_path_positions
void initPublisher(bool using_gazebo)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
int main(int argc, char **argv)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
ros::Publisher gripper_position_pub_
ros::Publisher gripper_state_pub_
PlannedPathInfo planned_path_info_
bool calcPlannedPath(open_manipulator_msgs::JointPosition msg)
ros::Subscriber display_planned_path_sub_
void initSubscriber(bool using_gazebo)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool setGripperPositionMsgCallback(open_manipulator_msgs::SetJointPosition::Request &req, open_manipulator_msgs::SetJointPosition::Response &res)
virtual ~GripperController()
bool getParam(const std::string &key, std::string &s) const
ROSCPP_DECL void shutdown()
void gripperOnOffMsgCallback(const std_msgs::String::ConstPtr &msg)
ros::ServiceServer set_gripper_position_server_
ROSCPP_DECL void spinOnce()
void displayPlannedPathMsgCallback(const moveit_msgs::DisplayTrajectory::ConstPtr &msg)
#define ITERATION_FREQUENCY
ros::Publisher gazebo_gripper_position_pub_[2]