Computer control

This forum is dedicated to software development related to MultiWii.
It is not the right place to submit a setup problem.
Software download
Post Reply
User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Computer control

Post by alduxvm »

Hi all!!!

I want to control the MW from the computer, why?? because I have motion tracking cameras, and I want to perform some navigation algorithms, my idea is to have on my computer a 3DR radio or a Xbee or even a BT adapter, and another on my quad, and just send the commands to it.

I've been reading on other posts about:

Code: Select all

#define RCSERIAL


and also some stuff about:

Code: Select all

static int16_t rcData[RC_CHANS];


So... in config.h I have to make the proper settings for that, maybe disable the normal radio??? or can both exits as failsafe, my radio and the computer??

For the computer side, I guess I need to write something that sends the rcData via the MW serial protocol right??? anyone has some wee example about that?

something like: rcData[RC_CHANS] = { 1500, 1500, 1500, 1000, 1000, 1000, 1000, 1000 }; that well every channel will be a variable of course...

Is this the right direction??

Any ideas?? suggestions??

Cheers!!

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

I'll start making this using processing...

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

Here is how I do it in my Joystick adaptation. I am only sending the first four channels however, you can modify it as required.

Code: Select all

LeftStick.setArrayValue(new float[] {leftX-900,2100-leftY});//.setArrayValue(new float[] {600, 600})
RightStick.setArrayValue(new float[] {rightX-900,2100-rightY});

    if ((time-time5)>40 ){
      time5=time;
      payload = new ArrayList<Character>();
      payload.add(char((int)rightX % 256));
      payload.add(char((int)rightX / 256));
      payload.add(char((int)rightY % 256));
      payload.add(char((int)rightY / 256));
      payload.add(char((int)leftX % 256));
      payload.add(char((int)leftX / 256));
      payload.add(char((int)leftY % 256));
      payload.add(char((int)leftY / 256));
      payload.add(char(1500 % 256));
      payload.add(char(1500 / 256));
      payload.add(char(1500 % 256));
      payload.add(char(1500 / 256));
      payload.add(char(1500 % 256));
      payload.add(char(1500 / 256));
      payload.add(char(1500 % 256));
      payload.add(char(1500 / 256));
      sendRequestMSP(requestMSP(MSP_SET_RAW_RC,payload.toArray(new Character[payload.size()])));
    }
Attachments
MultiWiiConf_2_1JoyStick.zip
(19 KiB) Downloaded 348 times

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

wow!! thanks a lot!! ill post my code as well and maybe a small video ;)

Cheers!!

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

I'm having a wee problem...

"Cannot find a class or type named "Slider2D""

mmmmm, strange because controlP5 library is correctly working...

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

If you want to use joystick, you will have to install procontroll, just comment that out if not required.

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

Oh and beware procontroll, only seems to work with WindowsXP and with Processing 1.5. I suggest, just removing it and using the code segments mentioned above.

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

ok, i manage to put it to work, using mac, procontroll and processing 1.5... MW 2.2 (on quad) and the MW config that copterrichie give me :)

I did two tests, the first one, was using the usb cable, this one works excellent, very quick response, but of course I cannot flight because of the cable.

The second test was using 3DR radios, I configure them at 115kbps and the response had a delay, making in it almost impossible to fly without having crash.

Is there a way to make it more quick??

ahhhh and my controls are inverted... hehehe

Cheers!!!

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

My Friend, this delay or latency is at the very core of the problem. Wireless devices with the exception of the cellphone which has the ability to trans and receive at the sometime are half-duplex devices. It takes time to raise and lower the signal to establish the connection. Here is a little write up on Bluetooth but it also applies to the 433mhz, wifi and others.

http://www.free2move.se/?page_id=1058

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

IMO, there is two ways to address this problem, 1. have two devices operating on two frequencies, one for sending and the second for receiving. However, this would be extremely complicated both in hardware and software. 2. rewrite the present code establishing a priority system with flight control being at the top of the list. When the connection is opened, send as much data as possible before changing direction for an answer.

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

I removed all telemetry data and the rest of the data thats send/received, and only send the RC commands, and I did my first flight right now :)

I just need to modify a little bit the rate, expo, mid, to be able to fly it better, but is working!!!

:)

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

Awesome, I really would appreciate seeing your work. Been meaning to do the same, just have not gotten around to do it. :)

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

