Sensors data from CRIUS AIOPv2 & manual waypoint navigation

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
waqarrashid33
Posts: 9
Joined: Mon May 23, 2016 1:40 pm
Location: Kiel, Germany

Sensors data from CRIUS AIOPv2 & manual waypoint navigation

Post by waqarrashid33 »

Hello Everyone,

I am a bit new to field of multi-copters so I am sorry if I am unable to make my question clear enough, we are doing a student project on a quadcopter which is based on CRIUS AIOP v2 and its running multiwii 2.4. We can fly the drone, can see sensors data using wingui and can plan missions using mission planner. What we need to do in our project is:

1. To send that data to a raspberry pi which would on be on drone connected with the board using UART or I2C.
2. Doing mission planning instead of using mission planner.. ( I just want to know how to store the waypoints in multiwii and make it follow these way-points programatically).

Please ask me if you need more information..

gregd72002
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Post by gregd72002 »

Hi,

As far as the UART vs I2C is concerned, you want to use UART. MW has a UART protocol (MSP) to communicate with so you can manage all waypoints etc using MSP. Here is a service with API that does exactly this. https://github.com/rpicopter/mw-service

I'm currently flying a quadcopter that has MW+RPi and I can control it from command line or using QGroundControl which rrequires mw-mavlink on top of mw-service.

This should allow you to set everything you need.

Hope this helps

User avatar
waqarrashid33
Posts: 9
Joined: Mon May 23, 2016 1:40 pm
Location: Kiel, Germany

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Post by waqarrashid33 »

This seems awsome.. I will try it and will get back to you on my progress..

User avatar
waqarrashid33
Posts: 9
Joined: Mon May 23, 2016 1:40 pm
Location: Kiel, Germany

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Post by waqarrashid33 »

I compiled the mw-service in raspberry pi.. When I run the ./mw, It can't receive anything from the board.. It opens the serial port and send something but doesn't receive anything back.. The MSP is enabled as I can use this code https://github.com/alduxvm/pyMultiWii to recieve sensors data from the board..

gregd72002
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Post by gregd72002 »

./mw is just the service

to test connection keep the service running and try ./mwtest or ./mwcli

User avatar
waqarrashid33
Posts: 9
Joined: Mon May 23, 2016 1:40 pm
Location: Kiel, Germany

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Post by waqarrashid33 »

I will play with the MSP further.. I think I need to understand it a bit before I am able to use your code.. After hours of trying Finally I am able to at least send a command and recieve the response.. Now I need a parser to understand what the response is and if it is even correct.. I am posting my code here, and please if can verify that its actually receiving the correct answer..
Thanks for your help..

Code: Select all

# Send a command to multiwii using MSP protocol and prints the the received response
# Waqar
import serial,time
import binascii
ser=serial.Serial()
ser.port="/dev/ttyUSB0"
BASIC="\x24\x4d\x3c\x00"
MSP_IDT=BASIC+"\x64\x64"
MSP_STATUS=BASIC+"\x63\x63"
MSP_RAW_IMU=BASIC+"\x66\x66"
MSP_SERVO=BASIC+"\x67\x67"
MSP_MOTOR=BASIC+"\x68\x68"
MSP_RC=BASIC+"\x69\x69"
MSP_RAW_GPS=BASIC+"\x70\x70"
MSP_COMP_GPS=BASIC+"\x71\x71"
MSP_ATTITUDE=BASIC+"\x72\x72"
MSP_ALTITUDE=BASIC+"\x73\x73"
MSP_BAT=BASIC+"\x74\x74"

#CURRENT=MSP_STATUS
CURRENT=MSP_RAW_GPS
ser.baudrate=115200
ser.bytesize=serial.EIGHTBITS
ser.parity=serial.PARITY_NONE
serial.stopbits=serial.STOPBITS_ONE
ser.timeout=0
ser.xonxoff=False
ser.rtscts=False
ser.dsrdtr=False
ser.writeTimeout=2
try:
    ser.open()
except Exception as e:
    print("Error open serial port: "+str(e))
    exit()

if ser.isOpen():
    print("Sleeping")
    #print(CURRENT)
    time.sleep(15)
    print("Serial port is open at"+ser.portstr)
    try:
        ser.flushInput()
        ser.flushOutput()
        print("Flushed")
        #ser.write(CURRENT.decode("hex")) binascii.unhexlify(hexstr)
        #a= binascii.hexlify(b'$M<cc')
        #print(a)
        print(bytes(CURRENT, encoding = "UTF-8"))
        ser.write(bytes(CURRENT, encoding = "UTF-8"))
        print("data written, the response is:")
        #print("Writing to "+ser.portstr+" "+ bytes(CURRENT, encoding = "UTF-8"))
        time.sleep(0.5)
        numOfLines=0
        while True:
            response=ser.readline()
            #print(type(response))
           
            #print(response.encode("hex"))
            print(response)
            numOfLines=numOfLines+1
   
            if(numOfLines>=1):
                break
        ser.close()
    except Exception as e1:
        print("Error communicating..."+str(e1))
else:
    print("Cannot open serial port")


gregd72002
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Post by gregd72002 »

MSP_RAW_GPS has ID of 106 (0x6A). Also you need to send CRC as part of each message. Not sure why you try to encode to UTF8 (it just asks for troubles). It should be simply ASCII.

User avatar
waqarrashid33
Posts: 9
Joined: Mon May 23, 2016 1:40 pm
Location: Kiel, Germany

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Post by waqarrashid33 »

Hey, Thanks for your help. Now I want to understand some other parts of multiwii code so that I can make changes to it for adding more sensors etc. The code is really complex because of all these typedefs. Does anybody know a good source to start with which can help me understand the code in a better way. I would also like to get rid of the inactive code parts which are not compiled for CRIUS AIOP v2 board. Does anybody know about some easy to use tools which can do this for me? I am trying to use coan but I am unable to make it work.

Post Reply