essai ncurses
This commit is contained in:
parent
ca086d8d2b
commit
286dbb36bf
5 changed files with 84 additions and 18 deletions
|
@ -9,6 +9,11 @@ find_package(catkin REQUIRED COMPONENTS
|
||||||
geometry_msgs
|
geometry_msgs
|
||||||
message_generation
|
message_generation
|
||||||
)
|
)
|
||||||
|
find_package(
|
||||||
|
PkgConfig REQUIRED
|
||||||
|
)
|
||||||
|
|
||||||
|
pkg_check_modules ( ncurses REQUIRED ncurses )
|
||||||
|
|
||||||
add_message_files(
|
add_message_files(
|
||||||
FILES
|
FILES
|
||||||
|
@ -25,6 +30,7 @@ catkin_package()
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${catkin_INCLUDE_DIRS}
|
${catkin_INCLUDE_DIRS}
|
||||||
|
${CURSES_INCLUDE_DIRS}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(filtre src/filtre.cpp)
|
add_executable(filtre src/filtre.cpp)
|
||||||
|
@ -36,6 +42,11 @@ target_link_libraries(random_pcl_publisher ${catkin_LIBRARIES})
|
||||||
add_executable(pcl_displayer src/pcl_displayer.cpp)
|
add_executable(pcl_displayer src/pcl_displayer.cpp)
|
||||||
target_link_libraries(pcl_displayer ${catkin_LIBRARIES})
|
target_link_libraries(pcl_displayer ${catkin_LIBRARIES})
|
||||||
|
|
||||||
|
add_library(curses src/curses.cpp src/curses.h)
|
||||||
|
|
||||||
|
add_executable(keyboard_cmd src/keyboard_cmd.cpp)
|
||||||
|
target_link_libraries(keyboard_cmd ${catkin_LIBRARIES} ${ncurses_LIBRARIES} curses)
|
||||||
|
|
||||||
add_executable(normal_estimator src/normal_estimator.cpp)
|
add_executable(normal_estimator src/normal_estimator.cpp)
|
||||||
target_link_libraries(normal_estimator ${catkin_LIBRARIES})
|
target_link_libraries(normal_estimator ${catkin_LIBRARIES})
|
||||||
add_dependencies(normal_estimator hand_control_generate_messages_cpp)
|
add_dependencies(normal_estimator hand_control_generate_messages_cpp)
|
||||||
|
|
37
src/curses.cpp
Normal file
37
src/curses.cpp
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
#include "curses.h"
|
||||||
|
#include <ncurses.h>
|
||||||
|
|
||||||
|
const int Curses::kbd_lines = 12;
|
||||||
|
const int Curses::kbd_columns = 50;
|
||||||
|
const int Curses::speed_lines = 4;
|
||||||
|
const int Curses::speed_columns = 50;
|
||||||
|
|
||||||
|
Curses::Curses() {
|
||||||
|
initscr();
|
||||||
|
cbreak();
|
||||||
|
noecho();
|
||||||
|
kbd = newwin(kbd_lines, kbd_columns, 0, 0);
|
||||||
|
kbd = newwin(speed_lines, speed_columns,
|
||||||
|
kbd_lines+1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
Curses::~Curses() {
|
||||||
|
delwin(kbd);
|
||||||
|
delwin(speed);
|
||||||
|
endwin();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Curses::print_kbd() {
|
||||||
|
wmove(kbd, 0, 0); waddstr(kbd, " ---------------------");
|
||||||
|
wmove(kbd, 1, 0); waddstr(kbd, "takeoff>| t|⇑ y|↖ u|↑ i|↗ o|");
|
||||||
|
wmove(kbd, 2, 0); waddstr(kbd, " |---|---|---|---|---|----");
|
||||||
|
wmove(kbd, 3, 0); waddstr(kbd, " reset>| g|⇐ h|← j| k|→ l|⇒ m|");
|
||||||
|
wmove(kbd, 4, 0); waddstr(kbd, " |---|---|---|---|---|----");
|
||||||
|
wmove(kbd, 5, 0); waddstr(kbd, " land>| b|⇓ n|↙ ,|↓ ;|↘ :|");
|
||||||
|
wmove(kbd, 6, 0); waddstr(kbd, " ---------------------");
|
||||||
|
wmove(kbd, 8, 0); waddstr(kbd, "a/w : increase/decrease linear `x` speeds by 10%");
|
||||||
|
wmove(kbd, 9, 0); waddstr(kbd, "z/x : increase/decrease linear `y` speed by 10%");
|
||||||
|
wmove(kbd, 10, 0); waddstr(kbd, "e/c : increase/decrease linear `z` speed by 10%");
|
||||||
|
wmove(kbd, 11, 0); waddstr(kbd, "r/v : increase/decrease rotation speed by 10%");
|
||||||
|
wrefresh(kbd);
|
||||||
|
}
|
23
src/curses.h
Normal file
23
src/curses.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#ifndef CURSES
|
||||||
|
#define CURSES
|
||||||
|
|
||||||
|
#include <ncurses.h>
|
||||||
|
|
||||||
|
class Curses
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
static const int kbd_lines;
|
||||||
|
static const int kbd_columns;
|
||||||
|
WINDOW* kbd;
|
||||||
|
static const char** kbd_descr;
|
||||||
|
static const int speed_lines;
|
||||||
|
static const int speed_columns;
|
||||||
|
WINDOW* speed;
|
||||||
|
|
||||||
|
public:
|
||||||
|
Curses();
|
||||||
|
~Curses();
|
||||||
|
void print_kbd();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -6,7 +6,7 @@
|
||||||
#include <ros/ros.h>
|
#include <ros/ros.h>
|
||||||
#include <ros/time.h>
|
#include <ros/time.h>
|
||||||
|
|
||||||
#include <ncurses.h>
|
#include "curses.h"
|
||||||
|
|
||||||
#include <std_msgs/Empty.h>
|
#include <std_msgs/Empty.h>
|
||||||
#include <geometry_msgs/Twist.h>
|
#include <geometry_msgs/Twist.h>
|
||||||
|
@ -25,17 +25,14 @@ class Run
|
||||||
void reset()
|
void reset()
|
||||||
{ pub_reset.publish(empty); };
|
{ pub_reset.publish(empty); };
|
||||||
float x_speed, y_speed, z_speed, turn;
|
float x_speed, y_speed, z_speed, turn;
|
||||||
void print_speed()
|
Curses term;
|
||||||
{
|
void print_speed() { ; };
|
||||||
std::cout << "x speed : " << x_speed << ", y speed : " <<
|
|
||||||
y_speed << ", z speed : " << z_speed <<
|
|
||||||
", rotation speed : " << turn << "\n";
|
|
||||||
};
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Run() :
|
Run() :
|
||||||
n(),
|
n(),
|
||||||
empty(),
|
empty(),
|
||||||
|
term(),
|
||||||
loop_rate(30),
|
loop_rate(30),
|
||||||
x_speed(0.2),
|
x_speed(0.2),
|
||||||
y_speed(0.3),
|
y_speed(0.3),
|
||||||
|
@ -47,11 +44,6 @@ class Run
|
||||||
pub_reset = n.advertise<std_msgs::Empty>("/ardrone/reset", 1);
|
pub_reset = n.advertise<std_msgs::Empty>("/ardrone/reset", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Run()
|
|
||||||
{
|
|
||||||
endwin();
|
|
||||||
}
|
|
||||||
|
|
||||||
void operator()()
|
void operator()()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -71,10 +63,6 @@ class Run
|
||||||
<<"r/v : increase/decrease rotation speed by 10%\n";
|
<<"r/v : increase/decrease rotation speed by 10%\n";
|
||||||
*/
|
*/
|
||||||
|
|
||||||
initscr();
|
|
||||||
cbreak();
|
|
||||||
noecho();
|
|
||||||
|
|
||||||
while (ros::ok())
|
while (ros::ok())
|
||||||
{
|
{
|
||||||
geometry_msgs::Twist::Ptr msg(new geometry_msgs::Twist());
|
geometry_msgs::Twist::Ptr msg(new geometry_msgs::Twist());
|
||||||
|
@ -232,12 +220,11 @@ class Run
|
||||||
default :
|
default :
|
||||||
break;
|
break;
|
||||||
} // switch
|
} // switch
|
||||||
|
|
||||||
ros::spinOnce();
|
ros::spinOnce();
|
||||||
loop_rate.sleep();
|
loop_rate.sleep();
|
||||||
|
|
||||||
} // while
|
} // while
|
||||||
} // run
|
} // run
|
||||||
|
|
||||||
}; // class
|
}; // class
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
|
|
8
src/test.cpp
Normal file
8
src/test.cpp
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
#include "curses.h"
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Curses term;
|
||||||
|
term.print_kbd();
|
||||||
|
for(;;) ;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue