-
Notifications
You must be signed in to change notification settings - Fork 1
Joystick‐based Joint Control
Anubhav Singh edited this page Dec 21, 2023
·
1 revision
void QNode::joy_joint_state_cb(const sensor_msgs::Joy::ConstPtr& joy_msg)
{
ROS_INFO("Joystick Joint Control");
trajectory_planning_gui::JogJoint msg;
msg.header.stamp = ros::Time::now();
msg.header.frame_id = frame_id_;
msg.joint_names.resize(6);
for (int i=0; i<6; i++)
{
msg.joint_names[i] = joint_names[i];
}
msg.deltas.resize(6);
msg.deltas[0] = 0.05 * (-joy_msg->buttons[4] + joy_msg->buttons[5]);
msg.deltas[1] = 0.05 * (-joy_msg->buttons[0] + joy_msg->buttons[2]);
msg.deltas[2] = 0.05 * (joy_msg->buttons[1] - joy_msg->buttons[3]);
msg.deltas[3] = 0.05 * (joy_msg->axes[7]);
msg.deltas[4] = 0.05 * (joy_msg->axes[6]);
msg.deltas[5] = 0.05 * (-joy_msg->buttons[11] + joy_msg->buttons[12]);
jog_joint_pub_.publish(msg);
}