![]() ![]() Retrieve robot position using the sensors.Ĭonst double roll = wb_inertial_unit_get_roll_pitch_yaw(imu) + M_PI / 2.0 Ĭonst double pitch = wb_inertial_unit_get_roll_pitch_yaw(imu) Ĭonst double yaw= *wb_compass_get_values(compass) const double k_vertical_p = 3.0 // P constant of the vertical PID.Ĭonst double k_roll_p = 50.0 // P constant of the roll PID.Ĭonst double k_pitch_p = 30.0 // P constant of the pitch PID.ĭouble target_altitude = 1 //also target yĬonst double time = wb_robot_get_time() // in seconds. WbDeviceTag motors = Ĭonst double k_vertical_thrust = 68.5 // with this thrust, the drone lifts.Ĭonst double k_vertical_offset = 0.6 // Vertical offset where the robot actually targets to stabilize itself. WbDeviceTag rear_right_motor = wb_robot_get_device("rear right propeller") WbDeviceTag rear_left_motor = wb_robot_get_device("rear left propeller") WbDeviceTag front_right_motor = wb_robot_get_device("front right propeller") WbDeviceTag front_left_motor = wb_robot_get_device("front left propeller") Get propeller motors and set them to velocity mode. WbDeviceTag camera_pitch_motor = wb_robot_get_device("camera pitch") ![]() WbDeviceTag camera_roll_motor = wb_robot_get_device("camera roll") WbDeviceTag camera = wb_robot_get_device("camera") WbDeviceTag gyro = wb_robot_get_device("gyro") WbDeviceTag compass = wb_robot_get_device("compass") ![]() WbDeviceTag gps = wb_robot_get_device("gps") WbDeviceTag imu = wb_robot_get_device("inertial unit") Int timestep = (int)wb_robot_get_basic_time_step() So is it because the idea to code my drone to stay at a fixed altitude went wrong at some point? This is my code so far: #include I have tried to solve it by adjusting the P, D constants in my PD controllers but the drone all performed worse. Up to now, my drone was able to take off pretty well to the desired height but when it reached the desired height it started to lose balance and fall. For now, I just want my drone to be able to stay in a fixed position after take-off. I'm trying to use Webots software with C programming to simulate a quadcopter. ![]()
0 Comments
Leave a Reply. |