42 #include <sensor_msgs/Joy.h> 152 bool control_prosilica;
153 n_local.
param(
"control_prosilica", control_prosilica,
true);
156 n_local.
param(
"control_body", control_body,
true);
159 n_local.
param(
"control_larm", control_larm,
true);
162 n_local.
param(
"control_rarm", control_rarm,
true);
165 n_local.
param(
"control_head", control_head,
true);
167 std::string arm_controller_name;
168 n_local.
param(
"arm_controller_name", arm_controller_name,std::string(
""));
173 ROS_INFO(
"Initing general commander");
175 if(arm_controller_name.empty()) {
187 arm_controller_name);
209 bool buttonOkAndOn(
unsigned int buttonNum,
const sensor_msgs::Joy::ConstPtr& joy_msg)
const {
210 if(buttonNum >= joy_msg->buttons.size())
return false;
211 return(joy_msg->buttons[buttonNum]);
214 bool axisOk(
unsigned int axisNum,
const sensor_msgs::Joy::ConstPtr& joy_msg)
const {
215 return (axisNum < joy_msg->axes.size());
219 const sensor_msgs::Joy::ConstPtr& new_msg,
220 const sensor_msgs::Joy::ConstPtr& old_msg) {
225 void joy_cb(
const sensor_msgs::Joy::ConstPtr& joy_msg)
248 bool setting_walk_along_this_cycle_ =
false;
257 setting_walk_along_this_cycle_ =
true;
269 bool in_walk_along =
false;
295 in_walk_along =
true;
307 ROS_INFO(
"No longer waiting for set");
319 ROS_INFO(
"Should be in walk along");
325 ROS_INFO(
"No longer waiting for init");
419 }
else if(!down && up) {
478 bool lookAnalog =
false;
482 if(rotClock && !rotCounter) {
484 }
else if(!rotClock && rotCounter) {
560 bool lookAnalog =
false;
564 if(rotClock && !rotCounter) {
566 }
else if(!rotClock && rotCounter) {
646 bool lookAnalog =
false;
650 if(rotClock && !rotCounter) {
653 }
else if(!rotClock && rotCounter) {
729 double cur_torso_pos = 0.0;
731 if(!ok)
return false;
735 double dt = 1.0/double(hz);
736 double horizon = dt*5.0;
737 double cur_torso_pos = 0.0;
748 double cur_pan_pos = 0.0;
749 double cur_tilt_pos = 0.0;
751 if(!ok)
return false;
753 if(!ok)
return false;
761 des_pan_pos_ = std::max(des_pan_pos_, -
max_pan_);
766 des_tilt_pos_ = std::max(des_tilt_pos_,
min_tilt_);
881 int main(
int argc,
char **argv)
893 unsigned int counter_limit = (
unsigned int)(
FastHz/
SlowHz);
895 unsigned int counter = 0;
912 if((counter % counter_limit) == 0) {
923 ROS_INFO(
"Arms not in walk position");
void sendWalkAlongCommand(double thresh, double x_dist_max, double x_speed_scale, double y_dist_max, double y_speed_scale, double rot_scale)
static const unsigned int HEAD_LAYOUT_BUTTON
static const unsigned int RIGHT_AXIS_NUMBER
double walk_along_thresh_
static const unsigned int ARM_POSE_BUTTON
double right_arm_vel_yaw_
bool buttonOkAndOn(unsigned int buttonNum, const sensor_msgs::Joy::ConstPtr &joy_msg) const
static const unsigned int SET_WALK_ALONG_BUTTON
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
void setHeadMode(HeadControlMode mode)
static const unsigned int CLOSE_GRIPPER_BUTTON
static const unsigned int LASER_TOGGLE_BUTTON
static const unsigned int ARM_MODE_TOGGLE_BUTTON
void sendHeadSequence(HeadSequence seq)
void sendArmVelCommands(double r_x_vel, double r_y_vel, double r_z_vel, double r_roll_vel, double r_pitch_vel, double r_yaw_vel, double l_x_vel, double l_y_vel, double l_z_vel, double l_roll_vel, double l_pitch_vel, double l_yaw_vel, double hz)
void setArmMode(WhichArm which, ArmControlMode mode)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
double des_right_wrist_vel_
double walk_along_w_speed_scale_
static const unsigned int HEAD_PAN_AXIS
bool convertCurrentVelToDesiredHeadPos(double hz)
void tuckArms(WhichArm arm)
HeadControlMode getHeadMode()
int main(int argc, char **argv)
static const unsigned int RIGHT_ARM_LAYOUT_BUTTON
double walk_along_x_speed_scale_
static const unsigned int SPEED_UP_BUTTON
void sendWristVelCommands(double right_wrist_vel, double left_wrist_vel, double hz)
ROSCPP_DECL void spin(Spinner &spinner)
static const unsigned int VY_AXIS
static const unsigned int TORSO_DOWN_BUTTON
double des_left_wrist_vel_
static const unsigned int ARM_Y_AXIS
static const ros::Duration DOUBLE_TAP_TIMEOUT(.25)
double walk_along_y_dist_max_
static const double SlowHz
static const unsigned int PROSILICA_POLL_BUTTON
static const unsigned int OPEN_GRIPPER_BUTTON
void untuckArms(WhichArm arm)
bool axisOk(unsigned int axisNum, const sensor_msgs::Joy::ConstPtr &joy_msg) const
void sendBaseCommand(double vx, double vy, double vw)
bool set_walk_along_mode_
static const double FastHz
bool sameValueAsLast(unsigned int button, const sensor_msgs::Joy::ConstPtr &new_msg, const sensor_msgs::Joy::ConstPtr &old_msg)
bool param(const std::string ¶m_name, T ¶m_val, const T &default_val) const
static const unsigned int HEAD_TILT_AXIS
void sendProjectorStartStop(bool start)
std::string prosilica_namespace_
int switch_head_control_mode_button_
static const unsigned int HEAD_MODE_TOGGLE_BUTTON
ArmControlMode getArmMode(WhichArm which)
void sendHeadTrackCommand()
double walk_along_y_speed_scale_
double right_arm_vel_pitch_
static const unsigned int ARM_X_AXIS
static const unsigned int ARM_UNTUCK_BUTTON
void sendHeadCommand(double req_pan, double req_tilt)
static const unsigned int BODY_LAYOUT_BUTTON
static const unsigned int PROJECTOR_TOGGLE_BUTTON
bool getJointPosition(const std::string &name, double &pos) const
void requestProsilicaImage(std::string ns)
static const unsigned int ARM_Z_AXIS
void joy_cb(const sensor_msgs::Joy::ConstPtr &joy_msg)
int projector_toggle_button_
void setLaserMode(LaserControlMode mode)
LaserControlMode getLaserMode()
double left_arm_vel_pitch_
ros::Time last_head_toggle_
double right_arm_vel_roll_
void sendGripperCommand(WhichArm which, bool close)
double left_arm_vel_roll_
Pr2TeleopGeneralJoystick(bool deadman_no_publish=false)
static const unsigned int ARM_TUCK_BUTTON
ROSCPP_DECL void shutdown()
~Pr2TeleopGeneralJoystick()
void sendTorsoCommand(double pos, double vel)
static const unsigned int TORSO_UP_BUTTON
double walk_along_x_dist_max_
bool walk_along_init_waiting_
ros::Time last_walk_along_time_
static const unsigned int LEFT_AXIS_NUMBER
static const unsigned int LEFT_ARM_LAYOUT_BUTTON
static const unsigned int ARM_YAW_AXIS
ros::Time last_projector_toggle_
bool convertCurrentVelToDesiredTorsoPos(double hz)
static const unsigned int VW_AXIS
bool moveToWalkAlongArmPose()
static const unsigned int WRIST_COUNTER_BUTTON
sensor_msgs::JoyConstPtr last_joy_
static const unsigned int WRIST_CLOCKWISE_BUTTON
ros::Time last_laser_toggle_
static const unsigned int MOVE_TO_WALK_ALONG_BUTTON
static const unsigned int VX_AXIS