rosflight / rosflight_joy

A simple collection of joystick helper nodes for use with the rosflight stack
4 stars 6 forks source link

How to control from the keyboard + mouse? #4

Closed Dines97 closed 5 years ago

Dines97 commented 5 years ago

A little dumb problem. But I don't have a xbox controller or any other. It’s just that in our team I’m not a pilot, but rather a developer and didn’t think about the need for one for myself. So, how to use the keyboard?

superjax commented 5 years ago

You might want to check out 'vimfly'

https://github.com/byu-magicc/roscopter/blob/master/roscopter_utils/src/vimfly

I haven't used it personally, but I think it works! Perhaps @plusk01 or @mmmfarrell would know better.

Dines97 commented 5 years ago

I did not say but we are developing a fixed wing and the control scheme in vimfly as I understood for multirotor. How are the commands in general transmitted with the joystick in ROSflight? The rosflight_joy package uses RCRaw messages; vimfly uses Command. So which one is the right one and how to use it? The problem is that we want to further connect opencv and we need to transfer commands from it.

Dines97 commented 5 years ago

As I understand in RCRaw, the first four variables are responsible for the AETR, right? Then what are the last four variables responsible for?

mmmfarrell commented 5 years ago

@Dines97 It seems to me that you have two different options here based off the two different types of "commands" you are talking about. Think about a real hardware system. Rosflight assumes there is always an RC transmitter directly connected to the flight controller. This RC transmitter is used to arm and fly the UAV. Optionally, rosflight supports off board control. These commands (Command msgs) would come from your autopilot running on a computer that is talking to the flight controller. The RC transmitter can always be used to override the off board commands if needed. So here are the two options I understand.

  1. Create a node modeled after 'vimfly' that sends Command messages to the flight controller (rosflight). These commands can be calculated based on the keyboard or however you decide to do it for your node. From what I understand you want to use OpenCV to generate commands based on visual feedback. If this is the case, this option would best replicate a real system in hardware because the flight controller can always accept off board commands (Command msg) from your onboard computer while still listening to the real RC transmitter in case the safety pilot needs to intervene.

  2. Create a node that publishes RCRaw messages. This would be best if you want to simulate the RC transmitter. This node would be modeled after the rosflight_joy node. This would be hard to do with a keyboard since you don't have variables axes (it would be 100% or 0% with a key press).

Hopefully this helps.

superjax commented 5 years ago

7 Also adds this functionality in a very nice way