Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webots new system id values #65

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/functional_areas/controllers.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ As of this [Pull request in the Crazyflie firmware repo](https://github.com/bitc

Change the controller in the crazyflie robot model in webots to crazyflie_controller_py_firmware_pid, and adjust the following line to point to your crazyflie-firmware repo:

sys.path.append('../../../../../C/crazyflie-firmware')
sys.path.append('../../../../../C/crazyflie-firmware/build')

Press play with the simulator and use your keyboard to control it.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,15 +99,15 @@ int main(int argc, char **argv) {

// Initialize PID gains.
gains_pid_t gains_pid;
gains_pid.kp_att_y = 1;
gains_pid.kd_att_y = 0.5;
gains_pid.kp_att_rp = 0.5;
gains_pid.kd_att_rp = 0.1;
gains_pid.kp_vel_xy = 2;
gains_pid.kd_vel_xy = 0.5;
gains_pid.kp_z = 10;
gains_pid.ki_z = 5;
gains_pid.kd_z = 5;
gains_pid.kp_att_y = 200;
gains_pid.kd_att_y = 20;
gains_pid.kp_att_rp = 100;
gains_pid.kd_att_rp = 20;
gains_pid.kp_vel_xy = 0.1;
gains_pid.kd_vel_xy = 0.01;
gains_pid.kp_z = 1000;
gains_pid.ki_z = 500;
gains_pid.kd_z = 500;
init_pid_attitude_fixed_height_controller();

double height_desired = FLYING_ALTITUDE;
Expand Down Expand Up @@ -204,6 +204,8 @@ int main(int argc, char **argv) {
desired_state.altitude = height_desired;
pid_velocity_fixed_height_controller(actual_state, &desired_state, gains_pid, dt, &motor_power);


printf("motor_power: %f %f %f %f\n", motor_power.m1, motor_power.m2, motor_power.m3, motor_power.m4);
// Setting motorspeed
wb_motor_set_velocity(m1_motor, -motor_power.m1);
wb_motor_set_velocity(m2_motor, motor_power.m2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

import sys
# Change this path to your crazyflie-firmware folder
sys.path.append('../../../../../c/crazyflie-firmware')
sys.path.append('../crazyflie-firmware/build/')
import cffirmware

robot = Robot()
Expand Down Expand Up @@ -175,7 +175,9 @@
motorPower_m3 = cmd_thrust + cmd_roll - cmd_pitch + cmd_yaw
motorPower_m4 = cmd_thrust + cmd_roll + cmd_pitch - cmd_yaw

scaling = 1000 ##Todo, remove necessity of this scaling (SI units in firmware)
print('Motor Powers: ', motorPower_m1, motorPower_m2, motorPower_m3, motorPower_m4)

scaling = 20 ##Todo, remove necessity of this scaling (SI units in firmware)
m1_motor.setVelocity(-motorPower_m1/scaling)
m2_motor.setVelocity(motorPower_m2/scaling)
m3_motor.setVelocity(-motorPower_m3/scaling)
Expand Down
32 changes: 16 additions & 16 deletions simulator_files/webots/protos/Crazyflie.proto
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ PROTO Crazyflie [
DEF M1 Propeller {
shaftAxis 0 0 1
centerOfThrust 0.031 -0.031 0.008
thrustConstants -4e-05 0
torqueConstants 2.4e-06 0
thrustConstants -1.3e-08 1e-06
torqueConstants 7.6e-11 1e-07
fastHelixThreshold 50
device RotationalMotor {
name "m1_motor"
maxVelocity 600
maxTorque 30
maxVelocity 5000
maxTorque 10000
}
fastHelix Solid {
translation 0.031 -0.031 0.008
Expand Down Expand Up @@ -144,13 +144,13 @@ PROTO Crazyflie [
DEF M2 Propeller {
shaftAxis 0 0 1
centerOfThrust -0.031 -0.031 0.008
thrustConstants 4e-05 0
torqueConstants 2.4e-06 0
thrustConstants 1.3e-08 1e-06
torqueConstants 7.6e-11 1e-07
fastHelixThreshold 50
device RotationalMotor {
name "m2_motor"
maxVelocity 600
maxTorque 30
maxVelocity 5000
maxTorque 10000
}
fastHelix Solid {
translation -0.031 -0.031 0.008
Expand All @@ -168,13 +168,13 @@ PROTO Crazyflie [
DEF M3 Propeller {
shaftAxis 0 0 1
centerOfThrust -0.031 0.031 0.008
thrustConstants -4e-05 0
torqueConstants 2.4e-06 0
thrustConstants -1.3e-08 1e-06
torqueConstants 7.6e-11 1e-07
fastHelixThreshold 50
device RotationalMotor {
name "m3_motor"
maxVelocity 600
maxTorque 30
maxVelocity 5000
maxTorque 10000
}
fastHelix Solid {
translation -0.031 0.031 0.008
Expand All @@ -192,13 +192,13 @@ PROTO Crazyflie [
DEF M4 Propeller {
shaftAxis 0 0 1
centerOfThrust 0.031 0.031 0.008
thrustConstants 4e-05 0
torqueConstants 2.4e-06 0
thrustConstants 1.3e-08 1e-06
torqueConstants 7.6e-11 1e-07
fastHelixThreshold 50
device RotationalMotor {
name "m4_motor"
maxVelocity 600
maxTorque 30
maxVelocity 5000
maxTorque 10000
}
fastHelix Solid {
translation 0.031 0.031 0.008
Expand Down