sendSetpointMulti.cpp
Go to the documentation of this file.
00001 #include <thread>
00002 #include <iostream>
00003 
00004 #include <crazyflie_cpp/Crazyflie.h>
00005 
00006 int main()
00007 {
00008 
00009 
00010   // launch two threads and set new setpoint at 100 Hz
00011   std::thread t1([] {
00012     Crazyflie cf1("radio://0/100/2M/E7E7E7E701"); // Instantiate first Crazyflie object
00013       // Send 0 a few times to make sure thrust lock is disabled
00014     for (size_t i = 0; i < 100; ++i) {
00015       cf1.sendSetpoint(0, 0, 0, 0);
00016     }
00017     while (true) {
00018       // Crazyflie cf1("radio://0/80/2M/E7E7E7E7E1");
00019       cf1.sendSetpoint(0, 0, 0, 10000); // send roll, pitch, yaw, and thrust
00020       std::this_thread::sleep_for(std::chrono::milliseconds(10));
00021     }
00022   });
00023 
00024   // launch two threads and set new setpoint at 100 Hz
00025   std::thread t2([] {
00026     Crazyflie cf2("radio://0/100/2M/E7E7E7E702"); // Instantiate second Crazyflie object
00027       // Send 0 a few times to make sure thrust lock is disabled
00028     for (size_t i = 0; i < 100; ++i) {
00029       cf2.sendSetpoint(0, 0, 0, 0);
00030     }
00031     while (true) {
00032       // Crazyflie cf1("radio://0/80/2M/E7E7E7E7E1");
00033       cf2.sendSetpoint(0, 0, 0, 20000); // send roll, pitch, yaw, and thrust
00034       std::this_thread::sleep_for(std::chrono::milliseconds(10));
00035     }
00036   });
00037 
00038   t1.join();
00039   t2.join();
00040 
00041   return 0;
00042 }


crazyflie_cpp
Author(s): Wolfgang Hoenig
autogenerated on Sun Oct 8 2017 02:47:59