How to improve this quadcopter code

Hi,

About 20 months ago I just bought my first arduino and started playing with it. I never lighted up a single LED in my whole life, I never played with batteries, resistor... I am a "mechanical" guy, graduated in mechanical engineer at UFSC, known as the best university for mechanical engineer at South America according to ENADE (a test that checks universities across several fields). EDIT: just to make clear, this university is not a "paid" university as you have in US, it's a federal university which you can only enter after being good at some exams about maths, science, languages... the best ones get in and nobody has to pay anything cause federal universities in Brazil are completely free for those who can get in. So it's not as US where you can buy your place at good universities.

Of course, in USA you have waaay better universities than in the whole South Americe - but hey, I tried my best where I was living. Having said that you can expect that I am not retard as some of you treat me in this forum. I just said that so you can know you should not judge people without knowing them better, as many of you do here at forum.arduino. I say that cause as soon as I started playing with arduino I always wanted to make a quadcopter, always. I came to this same forum and made lots of questions and at 80% of cases I was made fun of, people didnt believe me cause I was asking so many idiot questions - if there is such a thing.

So a few months ago I finished my quadcopter with arduino and published it at youtube just to share with some friends. In the first days nobody got interested in it and I didnt care, I just posted it so I could share the video with some really close friends. After some days the video got a few views and so far at least 40 people got in touch directly with me by mail to ask about my project. and I am not even counting people commenting in the video. I think what made people like it so much is that I did almost all the code by myself. I refused myself to use premade quadocpter codes, I refused to use PID libraries... I just used the really most basic libraries around and built the entire code by myself. I am not a C programmer, sure, the code can be improved and that's why I am getting in touch with you. I think that the fact that I made almost all the code made it easy to people understand it without needing to study too much external content/libraries.

First, lets take a look at my quadcopter, shall we?

Despite some of you may say, it works. It works perfectly to me. It flyes well, is well calibrated and the algorightm has many "safe features" I included. So far, at least 25 people got in touch to show me their drone flying using my code with just a few changes on their own. I am getting a little worried cause I know my code is not the best one in the world and it may have some flaws. So I decided to come here to ask you if there is any place where I can post this project and ask good will people to take a look at the code and improve it?

The code I am hosting it in the link below and this link is already in the description of the video so anyone can download it:

https://www.sitepor500.com.br/?criacao-site-codigo728

The code of my controller (which is also entirely mine, done without any "copy" from any person) is also below:

https://www.sitepor500.com.br/?criacao-site-codigo984

Would any of you mind help me to check this code and tell if there is any good improvement I could make? I dont mean small improvements like using an unsigned int in place of int... I mean real improvements so people can fly it safe and I can be peace of mind that nobody will get hurt by using my code?

After this quadcopter I posted other videos of drones that I made with styrofoam, wood... I am really in love with this but I would like to be sure this code may not fail and fall over any child's head.

You are asking us to share in the liability you envision when someone uses your Arduino code. you should have considered this before releasing your code. You need to talk to a lawyer or but a larger insurance package.

Paul

(deleted)

@Paul_KD7HB I dont want to share liability, this kind of stupid thing is what I am saying that happens frequently here in this forum. In the top of my code there is a really easy to read warning telling people to try that code at their own risk and that the code could be buggy. If any idiot person uses that code believing it's safe and tries to fly a drone over other people's head, that people is indeed stupid. I would like to share knowledge not "liability".

@spycatcher2k good to you, actualy good for us, at least we are not stupid for electing an idiot as a president. :wink:

OK, @batata00, I'm getting fed-up of moving your posts to more appropriate sections of the forum.

@AWOL programmimg section was not appropriate? Where should I have post this? If this is not a programming question I respectly really dont think you read what I wrote.

tell if there is any good improvement I could make? I dont mean small improvements like using an unsigned int in place of int... I mean real improvements so people can fly it safe and I can be peace of mind that nobody will get hurt by using my code?

If that doesn't say "Advice on general approaches or feasibility", I'm not sure what would.

So any advice in programming should be considered "Advice on general approaches or feasibility"? So what is the point of the programming section? Everybody there is looking for advice on how to program things. So how didnt you also moved this Play 2 second audio with arduino - Project Guidance - Arduino Forum to project guidance? There are many other posts in programming that you should move, if you want I have spare time today and I can point you at least 10 posts you could move.

When you go fishing/hunting, do you catch all the fish/deer/bunnies?

No, of course not.

if you want I have spare time today and I can point you at least 10 posts you could move.

I'm delighted for you that you have spare time; I don't.

batata004:
@Paul_KD7HB I dont want to share liability, this kind of stupid thing is what I am saying that happens frequently here in this forum. In the top of my code there is a really easy to read warning telling people to try that code at their own risk and that the code could be buggy. If any idiot person uses that code believing it's safe and tries to fly a drone over other people's head, that people is indeed stupid. I would like to share knowledge not "liability".

@spycatcher2k good to you, actualy good for us, at least we are not stupid for electing an idiot as a president. :wink:

To expand a bit on my post.

Anything posted on the internet is public knowledge for ever! When someone post concern about their software or hardware posing possible risk to the public and then something happens that may relate to that software or hardware, their involvement is automatic, as far as a lawyer is involved. Anyone who examines that software and makes pronouncements about it is similarly involved.

Will it ever happen? Don't know. I did see an old man get hit in the head by a large RC sailplane as it was landing and was knocked down and had a bloody spot on his head. There used to be insurance ads in model airplane magazines. I wonder if the people flying UAVs have purchased liability insurance? You don't have to be flying them OVER people to injure someone. I have not seen any mention of UAV flying in my insurance policies.

This subject did get me to plan to add safety code to the drying oven controller I am working on. If the oven temperature goes over the set temperature by 20 degrees, sound alarm and turn the oven off.

I wonder if SSRs can fail closed, like normal relays can do?

Paul

@Paul_KD7HB I agree with you, but if people say it clearly that the code/software could cause harm to others, they want to mean that. If any stupid peron uses that code and cause harm to third parties, that stupid person is exactly what he is: stupid.

you cant prevent people from helping growing a pice of code/software just because stupid people will not read the warning notice and will try to use the code anyway killing other people. YOU CANT DO THAT! If that was the case, LIBREPILOT would have not grown as much as it did, NAZE too...

@AWOL I took my spare time to help this forum, as you clearly say you dont have spare time but even though you keep moving my posts around to other sections. When I am the subject it looks like you have spare time, but with other you dont.

Show some respect and move the topics below to the right section cause they clearly can be moved to project guidance and general electronics if we want to follow your "strict rule" of programming questions.

http://forum.arduino.cc/index.php?topic=454848.0
http://forum.arduino.cc/index.php?topic=454855.0
http://forum.arduino.cc/index.php?topic=454538.0
http://forum.arduino.cc/index.php?topic=454965.0
http://forum.arduino.cc/index.php?topic=454966.0
http://forum.arduino.cc/index.php?topic=454968.0
http://forum.arduino.cc/index.php?topic=454811.0
http://forum.arduino.cc/index.php?topic=454852.0
http://forum.arduino.cc/index.php?topic=454881.0
http://forum.arduino.cc/index.php?topic=454890.0
http://forum.arduino.cc/index.php?topic=454933.0
http://forum.arduino.cc/index.php?topic=454699.0

@AWOL I took my spare time to help this forum,

Must've missed that. Apologies.

When I am the subject it looks like you have spare time, but with other you dont.

Perhaps because I move (or suspend) so many of you posts/accounts, your handle sticks in my mind, so I remember them better.
I wonder why that would be.

Show some respect

You can whistle.

:slight_smile: