I want to be able to change the mode or position of my quadrotor by just pressing a keyboard key, while in OFFBOARD mode. Can anyone suggest for me on how to do it? I have been trying using the termios library, but it seems that the keyboard interrupt causes the quadrotor to enter failsafe mode every time I press a key that I have map to a certain mode, or even position.
i would say ncursus, i have once tried with termios, but it doesn’t get very well.
i would like also if your were able to get into offboard mode. especially if you where trying costume code rather than using ROS
Yeah I have tried before using Termios, but it doesn’t function really well and the interrupt blocks the loop of the program. Thank you for the suggestion, I will try to learn about it.
Are you using C++ or Python?
For C++, you can use the Boost library to get an input. I never used it but already saw some doing it.
For Python, if you want a beautiful interface, use urwid, or curses libraries. But the fastest way it to do it like here
With getch a minimal library for keyboard input.
I have also tried boost, using boost::asio::posix::stream_descriptor, but it doesn’t work, you have bufffering on the input.
unless if you have another way using boost. which i would like to hear.
@shrit Simply start a thread with your main loop program and you can use the second thread, buffering, as an interface.
Anyway, you can make a second program (instead of a thread) and publish some informations like “std_msgs/Bool” to “/emergency/stop”
it seems to me that you are taking about using MAVROS rather than a C++ customized code?? am I right ?
So you do not use ROS. ROS simplifies everything and do not force you to use Mavros at all.
If you do not use ROS, you are either an hardcore Linux Inter Process communication dev or you are using a library like ZMQ. If you are not, then you need one of those solutions.
Do not add you useless complexity.
Yes, of course I understand that ROS will make my life easier, a part from installing the library on raspberry pi and adding more dependencies to the code. However until the moment I’m also trying to find a way to fully control the drone using only C++ code.
I have seen your question about offboard mode:
Until now I have not been able to switch to this mode using the code, probably because i didn’t understand the principle very well, what I have understood is that you need to send in a loop empty setpoint message, and later you send command long with MAV_CMD_NAV_GUIDED_ENABLE.
I don’t if the this is what should be done, I would like to have a clear documentation on this issue from
- Have a localization system (mocap, vicon, px4flow, GPS)
- Send 100 setpoints (the same, just to say you are serioussly using setpoints)
- Set offboard mode, while on that mode send setpoints in a loop at 6Hz