42 #ifndef JOG_ARM_SERVER_H 43 #define JOG_ARM_SERVER_H 45 #include <Eigen/Eigenvalues> 46 #include <jog_msgs/JogJoint.h> 53 #include <sensor_msgs/JointState.h> 54 #include <sensor_msgs/Joy.h> 55 #include <std_msgs/Bool.h> 56 #include <std_msgs/Float64MultiArray.h> 58 #include <trajectory_msgs/JointTrajectory.h> 104 std::string move_group_name, joint_topic, cartesian_command_in_topic, command_frame, command_out_topic,
105 planning_frame,
warning_topic, joint_command_in_topic, command_in_type, command_out_type;
106 double linear_scale,
rotational_scale, joint_scale, lower_singularity_threshold, hard_stop_singularity_threshold,
107 lower_collision_proximity_threshold, hard_stop_collision_proximity_threshold, low_pass_filter_coeff,
108 publish_period, publish_delay, incoming_command_timeout, joint_limit_margin, collision_check_rate;
126 void deltaCartesianCmdCB(
const geometry_msgs::TwistStampedConstPtr& msg);
127 void deltaJointCmdCB(
const jog_msgs::JogJointConstPtr& msg);
128 void jointsCB(
const sensor_msgs::JointStateConstPtr& msg);
133 static void* jogCalcThread(
void* thread_id);
152 double filter(
double new_msrmt);
153 void reset(
double data);
154 double filter_coeff_ = 10.;
157 double prev_msrmts_[3] = { 0., 0., 0. };
158 double prev_filtered_msrmts_[2] = { 0., 0. };
163 filter_coeff_ = low_pass_filter_coeff;
168 prev_msrmts_[0] = data;
169 prev_msrmts_[1] = data;
170 prev_msrmts_[2] = data;
172 prev_filtered_msrmts_[0] = data;
173 prev_filtered_msrmts_[1] = data;
179 prev_msrmts_[2] = prev_msrmts_[1];
180 prev_msrmts_[1] = prev_msrmts_[0];
181 prev_msrmts_[0] = new_msrmt;
183 double new_filtered_msrmt = (1 / (1 + filter_coeff_ * filter_coeff_ + 1.414 * filter_coeff_)) *
184 (prev_msrmts_[2] + 2 * prev_msrmts_[1] + prev_msrmts_[0] -
185 (filter_coeff_ * filter_coeff_ - 1.414 * filter_coeff_ + 1) * prev_filtered_msrmts_[1] -
186 (-2 * filter_coeff_ * filter_coeff_ + 2) * prev_filtered_msrmts_[0]);
189 prev_filtered_msrmts_[1] = prev_filtered_msrmts_[0];
190 prev_filtered_msrmts_[0] = new_filtered_msrmt;
192 return new_filtered_msrmt;
202 const std::unique_ptr<robot_model_loader::RobotModelLoader>& model_loader_ptr);
211 bool cartesianJogCalcs(
const geometry_msgs::TwistStamped& cmd,
jog_arm_shared& shared_variables);
213 bool jointJogCalcs(
const jog_msgs::JogJoint& cmd,
jog_arm_shared& shared_variables);
218 Eigen::VectorXd scaleCartesianCommand(
const geometry_msgs::TwistStamped& command)
const;
220 Eigen::VectorXd scaleJointCommand(
const jog_msgs::JogJoint& command)
const;
222 Eigen::MatrixXd pseudoInverse(
const Eigen::MatrixXd& J)
const;
225 Eigen::MatrixXd pseudoInverse(
const Eigen::MatrixXd& u_matrix,
const Eigen::MatrixXd& v_matrix,
const Eigen::MatrixXd& s_diagonals)
const;
227 void enforceJointVelocityLimits(Eigen::VectorXd& calculated_joint_vel);
228 bool addJointIncrements(sensor_msgs::JointState& output,
const Eigen::VectorXd& increments)
const;
232 void resetVelocityFilters();
236 void halt(trajectory_msgs::JointTrajectory& jt_traj);
238 void publishWarning(
bool active)
const;
240 bool checkIfJointsWithinBounds(trajectory_msgs::JointTrajectory_<
std::allocator<void>>& new_jt_traj);
244 double decelerateForSingularity(Eigen::MatrixXd jacobian,
const Eigen::VectorXd commanded_velocity);
247 bool applyVelocityScaling(
jog_arm_shared& shared_variables, trajectory_msgs::JointTrajectory& new_jt_traj,
248 const Eigen::VectorXd& delta_theta,
double singularity_scale);
250 trajectory_msgs::JointTrajectory composeOutgoingMessage(sensor_msgs::JointState& joint_state,
253 void lowPassFilterVelocities(
const Eigen::VectorXd& joint_vel);
255 void lowPassFilterPositions();
257 void insertRedundantPointsIntoTrajectory(trajectory_msgs::JointTrajectory& trajectory,
int count)
const;
280 const std::unique_ptr<robot_model_loader::RobotModelLoader>& model_loader_ptr);
285 #endif // JOG_ARM_SERVER_H double collision_velocity_scale
tf::TransformListener listener_
double filter(double new_msrmt)
std::string warning_topic
pthread_mutex_t collision_velocity_scale_mutex
sensor_msgs::JointState incoming_jts_
pthread_mutex_t zero_joint_cmd_flag_mutex
bool zero_cartesian_cmd_flag
std::vector< jog_arm::LowPassFilter > position_filters_
pthread_mutex_t incoming_cmd_stamp_mutex
bool publish_joint_velocities
ros::Time incoming_cmd_stamp
trajectory_msgs::JointTrajectory new_traj_
pthread_mutex_t new_traj_mutex
geometry_msgs::TwistStamped command_deltas
pthread_mutex_t joint_command_deltas_mutex
jog_msgs::JogJoint joint_command_deltas
ros::Publisher warning_pub_
jog_arm_parameters parameters_
sensor_msgs::JointState joints
static std::unique_ptr< robot_model_loader::RobotModelLoader > model_loader_ptr_
moveit::planning_interface::MoveGroupInterface move_group_
pthread_mutex_t zero_cartesian_cmd_flag_mutex
pthread_mutex_t command_is_stale_mutex
std::vector< jog_arm::LowPassFilter > velocity_filters_
pthread_mutex_t joints_mutex
trajectory_msgs::JointTrajectory new_traj
LowPassFilter(double low_pass_filter_coeff)
const robot_state::JointModelGroup * joint_model_group_
sensor_msgs::JointState original_jts_
pthread_mutex_t ok_to_publish_mutex
robot_state::RobotStatePtr kinematic_state_
pthread_mutex_t command_deltas_mutex