Can I stop the sensor when I use it for ten second in flow deck?
-
- Beginner
- Posts: 19
- Joined: Tue Jul 14, 2020 1:37 pm
Can I stop the sensor when I use it for ten second in flow deck?
recently I use the flow deck v2 in my research and I know has two sensor in the this expantion deck
PWM3901(for x and y) and VL53L0x ToF sensor (for z)
first I want use the both of them to hover for 10 second
second after first step I want to stop the sensor of ToF sensor just want know the information of x and y No matter where crazyflie flies, the height of z will never change。
I use the python script "motion_commander.py" that mention the word of distance same like all functions are based on distance (ToF data).
So can I do what I want in the python script?
Thank all of one who helps me.
Best wishes
PWM3901(for x and y) and VL53L0x ToF sensor (for z)
first I want use the both of them to hover for 10 second
second after first step I want to stop the sensor of ToF sensor just want know the information of x and y No matter where crazyflie flies, the height of z will never change。
I use the python script "motion_commander.py" that mention the word of distance same like all functions are based on distance (ToF data).
So can I do what I want in the python script?
Thank all of one who helps me.
Best wishes
Re: Can I stop the sensor when I use it for ten second in flow deck?
Hi,
There is no functionality that allows to disable the ToF sensor in flight, but it can be added quite easily. The followind change in the firmware adds a parameter "tof.enable", if this parameter is set to 0, the ToF sensor is not going to be pushed anymore to the estimator:
Be aware that the Z estimate is used by the flow to compensate for attitude change so to work properly the flow needs an accurate estimate of the height above the floor. If you disable the ToF sensor, you need to provide to the estimator an other accurate elevation measurement.
There is no functionality that allows to disable the ToF sensor in flight, but it can be added quite easily. The followind change in the firmware adds a parameter "tof.enable", if this parameter is set to 0, the ToF sensor is not going to be pushed anymore to the estimator:
Code: Select all
diff --git a/src/deck/drivers/src/zranger2.c b/src/deck/drivers/src/zranger2.c
index d7c3b6c..958fe93 100644
--- a/src/deck/drivers/src/zranger2.c
+++ b/src/deck/drivers/src/zranger2.c
@@ -113,6 +113,8 @@ bool zRanger2Test(void)
return true;
}
+static bool tofEnabled = true;
+
void zRanger2Task(void* arg)
{
TickType_t lastWakeTime;
@@ -137,7 +139,7 @@ void zRanger2Task(void* arg)
// check if range is feasible and push into the estimator
// the sensor should not be able to measure >5 [m], and outliers typically
// occur as >8 [m] measurements
- if (range_last < RANGE_OUTLIER_LIMIT) {
+ if (tofEnabled && range_last < RANGE_OUTLIER_LIMIT) {
float distance = (float)range_last * 0.001f; // Scale from [mm] to [m]
float stdDev = expStdA * (1.0f + expf( expCoeff * (distance - expPointA)));
rangeEnqueueDownRangeInEstimator(distance, stdDev, xTaskGetTickCount());
@@ -160,3 +162,7 @@ DECK_DRIVER(zranger2_deck);
PARAM_GROUP_START(deck)
PARAM_ADD(PARAM_UINT8 | PARAM_RONLY, bcZRanger2, &isInit)
PARAM_GROUP_STOP(deck)
+
+PARAM_GROUP_START(tof)
+PARAM_ADD(PARAM_UINT8, enable, &tofEnabled)
+PARAM_GROUP_STOP(tof)
-
- Beginner
- Posts: 19
- Joined: Tue Jul 14, 2020 1:37 pm
Re: Can I stop the sensor when I use it for ten second in flow deck?
Thanks for the answerarnaud wrote: ↑Mon Sep 21, 2020 11:33 am Hi,
There is no functionality that allows to disable the ToF sensor in flight, but it can be added quite easily. The followind change in the firmware adds a parameter "tof.enable", if this parameter is set to 0, the ToF sensor is not going to be pushed anymore to the estimator:
Be aware that the Z estimate is used by the flow to compensate for attitude change so to work properly the flow needs an accurate estimate of the height above the floor. If you disable the ToF sensor, you need to provide to the estimator an other accurate elevation measurement.Code: Select all
diff --git a/src/deck/drivers/src/zranger2.c b/src/deck/drivers/src/zranger2.c index d7c3b6c..958fe93 100644 --- a/src/deck/drivers/src/zranger2.c +++ b/src/deck/drivers/src/zranger2.c @@ -113,6 +113,8 @@ bool zRanger2Test(void) return true; } +static bool tofEnabled = true; + void zRanger2Task(void* arg) { TickType_t lastWakeTime; @@ -137,7 +139,7 @@ void zRanger2Task(void* arg) // check if range is feasible and push into the estimator // the sensor should not be able to measure >5 [m], and outliers typically // occur as >8 [m] measurements - if (range_last < RANGE_OUTLIER_LIMIT) { + if (tofEnabled && range_last < RANGE_OUTLIER_LIMIT) { float distance = (float)range_last * 0.001f; // Scale from [mm] to [m] float stdDev = expStdA * (1.0f + expf( expCoeff * (distance - expPointA))); rangeEnqueueDownRangeInEstimator(distance, stdDev, xTaskGetTickCount()); @@ -160,3 +162,7 @@ DECK_DRIVER(zranger2_deck); PARAM_GROUP_START(deck) PARAM_ADD(PARAM_UINT8 | PARAM_RONLY, bcZRanger2, &isInit) PARAM_GROUP_STOP(deck) + +PARAM_GROUP_START(tof) +PARAM_ADD(PARAM_UINT8, enable, &tofEnabled) +PARAM_GROUP_STOP(tof)
I also want to know the flow deck has two sensors right?
tof and the PWM
but I just notice the tof sensor worked for the data capture like "distance" in the "motion_commander.py".
I want to know where the flie or the code for the PMW3901 optical flow sensor. Can you help me ?
Thank you very much
-
- Beginner
- Posts: 19
- Joined: Tue Jul 14, 2020 1:37 pm
Re: Can I stop the sensor when I use it for ten second in flow deck?
And can you teach me how to add the functionality that allows to disable the ToF sensor in flight in python script?arnaud wrote: ↑Mon Sep 21, 2020 11:33 am Hi,
There is no functionality that allows to disable the ToF sensor in flight, but it can be added quite easily. The followind change in the firmware adds a parameter "tof.enable", if this parameter is set to 0, the ToF sensor is not going to be pushed anymore to the estimator:
Be aware that the Z estimate is used by the flow to compensate for attitude change so to work properly the flow needs an accurate estimate of the height above the floor. If you disable the ToF sensor, you need to provide to the estimator an other accurate elevation measurement.Code: Select all
diff --git a/src/deck/drivers/src/zranger2.c b/src/deck/drivers/src/zranger2.c index d7c3b6c..958fe93 100644 --- a/src/deck/drivers/src/zranger2.c +++ b/src/deck/drivers/src/zranger2.c @@ -113,6 +113,8 @@ bool zRanger2Test(void) return true; } +static bool tofEnabled = true; + void zRanger2Task(void* arg) { TickType_t lastWakeTime; @@ -137,7 +139,7 @@ void zRanger2Task(void* arg) // check if range is feasible and push into the estimator // the sensor should not be able to measure >5 [m], and outliers typically // occur as >8 [m] measurements - if (range_last < RANGE_OUTLIER_LIMIT) { + if (tofEnabled && range_last < RANGE_OUTLIER_LIMIT) { float distance = (float)range_last * 0.001f; // Scale from [mm] to [m] float stdDev = expStdA * (1.0f + expf( expCoeff * (distance - expPointA))); rangeEnqueueDownRangeInEstimator(distance, stdDev, xTaskGetTickCount()); @@ -160,3 +162,7 @@ DECK_DRIVER(zranger2_deck); PARAM_GROUP_START(deck) PARAM_ADD(PARAM_UINT8 | PARAM_RONLY, bcZRanger2, &isInit) PARAM_GROUP_STOP(deck) + +PARAM_GROUP_START(tof) +PARAM_ADD(PARAM_UINT8, enable, &tofEnabled) +PARAM_GROUP_STOP(tof)
I am not good at python very much....
thank you very much again
Re: Can I stop the sensor when I use it for ten second in flow deck?
Hi,
The flow deck does indeed contain the optical flow sensor and one ToF ranging sensor.
The motion_commander does control the XYZ position of the drone, it has no notion of what sensor are installed on the drone. The drone estimates and control its position,velocity using some means (IMU plus the flow deck is one, mocap, LPS or lighthouse would be other), then a program, for example the motion_commander.py functions, can send position or velocity setpoint.
The PMW3901 is completely handled in firmware, the driver is a deck driver: https://github.com/bitcraze/crazyflie-f ... eck_v1v2.c and the velocity estimation from flow is part of the kalman filter (note the use of the Z estimate): https://github.com/bitcraze/crazyflie-f ... #L470-L535
The flow deck does indeed contain the optical flow sensor and one ToF ranging sensor.
The motion_commander does control the XYZ position of the drone, it has no notion of what sensor are installed on the drone. The drone estimates and control its position,velocity using some means (IMU plus the flow deck is one, mocap, LPS or lighthouse would be other), then a program, for example the motion_commander.py functions, can send position or velocity setpoint.
The PMW3901 is completely handled in firmware, the driver is a deck driver: https://github.com/bitcraze/crazyflie-f ... eck_v1v2.c and the velocity estimation from flow is part of the kalman filter (note the use of the Z estimate): https://github.com/bitcraze/crazyflie-f ... #L470-L535
-
- Beginner
- Posts: 19
- Joined: Tue Jul 14, 2020 1:37 pm
Re: Can I stop the sensor when I use it for ten second in flow deck?
oh Thank you I know the set up of PWM is in the firmware,and almost do not need to modify it for the hoverarnaud wrote: ↑Mon Sep 21, 2020 12:18 pm Hi,
The flow deck does indeed contain the optical flow sensor and one ToF ranging sensor.
The motion_commander does control the XYZ position of the drone, it has no notion of what sensor are installed on the drone. The drone estimates and control its position,velocity using some means (IMU plus the flow deck is one, mocap, LPS or lighthouse would be other), then a program, for example the motion_commander.py functions, can send position or velocity setpoint.
The PMW3901 is completely handled in firmware, the driver is a deck driver: https://github.com/bitcraze/crazyflie-f ... eck_v1v2.c and the velocity estimation from flow is part of the kalman filter (note the use of the Z estimate): https://github.com/bitcraze/crazyflie-f ... #L470-L535
So I just want to stop the tof sensor during flight in python scrip. Can you help me how to do with that in crazyflie-lib-python?
very very thanks
Re: Can I stop the sensor when I use it for ten second in flow deck?
The modification to the firmware I sent you in my fist message does allow to disable the ToF sensor from python: you can set parameters from python and the change exposes a parameter to disable the ToF sensor. If you wonder how to set a parameter from python I suggest you follow this tutorial, it contains a section about setting parameters: https://www.bitcraze.io/documentation/r ... log_param/
To modify the Crazyflie fimware with the diff I sent you , you can copy-paste the full diff in "git apply", compile and upload the firmware with make cload.
When the ToF sensor is disabled, if you do not have any other sensor available for the height, the Crazyflie will lose height control (in my case, when I tested, it went down, it could also go up).
To modify the Crazyflie fimware with the diff I sent you , you can copy-paste the full diff in "git apply", compile and upload the firmware with make cload.
When the ToF sensor is disabled, if you do not have any other sensor available for the height, the Crazyflie will lose height control (in my case, when I tested, it went down, it could also go up).
-
- Beginner
- Posts: 19
- Joined: Tue Jul 14, 2020 1:37 pm
Re: Can I stop the sensor when I use it for ten second in flow deck?
thank you very much for the anwserarnaud wrote: ↑Mon Sep 21, 2020 12:48 pm The modification to the firmware I sent you in my fist message does allow to disable the ToF sensor from python: you can set parameters from python and the change exposes a parameter to disable the ToF sensor. If you wonder how to set a parameter from python I suggest you follow this tutorial, it contains a section about setting parameters: https://www.bitcraze.io/documentation/r ... log_param/
To modify the Crazyflie fimware with the diff I sent you , you can copy-paste the full diff in "git apply", compile and upload the firmware with make cload.
When the ToF sensor is disabled, if you do not have any other sensor available for the height, the Crazyflie will lose height control (in my case, when I tested, it went down, it could also go up).
I already done what I want. The result was when I shut down the tof during flight The crazyflie was fall directly.
So what I want is after the sensor is turned off, the original altitude can be maintained, which means that the previous distance data is saved to provide the power required to maintain the flight. Is that possible?
thank you very much
Re: Can I stop the sensor when I use it for ten second in flow deck?
Without sensor measurement the drone is not capable to maintain its height at all.
If you want to still maintain a constant altitude and you do not have extra height sensor, disabling the ToF sensor is not solving your problem since it disables height control.
I think the best is that you tell us what high-level goal you are trying to achieve and we can guide you with what technical solution is actually needed to reach this goal.
If you want to still maintain a constant altitude and you do not have extra height sensor, disabling the ToF sensor is not solving your problem since it disables height control.
I think the best is that you tell us what high-level goal you are trying to achieve and we can guide you with what technical solution is actually needed to reach this goal.
-
- Beginner
- Posts: 19
- Joined: Tue Jul 14, 2020 1:37 pm
Re: Can I stop the sensor when I use it for ten second in flow deck?
Thank you for answerarnaud wrote: ↑Mon Sep 28, 2020 6:00 am Without sensor measurement the drone is not capable to maintain its height at all.
If you want to still maintain a constant altitude and you do not have extra height sensor, disabling the ToF sensor is not solving your problem since it disables height control.
I think the best is that you tell us what high-level goal you are trying to achieve and we can guide you with what technical solution is actually needed to reach this goal.
If I have not extra sensor I can not maintain hover and I just want to try use the flow deck v2 fix the x and y positions when the cf take off in the specifically height I shut down the tot just use the pwm sensor the maintain the position x and y
I thought the way about disable the tof when it hover
First is that modify the code in firmware “zanger2.c” to save the data of height information before.
second I want to set reference point (0.0)from the ground to the position where cf reached.
Can you give me some suggestions for the goal what I want?
Thank you very very much!!!