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

Sensors data from CRIUS AIOPv2 & manual waypoint navigation

Postby waqarrashid33 » Thu Jun 09, 2016 2:27 pm

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..
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

Postby gregd72002 » Fri Jun 10, 2016 1:54 pm

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
gregd72002
 
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Postby waqarrashid33 » Sat Jun 11, 2016 1:41 pm

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

Postby waqarrashid33 » Sat Jun 11, 2016 6:54 pm

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..
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

Postby gregd72002 » Sat Jun 11, 2016 11:00 pm

./mw is just the service

to test connection keep the service running and try ./mwtest or ./mwcli
gregd72002
 
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Postby waqarrashid33 » Sun Jun 12, 2016 4:32 am

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")

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

Postby gregd72002 » Sun Jun 12, 2016 3:47 pm

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.
gregd72002
 
Posts: 103
Joined: Fri Dec 12, 2014 5:16 pm

Re: Sensors data from CRIUS AIOPv2 & manual waypoint navigat

Postby waqarrashid33 » Sat Jul 30, 2016 9:12 pm

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


Return to Software development

Who is online

Users browsing this forum: No registered users and 9 guests

cron