27 init_position_(false),
60 open_manipulator_msgs::JointPosition msg;
62 msg.joint_name.push_back(
"joint1");
63 msg.joint_name.push_back(
"joint2");
64 msg.joint_name.push_back(
"joint3");
65 msg.joint_name.push_back(
"joint4");
67 msg.position.push_back(0.0);
68 msg.position.push_back(-1.5707);
69 msg.position.push_back(1.37);
70 msg.position.push_back(0.2258);
72 msg.max_velocity_scaling_factor = 0.2;
73 msg.max_accelerations_scaling_factor = 0.5;
82 ROS_INFO(
"SET Gazebo Simulation Mode(Joint)");
84 std::string joint_name[
joint_num_] = {
"joint1",
"joint2",
"joint3",
"joint4"};
123 open_manipulator_msgs::GetJointPosition::Response &res)
128 const std::vector<std::string> &joint_names =
move_group->getJointNames();
129 std::vector<double> joint_values =
move_group->getCurrentJointValues();
131 for (std::size_t i = 0; i < joint_names.size(); ++i)
133 ROS_INFO(
"%s: %f", joint_names[i].c_str(), joint_values[i]);
135 res.joint_position.joint_name.push_back(joint_names[i]);
136 res.joint_position.position.push_back(joint_values[i]);
143 open_manipulator_msgs::GetKinematicsPose::Response &res)
148 const std::string &pose_reference_frame =
move_group->getPoseReferenceFrame();
149 ROS_INFO(
"Pose Reference Frame = %s", pose_reference_frame.c_str());
151 geometry_msgs::PoseStamped current_pose =
move_group->getCurrentPose();
153 res.header = current_pose.header;
154 res.kinematics_pose.group_name =
"arm";
155 res.kinematics_pose.pose = current_pose.pose;
161 open_manipulator_msgs::SetJointPosition::Response &res)
163 open_manipulator_msgs::JointPosition msg = req.joint_position;
168 open_manipulator_msgs::SetKinematicsPose::Response &res)
170 open_manipulator_msgs::KinematicsPose msg = req.kinematics_pose;
179 bool isPlanned =
false;
180 geometry_msgs::Pose target_pose = msg.pose;
184 move_group->setMaxVelocityScalingFactor(msg.max_velocity_scaling_factor);
185 move_group->setMaxAccelerationScalingFactor(msg.max_accelerations_scaling_factor);
193 bool success = (
move_group->plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS);
201 ROS_WARN(
"Planning (task space goal) is FAILED");
221 bool isPlanned =
false;
223 const robot_state::JointModelGroup *joint_model_group =
move_group->getCurrentState()->getJointModelGroup(
"arm");
225 moveit::core::RobotStatePtr current_state =
move_group->getCurrentState();
227 std::vector<double> joint_group_positions;
228 current_state->copyJointGroupPositions(joint_model_group, joint_group_positions);
232 if (msg.joint_name[
index] == (
"joint" + std::to_string((
index+1))))
234 joint_group_positions[
index] = msg.position[
index];
238 move_group->setJointValueTarget(joint_group_positions);
240 move_group->setMaxVelocityScalingFactor(msg.max_velocity_scaling_factor);
241 move_group->setMaxAccelerationScalingFactor(msg.max_accelerations_scaling_factor);
247 bool success = (
move_group->plan(my_plan) == moveit::planning_interface::MoveItErrorCode::SUCCESS);
255 ROS_WARN(
"Planning (joint space goal) is FAILED");
273 if (msg->trajectory[0].joint_trajectory.joint_names[0].find(
"grip") == std::string::npos)
284 for (uint8_t num = 0; num < joint_num; num++)
286 float joint_position = msg->trajectory[0].joint_trajectory.points[point_num].positions[num];
303 static uint16_t step_cnt = 0;
304 std_msgs::Float64 gazebo_goal_joint_position;
305 sensor_msgs::JointState goal_joint_position;
306 open_manipulator_msgs::State state;
312 for (uint8_t num = 0; num <
joint_num_; num++)
320 for (uint8_t num = 0; num <
joint_num_; num++)
340 state.robot = state.IS_MOVING;
345 state.robot = state.STOPPED;
350 int main(
int argc,
char **argv)
352 ros::init(argc, argv,
"joint_controller_for_OpenManipulator");
bool getJointPositionMsgCallback(open_manipulator_msgs::GetJointPosition::Request &req, open_manipulator_msgs::GetJointPosition::Response &res)
bool setKinematicsPoseMsgCallback(open_manipulator_msgs::SetKinematicsPose::Request &req, open_manipulator_msgs::SetKinematicsPose::Response &res)
void publish(const boost::shared_ptr< M > &message) const
ros::ServiceServer get_joint_position_server_
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ros::Subscriber display_planned_path_sub_
Eigen::MatrixXd planned_path_positions
PlannedPathInfo planned_path_info_
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
void displayPlannedPathMsgCallback(const moveit_msgs::DisplayTrajectory::ConstPtr &msg)
ServiceServer advertiseService(const std::string &service, bool(T::*srv_func)(MReq &, MRes &), T *obj)
void initPublisher(bool using_gazebo)
ros::Publisher gazebo_goal_joint_position_pub_[10]
ros::ServiceServer set_kinematics_pose_server_
ros::Publisher arm_state_pub_
ros::Publisher goal_joint_position_pub_
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
bool getKinematicsPoseMsgCallback(open_manipulator_msgs::GetKinematicsPose::Request &req, open_manipulator_msgs::GetKinematicsPose::Response &res)
ros::ServiceServer set_joint_position_server_
int main(int argc, char **argv)
bool getParam(const std::string &key, std::string &s) const
void initSubscriber(bool using_gazebo)
ROSCPP_DECL void shutdown()
bool calcPlannedPath(open_manipulator_msgs::JointPosition msg)
bool setJointPositionMsgCallback(open_manipulator_msgs::SetJointPosition::Request &req, open_manipulator_msgs::SetJointPosition::Response &res)
ROSCPP_DECL void spinOnce()
ros::ServiceServer get_kinematics_pose_server_
#define ITERATION_FREQUENCY