Need Help Figuring Out Library "ncurses" [closed]
Hi everyone, I am using ROS Indigo in conjunction with Gazebo 2.2.3 on Ubuntu 14.04. I'm trying to set up my keyboard teleop program so that it will accept a series of commands without me having to press the Enter key every time I type in a command. I installed the ncurses library and have added the following line to my package's package.xml:
<build_depend>ncurses++</build_depend>
<run_depend>ncurses++</run_depend>
I've also added the following lines to my CMakeLists.txt:
find_package( PkgConfig REQUIRED )
pkg_check_modules ( ncurses++ REQUIRED ncurses++ )
add_executable(odg_control_keyboard_august_26 src/odg_control_keyboard_august_26.cpp)
target_link_libraries(odg_control_keyboard_august_26 ${catkin_LIBRARIES})
target_link_libraries(odg_control_keyboard_august_26 ${ncurses++_LIBRARIES})
add_dependencies(odg_control_keyboard_august_26 ${catkin_EXPORTED_TARGETS})
My code looks like the following:
#include "ros/ros.h"
#include <gazebo_msgs/ApplyJointEffort.h>
#include <gazebo_msgs/GetModelState.h>
#include <cstdlib>
#include <iostream>
#include <stdio.h>
#include "ncurses.h"
using namespace std;
int main (int argc, char **argv)
{
//Initial setup
ros::init(argc,argv,"odg_control_keyboard_august_26");
ros::NodeHandle n;
ros::Duration dur = ros::Duration(5);
initscr();
cbreak();
noecho();
keypad(stdscr, TRUE);
//This client will handle all actions relating to getting the state of the model. It will come into play in the loop.
//This client will handle moving the model.
ros::ServiceClient clientMove = n.serviceClient<gazebo_msgs::ApplyJointEffort>("/gazebo/apply_joint_effort");
gazebo_msgs::ApplyJointEffort applyjointeffort[4];
applyjointeffort[0].request.joint_name = "left_front_wheel_hinge";
applyjointeffort[1].request.joint_name = "right_front_wheel_hinge";
applyjointeffort[2].request.joint_name = "left_rear_wheel_hinge";
applyjointeffort[3].request.joint_name = "right_rear_wheel_hinge";
applyjointeffort[0].request.duration = dur;
applyjointeffort[1].request.duration = dur;
applyjointeffort[2].request.duration = dur;
applyjointeffort[3].request.duration = dur;
int ch = getch();
while(ch != KEY_BACKSPACE)
{
int ch = getch();
switch (ch)
{
case KEY_UP:
applyjointeffort[0].request.effort = 3;
applyjointeffort[1].request.effort = 3;
applyjointeffort[2].request.effort = 3;
applyjointeffort[3].request.effort = 3;
clientMove.call(applyjointeffort[0]);
clientMove.call(applyjointeffort[1]);
clientMove.call(applyjointeffort[2]);
clientMove.call(applyjointeffort[3]);
case KEY_LEFT:
applyjointeffort[0].request.effort = -2.7;
applyjointeffort[1].request.effort = 3;
applyjointeffort[2].request.effort = -2.7;
applyjointeffort[3].request.effort = 3;
clientMove.call(applyjointeffort[0]);
clientMove.call(applyjointeffort[1]);
clientMove.call(applyjointeffort[2]);
clientMove.call(applyjointeffort[3]);
case KEY_DOWN:
applyjointeffort[0].request.effort = -3;
applyjointeffort[1].request.effort = -3;
applyjointeffort[2].request.effort = -3;
applyjointeffort[3].request.effort = -3;
clientMove.call(applyjointeffort[0]);
clientMove.call(applyjointeffort[1]);
clientMove.call(applyjointeffort[2]);
clientMove.call(applyjointeffort[3]);
case KEY_RIGHT:
applyjointeffort[0].request.effort = 3;
applyjointeffort[1].request.effort = -2.7;
applyjointeffort[2].request.effort = 3;
applyjointeffort[3].request.effort = -2.7;
clientMove.call(applyjointeffort[0]);
clientMove.call(applyjointeffort[1]);
clientMove.call(applyjointeffort[2]);
clientMove.call(applyjointeffort[3]);
case KEY_BACKSPACE:
printf("Quitting now!\n");
break;
default:
printf("Invalid input!\n");
}
}
endwin();
}
However, when I try to compile it with catkin_make, I end up with the following errors:
odg_control_keyboard_august_26.cpp:(.text+0x10c): undefined reference to `initscr'
odg_control_keyboard_august_26.cpp:(.text+0x111): undefined reference to `cbreak'
odg_control_keyboard_august_26.cpp:(.text+0x116): undefined reference to `noecho'
odg_control_keyboard_august_26.cpp:(.text+0x11d): undefined reference to `stdscr'
odg_control_keyboard_august_26.cpp:(.text+0x12a): undefined reference to `keypad'
odg_control_keyboard_august_26.cpp:(.text+0x27b): undefined reference to `stdscr'
odg_control_keyboard_august_26.cpp:(.text+0x283): undefined reference to ...