ll make a video and upload it :)

Cheers!!

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

This are some flights I did with the modifications to be more fast ;)





How about that??

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

Absolutely Awesome!! How are you controlling the Yaw and Throttle?

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

P.S. I THINK I see just a little delay in your hand movement and the response of the copter. MAYBE removing the reply/answer from the Firmware may give the desired results. It is talked about here: viewtopic.php?f=8&t=3002&p=35694#p35691

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Computer control

Post by crashlander »

Hello!
I'm flying my own version of RCSERIAL TX (https://code.google.com/p/mwii-msp-tx/) using APC802 and APC220 over 19200 baud and with 40Hz refresh rate, with default setup (it means every MSP command is confirmed by MWII but TX is not waiting for it) and the delay/latency/lag in copter response is IMO negligible. Now I have better comparison since I'm flying with same TX (Spektrum DX7) but once with 2.4 build in radio and second with my own TX module.

Regards
Andrej

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

The problem being, these are HALF-Duplex devices and with each response regardless of the TX is waiting for that response, the signal has to be lowered then reversed to send the response. It takes time to raise and lower the signal to switch direction.

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Computer control

Post by crashlander »

@copterrichie
Yes I'm aware of the underlying issue! But I'm just saying that I can not currently confirm any real differences between using DX7 natively and MSP (over APC802 link).
And today I was testing just that with FFF, sharp turns and some loops and the only limiting factor today was bad bearing in one of the motors (but that influenced also DX7 native mode).

Regards
Andrej

copterrichie
Posts: 2261
Joined: Sat Feb 19, 2011 8:30 pm

Re: Computer control

Post by copterrichie »

Cool

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

is no possible to test your scripts @crashlander??

i would like to test this: https://code.google.com/p/mwii-msp-tx/

cheers!!

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Computer control

Post by crashlander »

Hello!
Sorry bout I do not really understand your question.
My code is divided into two versions, original one with analog reading and new for reading sumPPM signal from TX trainer port.
New sum PPM code (https://code.google.com/p/mwii-msp-tx/s ... PPM_msp_tx) consist of only 3 files (one with function for reading/ decoding sum PPM signal, another for converting/encoding uint16_t values of RC signal to MSP command and third that just binds everything together).
The code runs on Ardu ProMini and channel order is optimized for Spktrum DX7 PPM signal.
But since you are already flying with your code I do not think you will find anything interesting or very new in my code.

Regards
Andrej

User avatar
Vectorman
Posts: 1
Joined: Thu May 23, 2013 5:14 am
Location: Russia

Re: Computer control

Post by Vectorman »

Hello!

I am working on the same thing. I want to build quadX copter, and control it from my Android. Like an ARDrone.
For now I written an control app, which communicating ti copter via Wi-Fi. On copter, in addition to MultiWii, I've placed single board computer (RaspberryPi).
First my idea was generate at Raspberry GPIO pins required PWM signal. Unfortunately, the idea did not pay off (failed to achieve the exact duration of the pulse). So, I've decided - why do not I pass a values of Throttle, Roll, Yaw and Pitch on the digital channel? Now I have difficulty understanding MultiWii firmware code...
I've read some things about

Code: Select all

//#define RCSERIAL 
So, can you give me some more detailed explain? :)

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

ok, it appears we are working on the same, care to chat??? alduxvm at gmail, write a email and we can start from there, when we get results, we can publish them here :)

cheers!!

gompf-2
Posts: 136
Joined: Sun Jun 05, 2011 11:46 am

Re: Computer control

Post by gompf-2 »

Vectorman wrote:I've read some things about

Code: Select all
//#define RCSERIAL

So, can you give me some more detailed explain? :)


Hi Vectorman,
by this define you can use the GUI serial port to transfer rc controls by using MSP_SET_RAW_RC as header. Furthermore you have fallback/failsafe to "normal" reciever on case links breaks down, very fine for test phase (if it works you can finally comment ppm/sum_ppm stuff to safe some flash) .
Have a look at http://www.multiwii.com/forum/viewtopic.php?f=8&t=3101 for Alex´ code for the details.

Regards,
gompf

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Computer control

Post by crashlander »

In later _shared versions there is no more RCSERIAL define since that option is always active!
And also from those versions on you can simultaneously use serial and standard TX before (eg. official 2.2) it was compile-time decision.

