2 #include <sensor_msgs/Joy.h> 4 #include <control_msgs/GripperCommandAction.h> 55 if(!isDeadManActive) {
56 if(msg->axes[_hardProfileIndex] == -1.0) {
58 if(msg->axes[_rightLeftAxis] == 1) {
60 }
else if(msg->axes[_rightLeftAxis] == -1) {
64 if(msg->axes[_upDownAxis] == 1) {
66 }
else if(msg->axes[_upDownAxis] == -1) {
70 if(msg->buttons[_xButtonIndex] == 1) {
72 }
else if(msg->buttons[_bButtonIndex] == 1) {
75 if(msg->buttons[_yButtonIndex] == 1) {
77 }
else if(msg->buttons[_aButtonIndex] == 1) {
82 }
else if(msg->axes[_softProfileIndex] == -1.0) {
83 if(msg->axes[_rightLeftAxis] == 1) {
85 }
else if(msg->axes[_rightLeftAxis] == -1) {
89 if(msg->axes[_upDownAxis] == 1) {
91 }
else if (msg->axes[_upDownAxis] == -1) {
95 if(msg->buttons[_yButtonIndex] == 1) {
97 }
else if(msg->buttons[_aButtonIndex] == 1) {
105 return _rotation1State == 1 || _rotation1State == -1
106 || _rotation2State == 1 || _rotation2State == -1
107 || _shoulder1State == 1 || _shoulder1State == -1
108 || _shoulder2State == 1 || _shoulder2State == -1
109 || _shoulder3State == 1 || _shoulder3State == -1
110 || _wristState == 1 || _wristState == -1
111 || _gripperState == 1 || _gripperState == -1;
123 _gripperWorking =
false;
131 ros::param::param<int>(
"drive_joy_teleop_deadman_button",
_deadManIndex, 7);
134 ros::param::param<int>(
"arm_joy_node_x_button_index",
_xButtonIndex, 3);
135 ros::param::param<int>(
"arm_joy_node_y_button_index",
_yButtonIndex, 4);
136 ros::param::param<int>(
"arm_joy_node_a_button_index",
_aButtonIndex, 0);
137 ros::param::param<int>(
"arm_joy_node_b_button_index",
_bButtonIndex, 1);
138 ros::param::param<int>(
"arm_joy_node_up_down_index",
_upDownAxis, 7);
139 ros::param::param<int>(
"arm_joy_node_left_right_index",
_rightLeftAxis, 6);
154 ROS_INFO(
"Trying to move arm to 90 deg pos");
157 if(_group.
plan(start_plan))
165 std::vector<double> group_variable_values;
166 group_variable_values.reserve(6);
169 group_variable_values);
172 ROS_INFO(
"Waiting for action server to start.");
177 control_msgs::GripperCommandGoal goal;
181 std::vector<double> prev_group_variable_values;
182 prev_group_variable_values.reserve(6);
184 if(_rotation1State == -1) {
187 }
else if(_rotation1State == 1) {
192 if(_shoulder1State == -1) {
195 }
else if(_shoulder1State == 1) {
200 if(_shoulder2State == -1) {
203 }
else if(_shoulder2State == 1) {
208 if(_rotation2State == -1) {
211 }
else if(_rotation2State == 1) {
216 if(_shoulder3State == -1) {
219 }
else if(_shoulder3State == 1) {
224 if(_wristState == -1) {
227 }
else if(_wristState == 1) {
232 if(_gripperState == -1) {
234 if(!_gripperWorking) {
238 goal.command.position=0.001;
239 goal.command.max_effort=5;
246 }
else if(_gripperState == 1) {
248 if (!_gripperWorking) {
249 goal.command.position=0.1;
250 goal.command.max_effort=5;
259 for (
int i=0; i<6; i++)
260 prev_group_variable_values[i] = group_variable_values[i];
265 bool success = (_group.
plan(my_plan)==moveit::planning_interface::MoveItErrorCode::SUCCESS);
272 for (
int i=0; i<6; i++)
273 group_variable_values[i] = prev_group_variable_values[i];
285 int main(
int argc,
char** argv) {
ros::AsyncSpinner _spinner
bool waitForServer(const ros::Duration &timeout=ros::Duration(0, 0)) const
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
bool setJointValueTarget(const std::vector< double > &group_variable_values)
float _shoulder2IncreamentValue
int main(int argc, char **argv)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
ROSCPP_DECL const std::string & getName()
float _shoulder3IncreamentValue
void setPlannerId(const std::string &planner_id)
float _rotation2IncreamentValue
void setPlanningTime(double seconds)
const std::string & getName() const
void joyCallback(const sensor_msgs::Joy::ConstPtr &msg)
float _rotation1IncreamentValue
ros::NodeHandle _nodeHandle
MoveItErrorCode execute(const Plan &plan)
MoveItErrorCode plan(Plan &plan)
void setNumPlanningAttempts(unsigned int num_planning_attempts)
float _wristIncreamentValue
void sendGoal(const Goal &goal, SimpleDoneCallback done_cb=SimpleDoneCallback(), SimpleActiveCallback active_cb=SimpleActiveCallback(), SimpleFeedbackCallback feedback_cb=SimpleFeedbackCallback())
robot_state::RobotStatePtr getCurrentState()
float _shoulder1IncreamentValue
moveit::planning_interface::MoveGroupInterface _group
bool setNamedTarget(const std::string &name)
actionlib::SimpleActionClient< control_msgs::GripperCommandAction > GripperClient