Hello,
Thanks for the suggestions. Finally, I achieved controlling model from the keyboard. I used http://wiki.ros.org/turtlesim example code. I took turtlesim, terminal reading part and added it to update function of my model. In every update, it checks if there is a key press. update function of my code is below.
// Called by the world update start event
public: void OnUpdate()
{
char c;
int kfd = 0;
struct termios cooked, raw;
// get the console in raw mode
tcgetattr(kfd, &cooked);
memcpy(&raw, &cooked, sizeof(struct termios));
raw.c_lflag &=~ (ICANON | ECHO);
// Setting a new line, then end of file
raw.c_cc[VEOL] = 1;
raw.c_cc[VEOF] = 2;
tcsetattr(kfd, TCSANOW, &raw);
struct pollfd pfd = {0,0,0}; /* poll() settings */
int pr; /* poll() result */
pfd.fd = STDIN_FILENO;
pfd.events = POLLIN;
pr = poll(&pfd, 1, 100);
if(pr>0)
{
if(read(kfd, &c, 1) < 0)
{
perror("read():");
exit(-1);
}
double rad = 1;
switch(c)
{
case KEYCODE_L:
puts("LEFT");
this->left_wheel_joint_->SetAngle(0,0); //joint
break;
case KEYCODE_D:
puts("DOWN");
this->left_wheel_joint_->SetAngle(0,-rad); //joint
break;
}
}
else{
//no key
}
}