hmartiro / project-thesis

xJüs, the hexapodal robot with a passive-backbone to improve behavior over harsh terrain.
4 stars 2 forks source link

Figure out CPP/Keyboard input interface #70

Closed PayneTrain closed 11 years ago

PayneTrain commented 11 years ago

Initial research shows that its very unfriendly/system dependent with Linux but that 'ncurses' package is the best way to go so I have downloaded it and am playing around with it

PayneTrain commented 11 years ago

Installed v5 of the ncurses dev kit, issues with including ncurses.h in a helloworld style program, appears get-apt did not place links in usr/lib so looking into that. It looks like getchar() will provide nice functionality for key based commands (press and hold W for robot to walk straight, double tap to increase speed, etc)

PayneTrain commented 11 years ago

Finally got a HelloWorld.cpp test program to compile using the -lncurses flag at the _end_ of the link command, terminal does not work with Eclipse so must be used in cmd terminal. Using getch() and keypad modifiers can get arrow key functionality (this is good for an application that waits for continuous input (pressing UP_ARROW) to move the car forward for the duration of the press (mod one leg period) ~ 2sec for the slowest)

PayneTrain commented 11 years ago

Compiling ncurses-5.9 for 32bit to be compatible with EPOS library, use this

Opened up this issue with StackOverflow

hmartiro commented 11 years ago

i just did sudo apt-get install ncurses-dev and it worked for me just fine. I just added #include <ncurses.h> and ncurses to the library include for the compiler. I made a print wrapper for ncurses and got the keypresses working. This is what I use to initialize:

initscr(); noecho(); cbreak(); keypad(stdscr, TRUE); nodelay(stdscr, TRUE); scrollok(stdscr, TRUE);

The nodelay call makes it so that getch() doesn't wait for input, but returns -1 if nothing is pressed. This works fine, but I think at this point we need to make a decision.

  1. Continue with C++ using ncurses, establishing high level control flow with the keyboard. If we need to make a graphical application, QT is our best bet.
  2. Create our own shared library libxJus.so and start using Python to call that library using a binding like Boost.python or ctypes. ncurses will be replaced with a Python package, and we can use a Python GUI toolkit.

The advantages of switching over are

Disadvantages

I just don't want to keep making stuff for C++ only to decide to switch over later cause it's just too annoying. We should make a decision and work with that.

PayneTrain commented 11 years ago

Hmm, I could only get the 64b working, not the 32b but cool!

hmartiro commented 11 years ago

my linux is 32-bit so that's probably why

hmartiro commented 11 years ago

We can forget about ncurses, look at #73