fairlight1337 / libcflie Goto Github PK
View Code? Open in Web Editor NEWCrazyflie Nano C++ Client Library
Home Page: http://fairlight1337.github.io/libcflie.html
Crazyflie Nano C++ Client Library
Home Page: http://fairlight1337.github.io/libcflie.html
Hello:
First very appreciate that you created such an excellent lib and it indeed help me alot. Because I am not recieve my Crazyflies yet, so I cannot test your lib so far. I skim through your code and found you default the type of variable log is double
wthen you get the log message from the Crazyflie.
Line 59 in 4fca065
But I looked back to the firmware of Crazyflies and found the variables in log may have different types.
I am wondering if I want to recieve an another type variable's log (such as LOG_INT8
), your code will work currently or not, and what I should do? After I got my Cf 2.0, I will test as well.
Jason
In your replugging example, you call sleep(0.5) on line 68.
You pass a double literal, but sleep takes an unsigned int.
The implicit conversion taking place from double to unsigned int passed 0 to sleep.
This is probably not the intended behavior.
Hi,
I'm trying to link against the library but I'm having some trouble during compilation with a makefile. I believe the issue is that its not link the libusb-1.0 library since I get the following error:
//usr/local/lib/libcflie.a(CCrazyRadio.cpp.o): In function CCrazyRadio::CCrazyRadio(std::string)': CCrazyRadio.cpp:(.text+0x87): undefined reference to
libusb_init'
My makefile is as followed:
CC = g++
CFLAGS = -Wall -g
all: simple
simple: simple.o
${CC} ${CFLAGS} simple.o -lusb-1.0 -lcflie -o simple
simple.o: simple.cpp CCrazyflie.h
${CC} ${CFLAGS} -c simple.cpp
clean:
rm simple.o simple
To point something out I have moved libcflie.a file to /usr/local/lib. Can someone give a had solving this issue??
I'm currently installing NuttX instead of FreeRTOS on the Crazyflie. Therefore, I fully erased the STM32 and flashed NuttX on it. At the moment I'm writing a communication app. I don't want to use the Crazyflie protocoll since I plan to integrate it with some external system (motion capture). Therefore I plan to just send and receive messages (without the logging stuff).
I managed to change your library, such that it sends the messages I want. However I didn't find out yet on how to look for messages that are sent by the Crazyflie. Do you have some function for that? Or is this just implemented over the logging system?
Thank you for the great work with this library
All your API headers pollute my namespace by
using namespace std;
Please fix this in the API headers at least.
I do not want nor need the std namespace pollution.
Hi,
1st of all great job with the library!
I have been trying to use your library but I can't seem to get the ex-gui example to work properly. When I run ex-gui it connects fine to to the crazyflie and I can see the gui animation move according to the movement of the crazyflie. However, no thrust command are send to crazyflie.
I think its an issue with the new crazyflie firmware that needs to send a thrust = 0 command to unlock the motors. I tried this and it didn't seem to work. Wondering if you have the same issue
Hi,
i followed "How to build the library from source" and everything was fine. No cmake warnings, no build errors. The examples in /bin worked. But in my IDE (CodeBlocks), "undefined reference" errors were thrown. I had to link "/usr/lib/x86_64-linux-gnu/libusb-1.0.so" manually in the IDE to make it work. Maybe something went wrong in cmake.
I hope this may help someone one day :)
Ubuntu 16.04.1
GCC 5.4
cmake 3.5.1
Hello
I am newbie in crazyflie2.
I built your code in windows and it works in mainly.
But I have a trouble with setting thrust from program. I do the next
int main(int argc, char **argv) {
CCrazyRadio crRadio("radio://0/80/250K");
if(crRadio.startRadio())
{
CCrazyflie cflieCopter(&crRadio);
cflieCopter.setThrust(10001);
cflieCopter.setSendSetpoints(true);
for (int i=0;cflieCopter.cycle()&&i<100; ++i)
{
std::cout << cflieCopter.yaw() << " " << cflieCopter.pitch() << " " << cflieCopter.roll() << " " << cflieCopter.thrust() << " " << cflieCopter.batteryLevel()<< std::endl;
std::this_thread::sleep_for(std::chrono::milliseconds(10));
// Range: 10001 - (approx.) 60000
cflieCopter.setThrust(10001+i*20);
}
} else {
std::cerr << "Could not connect to dongle. Did you plug it in?" << std::endl;
}
}
I get
Opening radio 0/80/250K
Got device version 0.83
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
Registered logging block `stabilizer'
Registered logging block `gyroscope'
Registered logging block `accelerometer'
Registered logging block `battery'
Registered logging block `magnetometer'
Registered logging block `altimeter'
0 0 0 0 0
-2.03507 0.462907 0.134263 0 3.73724
-2.03507 0.462907 0.134263 0 3.73724
-2.03507 0.462907 0.134263 0 3.73724
...
-1.9969 0.464878 0.142745 0 3.74252
libusb: warning [winusbx_submit_control_transfer] ControlTransfer failed: [87] The parameter is incorrect.
libusb: warning [winusbx_submit_control_transfer] ControlTransfer failed: [87] The parameter is incorrect.
libusb: warning [winusbx_submit_control_transfer] ControlTransfer failed: [87] The parameter is incorrect.
libusb: warning [winusbx_submit_control_transfer] ControlTransfer failed: [87] The parameter is incorrect.
libusb: warning [winusbx_submit_control_transfer] ControlTransfer failed: [87] The parameter is incorrect.
libusb: warning [winusbx_submit_control_transfer] ControlTransfer failed: [87] The parameter is incorrect.
libusb: warning [winusbx_submit_control_transfer] ControlTransfer failed: [87] The parameter is incorrect.
libusb: warning [winusbx_submit_control_transfer] ControlTransfer failed: [87] The parameter is incorrect.
libusb: warning [winusbx_submit_control_transfer] ControlTransfer failed: [87] The parameter is incorrect.
I am not able to set thrust and engines are not work.
Could you advice me, whatI do incorrectly?
Hi. First of all, thank you for your great work!
I have an issue with timing. CCrazyfile::currentTime() apparently returns the current time in milliseconds.
double CCrazyflie::currentTime() {
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec) * 1000 + (tv.tv_usec) / 1000;
}
In CCrazyflie::cycle(), the current time is compared to a threshold:
// Check if it's time to send the setpoint
if(dTimeNow - m_dSetpointLastSent > m_dSendSetpointPeriod) {...
But the threshold is apparently defined in seconds, so this comparison does make no sense.
m_dSendSetpointPeriod = 0.01; // Seconds
currentTime() should return in seconds, right?
double CCrazyflie::currentTime() {
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec) + (tv.tv_usec) / 1000000.0;
}
Hi,
First, nice work with the library ;).
I think there may be a problem with the yaw setter. I have tested the code and it seems that setting yaw does nothing noticeable (the craziflie does not turn).
Based on the code:
if(m_fYaw < 0) {
m_fYaw += 2 * M_PI - m_fYaw;
}
It seems radians are used instead of degrees. Also m_fMaxYaw is set to 2*M_PI in the constructor. I think, this should use degrees like the other setters (pitch, roll).
According to what I've seen on the bitcraze wiki, yaw is actually yaw_rate (angle/s) so it can also be negative (turn to the left). I think it would be better not to perform this operation m_fYaw += 2 * M_PI - m_fYaw;
and instead use the same principle as for yaw and roll, i.e. :
if(fabs(m_fPitch) > m_fMaxAbsPitch) {
m_fPitch = copysign(m_fMaxAbsPitch, m_fPitch);
}
so my suggestion is:
void CCrazyflie::setYaw(float fYaw) {
m_fYaw = fYaw;
if(fabs(m_fYaw) > m_fMaxYaw){
m_fYaw = copysign(m_fMaxYaw, m_fYaw);
}
where
m_fMaxYaw = 180.0f;
I hope this helps. Thanks again for the great library.
Adrian
Hi there,
while using the library, I wondered that I get the IMU data at only 10 Hz. In contrast, the python library received data at 100 Hz. My inspections give that the m_lstLoggingPackets from CCrazyRadio.cpp filled with new data only at 60 Hz (10 Hz for one sensor e.g. accelerometer).
Is it possible that this deals with the use of synchronous functions of libusb? Or does someone have a solution to accelerate the receive of sensor data?
Thank you very much!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.