Hello to everyone, and some elementary question of crazyflie.

Discussions about all things Bitcraze
Post Reply
Sexydove
Beginner
Posts: 8
Joined: Wed Apr 25, 2018 10:36 pm

Hello to everyone, and some elementary question of crazyflie.

Post by Sexydove »

Greetings!

A new freshman says hello to the forum members. There are many things I want to say, but I would like to ask just a few questions that I have. I have read and read several articles on wikis and forums, and eventually have succeeded in hovering through python scripts. And while there have been many problems or questions, as I choose one, the important part is about the distribution of the code.

To be more precise, it is a role question about the firmware written in C and the library written in python.

Obviously the firmware will manipulate the motor and send and receive signals through the GPIO, and I wonder why python is doing it. On the wiki and the bitcraze homepage, I was told to start by blinking the LEDs through the firmware, but the python library was able to manipulate the motors in the script right away without any special function or class design.

Q.1
So it is a question. Does the motor control of the firmware overlap with the motor control of the python library?
If so, is it best to leave the firmware in its existing state and use only python?
(python did not matter, but main.c, which will be made in eclipse or terminal, had some problems, continuing from Q.2)


The results of the Python script were hopeful, but the firmware 'with one additional line' made via eclipse was not. I tried putting 'motorsBeep' function in main.c(in cf2.elf), but I was not able to compile it. The problem was the 'implicit declaration of function 'motorsBeep''.(I guess, this function with difference parameter would made the beep! Beep! bee.. bip! sounds occur at the initial condition of crazyflie..?)
Though I referenced "motors.h" as a header file, and the declaration was correct, the problem seems to be a syntax error in the firmware functions. To take a few things, the 'bool' function types(TRUE, FALSE), enumeration like ENABLE, and for register variable names predefined in macros like "TIM2" and "GPIO_Pin_9, was underlined red and the eclipse only says 'could not be resolved'.

Q.2
This problem has been identified in both the VM and the native Linux environment(in xubuntu 16.04). These syntax errors were also seen in several header and C files except for LED.h. How can I eliminate these syntax errors?


(and...)This is a question or difficulty that has not been resolved at this time, and I am going to ask about it because I can not confirm the information yet.

Q.3
I also found the c ++ library of 'Whoenig'. Are there any functional or usage differences comparing to the python library? It's more eye-catching because I'm more familiar with c++.


I will finish it with three questons, and I even feel a little sorry cause I seem to have asked too many questions for the first time.
These questions in my article do not need to be answered expeditiously, It's okay to answer slowly.

In the meantime, it was a big hurdle to create a native development environment on a laptop(which made me mad and mentally ill with black screen). Luckily, now that I'am in the front edge of programming stage so that I could have some breath finally. It was hard to solve by myself, but the wiki and forum helped me a lot. Thanks a lot for you.
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Hello to everyone, and some elementary question of crazyflie.

Post by arnaud »

Hi and welcome!

I will try to answer your questions in order. I am trying to stay to the point, there is a lot to say but it would become quite noisy. Feel free to ask more questions and as a general comment it would be useful to know a bit more about what you want to achieve, there is a lot of way to control and program Crazyflie and the best way depends of what you want to do with it.

A.1
There is no overlap when is comes to motor control, the motors are controlled by the firmware.
The firmware contains a state estimator that is able to estimate the Crazyflie orientation and position (if you have a flow deck or other positioning system). It also have a state controller that is at least controlling the rotation rate of the platform orientation. Depending of what setpoint packets you are sending you can control angle rate, absolute angles (this is the normal manual flight mode), velocity, position and there is even a high-level sequence controller added recently by Whoenig that allows the Crazyflie to control trajectories autonomously.

The python lib can send any of these setpoint packets (except high-level trajectories), depending of your application you will chose at what level you want to control the Crazyflie and so where you will put the role separation. If you have a flow deck it is good to control the velocity in X-Y and absolute height in Z since this is the kind of measurement you get from the flow sensor. If you have a positioning system you might prefer controlling the absolute position.

Where to work depends greatly of what you want to do: If you want to fly, you can do that from python only. If you want to interface new sensors or implement new low level control algorithm, you will most likely need to do that in the firmware.

A.2
This sounds like an include problem, did you try to tweak the beeps where they are generated. ie. modifying an existing function call instead of making a new one?

The syntax errors in Eclipse comes from a bad configuration of eclipse CDT, not of problems in the code. It is a bit misleading and it is something I am planning of fixing for the upcoming virtual machine release. The firmware project is kept free of any warning or error, that can be verified by compiling it with make. Until eclipse is fixed you should only look at the error or warning reported by the compiler directly, not the one in the eclipse editor. If you ever happen to tweak and configure eclipse properly I am interested, it would help a lot for making the new VM :-).

A.3
Both lib should do the same. The python lib is developed by mainly Bitcraze and will support any deck we produce in one way or another. The C++ lib might not have high level support for all the deck and setpoints packet, but it is currently the only one to support the high-level commander and it should work better to fly a lot of Crazyflie at the same time (for swarms).

A lot of things in Crazyflie are accessed using the log and param subsystem, since both lib supports that you should be able to use either. What to use depends mostly of your project and then of your programming language preference.
Sexydove
Beginner
Posts: 8
Joined: Wed Apr 25, 2018 10:36 pm

Re: Hello to everyone, and some elementary question of crazyflie.

Post by Sexydove »

Thank you arnoud!
It was a long, uncompleted article, thank you for coming here to answer.
(Since this article goes longer and more difficult to read. In that sense, as I reflect it, I would like to talk briefly)

Re: A.1
For beginners, then, I guess the step to follow is [python lib -> C ++ lib -> firmware], right?
[Thank you for your reply.]

Re: A.2
I knew that it was a problem with Eclipse. I think maybe it's because only the C header file for arm is installed, but I will try to think about this later. I think I need to look at the python library just because of the time lag.
[Thank you for your reply.]

Re: A.3
I am glad as it has been I thought. There are a few problems with cmake, so I'm using python first. If there's a problem......

Q.1
Is there a manual that summarizes the built-in functions and variables used in the Python and C++ libraries?

There is still a bit of a frustration because I am doing only modifying the example code partially. So before opening up the python library(commander.py) for studying of all, I want to see if there exist some sort of documentation available.
[Thank you for your reply.]
arnaud
Bitcraze
Posts: 2538
Joined: Tue Feb 06, 2007 12:36 pm

Re: Hello to everyone, and some elementary question of crazyflie.

Post by arnaud »

For A.1: You need to use the tool that fits your purpose. If you want to implement some kind of autonomous behavior [python -> firmware] makes sense since you can use python for quick prototyping and then implement autonomous behavior in the Crazyflie directly. If having the computer in the loop is not a problem python or other Crazyflie control lib are good to stick with. If you want to work on very low level things like new hardware driver or low level control algorithm you need to work on the firmware right away.

So far the documentation is mostly the code. We have tried to make examples for every functionality of the python lib, and the code is kept modular and as much as possible simple so that it is easy to understand how to use it.
Post Reply