Regards
Andrej

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Computer control

Post by PatrikE »

Hi Andrej.

I tested mwii-msp-tx.
It seems to work fine with Acp220 at 19200.

But....
It totally blocks the remote for the cars in the neighberhood!.... :o
First I though the battery in my key was dead.
But the spare key was dead to!

Then the neighbur Came and couldn't open his car....
After i shut it of the keys work again.

A perfect prank for the neighburs :lol:

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Computer control

Post by crashlander »

@PatrikE
Ups! :)
I normally fly in the middle of nowhere so I have not found no side effects (but I don't know about other faraway people when I'm playing with 500mW APC802) :!:
When I range tested (APC802) (not flying) I was able to arm my quad on the distance of aprox. 800m in the city between buildings.

But I'm aware that 433MHz is in Europe open frequency that can be used by anybody with limitation of 25mW and less than 10% duty-cycle.

Regards
Andrej

PatrikE
Posts: 1976
Joined: Tue Apr 12, 2011 6:35 pm
Location: Sweden
Contact:

Re: Computer control

Post by PatrikE »

I havn't made any rangetests yet.

I have also added a PPM_OK boolean .
It's set to true when interupt is trigged
After transitting its reset.

If PPM is lost it will stop transmit and MWii can enable Failsafe or switch to Frsky.

I run the FRsky module in transmitter and Acp on TrainerPort.
Flipping the powerswitch on radio switches between the "modules".

Btw.
It would be funny to start it at the shoppingCener and see all confused people ;)

/Patrik

naruto128
Posts: 4
Joined: Tue Jun 18, 2013 4:29 am

Re: Computer control

Post by naruto128 »

alduxvm wrote:This are some flights I did with the modifications to be more fast ;)





How about that??



hi, can put you code?

naruto128
Posts: 4
Joined: Tue Jun 18, 2013 4:29 am

Re: Computer control

Post by naruto128 »

crashlander wrote:Hello!
I'm flying my own version of RCSERIAL TX (https://code.google.com/p/mwii-msp-tx/) using APC802 and APC220 over 19200 baud and with 40Hz refresh rate, with default setup (it means every MSP command is confirmed by MWII but TX is not waiting for it) and the delay/latency/lag in copter response is IMO negligible. Now I have better comparison since I'm flying with same TX (Spektrum DX7) but once with 2.4 build in radio and second with my own TX module.

Regards
Andrej


Hello!, I do not find your code

crashlander
Posts: 506
Joined: Thu May 05, 2011 8:13 am
Location: Slovenia

Re: Computer control

Post by crashlander »

naruto128 wrote:
crashlander wrote:Hello!
I'm flying my own version of RCSERIAL TX (https://code.google.com/p/mwii-msp-tx/) using APC802 and APC220 over 19200 baud and with 40Hz refresh rate, with default setup (it means every MSP command is confirmed by MWII but TX is not waiting for it) and the delay/latency/lag in copter response is IMO negligible. Now I have better comparison since I'm flying with same TX (Spektrum DX7) but once with 2.4 build in radio and second with my own TX module.

Regards
Andrej


Hello!, I do not find your code

You should get familiar with Google's SVN....
But it is here: https://code.google.com/p/mwii-msp-tx/s ... PPM_msp_tx

Regards
Andrej

weisseruebe
Posts: 15
Joined: Fri Oct 12, 2012 1:13 am

Re: Computer control

Post by weisseruebe »

Has anybody considered taking a TX module from an RCSet and feed that with Signals from an Arduino connected to a PC?
Doing it that way, it should be pretty fast and one can use the available RC-Equipment with very good range.

naruto128
Posts: 4
Joined: Tue Jun 18, 2013 4:29 am

Re: Computer control

Post by naruto128 »

copterrichie wrote:Here is how I do it in my Joystick adaptation. I am only sending the first four channels however, you can modify it as required.

Code: Select all

LeftStick.setArrayValue(new float[] {leftX-900,2100-leftY});//.setArrayValue(new float[] {600, 600})
RightStick.setArrayValue(new float[] {rightX-900,2100-rightY});

    if ((time-time5)>40 ){
      time5=time;
      payload = new ArrayList<Character>();
      payload.add(char((int)rightX % 256));
      payload.add(char((int)rightX / 256));
      payload.add(char((int)rightY % 256));
      payload.add(char((int)rightY / 256));
      payload.add(char((int)leftX % 256));
      payload.add(char((int)leftX / 256));
      payload.add(char((int)leftY % 256));
      payload.add(char((int)leftY / 256));
      payload.add(char(1500 % 256));
      payload.add(char(1500 / 256));
      payload.add(char(1500 % 256));
      payload.add(char(1500 / 256));
      payload.add(char(1500 % 256));
      payload.add(char(1500 / 256));
      payload.add(char(1500 % 256));
      payload.add(char(1500 / 256));
      sendRequestMSP(requestMSP(MSP_SET_RAW_RC,payload.toArray(new Character[payload.size()])));
    }


hi thanks for sharing your code. works wonders.

I can ... but it does remove the replica, and only send the RC commands?,
I comment here: / / headSerialReply (0);

evaluateCommand void () {
switch (cmdMSP) {
MSP_SET_RAW_RC case:
for (uint8_t i = 0; i <8; i + +) {
RCDATA [i] = read16 ();
}
/ / HeadSerialReply (0);
break;

, But the same thing keeps sending the replies to processing.

cwleveck
Posts: 4
Joined: Mon Jul 01, 2013 6:28 pm

Re: Computer control

Post by cwleveck »

I use a usb analog controller that allows me to make my own joystick, it takes up to 8 potentiometers and 16 buttons and then I use a usb ppm converter to send a signal to an OpenLRS module.

Endurance R/C Hardware:
USB Analog reader
USB PCTx

Endurance R/C Software:
Servo Commander

Flytron Hardware:
OpenLRS TX and RX modules (I don't know how the "orange" hardware stacks up but I'm a very loyal customer and Melih is a stand up guy, so I use the original flytron equip and I haven't had any issues with it.)
Also, the rx module can be used as a TX which allows for telemetry back to the pc, ALSO if your really good, the rx module IS an arduino mini complete with i2c so you can easily run your sensors directly into your rx so there is no need for a separate rx/arduino board.

ALSO ALSO, and this is my favorite part, the PCTx can put out 9 channels over ppm, even if you are using it as intended through the trainer port of a 4 CHANNEL TRANSMITTER!
OH, and you can run multiple PCTx's. So if you've got a large model with a bunch of functions go crazy and build yourself a custom cockpit (like I did) with buttons, knobs and what have you.

ALSO ALSO ALSO. the OpenLRS rx can be run in ppm mode or I think even in serial mode, but I haven't tried either.

ALSO ALSO ALSO ALSO, everything I mention here is TOTALLY OPEN SOURCE. So hopefully I can get one of you guys who knows how to program (im a hopeless hardware guy) to help me implement some of my REALLY cool ideas.


Anyway, this whole solution is like a couple hundred bucks. Works great. Ive been using it to fly my blade helis and I love flying fpv with my mqx. I use usb pedals for yaw, so I can pedal turn in place without my altitude changing. I also use a home made collective stick for, well, collective. Its pretty cool flying stick and rudder with an mqx from my basement "theatre" with an overhead projector and a 200 inch screen with my own cockpit. I don't fly that one outside, but I do with my 8 foot telemaster. With the LRS at 433mhz and a 1.2 video tx, eagletree ant tracker, yaghi and patch antenna on the ground and a v-ant on the aircraft, I can go out a little ways.

Did I ever mention I get no lag time and ive been using this setup for months with no loss of aircraft? 2 years without the OpenLRS (just got it).

Now all I need is someone in Oregon to play with. Anyone around Salem who wants to fly with me?

cwleveck
Posts: 4
Joined: Mon Jul 01, 2013 6:28 pm

Re: Computer control

Post by cwleveck »

Crickets...... I thought for sure somebody would be interested in this.
nobody else is interested in building a realistic cockpit to use as a pc driven transmitter?
maybe I'm ahead of my time, or really far behind....
did any of you guys ever get a latency problems figured out?

User avatar
alduxvm
Posts: 40
Joined: Thu Apr 25, 2013 2:25 pm
Contact:

Re: Computer control

Post by alduxvm »

I still have the latency problems, I'm trying now with a BT radio i have and after one minute of being on, it start working nice... so, I'm going to use BT... and i just bought a couple of nRF24L01 with a UART interface, so I will try them as well...

Cheers!!

Post Reply