45 #include <sensor_msgs/JointState.h> 46 #include <std_msgs/Float64MultiArray.h> 48 #define KEYCODE_a 0x61 49 #define KEYCODE_b 0x62 50 #define KEYCODE_c 0x63 51 #define KEYCODE_d 0x64 52 #define KEYCODE_e 0x65 53 #define KEYCODE_f 0x66 54 #define KEYCODE_g 0x67 55 #define KEYCODE_h 0x68 56 #define KEYCODE_i 0x69 57 #define KEYCODE_j 0x6a 58 #define KEYCODE_k 0x6b 59 #define KEYCODE_l 0x6c 60 #define KEYCODE_m 0x6d 61 #define KEYCODE_n 0x6e 62 #define KEYCODE_o 0x6f 63 #define KEYCODE_p 0x70 64 #define KEYCODE_q 0x71 65 #define KEYCODE_r 0x72 66 #define KEYCODE_s 0x73 67 #define KEYCODE_t 0x74 68 #define KEYCODE_u 0x75 69 #define KEYCODE_v 0x76 70 #define KEYCODE_w 0x77 71 #define KEYCODE_x 0x78 72 #define KEYCODE_y 0x79 73 #define KEYCODE_z 0x7a 74 #define KEYCODE_ESCAPE 0x1B 77 struct termios cooked,
raw;
81 tcsetattr(
kfd, TCSANOW, &cooked);
92 std::cout <<
"init " << std::endl;
105 if(msg->position.size() != 7)
113 cmd_.data = msg->position;
129 tcgetattr(
kfd, &cooked);
130 memcpy(&
raw, &cooked,
sizeof(
struct termios));
131 raw.c_lflag &=~ (ICANON | ECHO);
135 tcsetattr(
kfd, TCSANOW, &
raw);
137 puts(
"Reading from keyboard");
138 puts(
"---------------------------");
139 puts(
"Use 'QA' to for joint 1");
140 puts(
"Use 'WS' to for joint 2");
141 puts(
"Use 'ED' to for joint 3");
142 puts(
"Use 'RF' to for joint 4");
143 puts(
"Use 'TG' to for joint 5");
144 puts(
"Use 'YH' to for joint 6");
145 puts(
"Use 'UJ' to for joint 7");
148 double delta_dist = 0.005;
153 if(read(
kfd, &c, 1) < 0)
163 cmd_.data[0] =
cmd_.data[0] + delta_dist;
166 cmd_.data[0] =
cmd_.data[0] - delta_dist;
170 cmd_.data[1] =
cmd_.data[1] + delta_dist;
173 cmd_.data[1] =
cmd_.data[1] - delta_dist;
177 cmd_.data[2] =
cmd_.data[2] + delta_dist;
180 cmd_.data[2] =
cmd_.data[2] - delta_dist;
184 cmd_.data[3] =
cmd_.data[3] + delta_dist;
187 cmd_.data[3] =
cmd_.data[3] - delta_dist;
191 cmd_.data[4] =
cmd_.data[4] + delta_dist;
194 cmd_.data[4] =
cmd_.data[4] - delta_dist;
198 cmd_.data[5] =
cmd_.data[5] + delta_dist;
201 cmd_.data[5] =
cmd_.data[5] - delta_dist;
205 cmd_.data[6] =
cmd_.data[6] + delta_dist;
208 cmd_.data[6] =
cmd_.data[6] - delta_dist;
212 std::cout << std::endl;
213 std::cout <<
"Exiting " << std::endl;
218 std::cout <<
"CODE: " << c << std::endl;
242 std_msgs::Float64MultiArray
cmd_;
247 int main(
int argc,
char** argv)
249 ros::init(argc, argv,
"joints_teleop_keyboard");
void publish(const boost::shared_ptr< M > &message) const
#define ROS_ERROR_STREAM_NAMED(name, args)
Subscriber subscribe(const std::string &topic, uint32_t queue_size, void(T::*fp)(M), T *obj, const TransportHints &transport_hints=TransportHints())
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
std_msgs::Float64MultiArray cmd_
ros::Subscriber joints_sub_
bool has_recieved_joints_
void stateCallback(const sensor_msgs::JointStateConstPtr &msg)
struct termios cooked raw
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Publisher joints_pub_
#define ROS_ERROR_STREAM(args)
int main(int argc, char **argv)