We try to use the breakout board to pin a ultrasonic sensor (HC-SR04). In order to generate the ultrasound we need to set the Trig on a High State for 10 µs. We know how to do that on a Arduino board but not on the Crazyflie. We saw a similar topic about sending "HIGH" or "LOW" through the IO : viewtopic.php?f=5&t=1364&p=7333
However, we can't access the code :https://github.com/bitcraze/crazyflie-f ... /exptest.c in today's firmware. So can you tell us how to send a "HIGH" or "LOW" with a certain frequency with the IO pins?
The exptest.c deck driver is used in factory to test Crazyflie, it is not such a good example since it initializes GPIOs without using the Arduino-like API.
A side point: you will have to create a task to run your code while the firmware is running. Pulsing the pin should be similar as with Arduino but measuring the time it takes for the echo will have to be a bit different: there is no ready-made pulsein() function in Crazyfie and you cannot make a while loop to measure the echo pin since you will use 100% of the CPU while doing that and trigger the watchdog (you can try by adding a sleep in the loop though but then you will have a measurement granularity of 1ms). You most likely will need to use one of the STM32 timer to measure the pulse. The closest example I can think about is this implementation that measures pulse start and pulse width: https://github.com/bitcraze/crazyflie-f ... #L258-L270.
We have written a code and we want to see if it works. However when we want to compile the code (through the command "Make CLOAD"), the console send us this message:
make all DEBUG=0 CLOAD=1
CLEAN_VERSION
VTMPL version.c
CC version.o
LD cf2.elf
bin/locodeck.o:(.data.algorithmsList+0x10): undefined reference to `uwbTdoaTagAlgorithm'
collect2: error: ld returned 1 exit status
make: *** [cf2.elf] Error 1
We didn't touched the locodeck code, so we don't understand why it doesn't work...
Can you help us? Thank you
We try to set a step by affecting a value to a variable during a period of time so it goes back to 0 as soon as it reaches the reload value. To achieve that, we used the microprocessor as a clock and we set the counter to have 1Hz. We used the variable range_last to print the graph in the client. However, the problem is that range_last stays at 5 and never changes. Can you take a look at the code and tell us the reasons why it's not working?
I am not completly sure of what you are trying to achieve. Who is calling the ultrasonReadRange function and at what rate?
For sure though you are not using the right timer. Searching in the code shows that timer2 is used for the motor PWM: https://github.com/bitcraze/crazyflie-f ... _cf2.c#L28. There is unfortunatly no documentation so find out what times is used where, so the only way is to do a search in the code (works well directly in github).
Hi,
for now, we are only trying to define the pulse that will be sent to the ultrasonic sensor.
The ultrasonReadRange function is called by sensors_cf2.c in the sensorsAcquire function.
Actually we have other questions:
1. Once we will have managed to make this work we would like to change the height kept by the drone when height mode is on. Could you tell us where to do that in the code please ?
2. The goal of our work is to make the drone land automatically. In order to transition from manual to automatic mode, we are wondering whether we should use the same system as the z-ranger in the cf client or directly implement a command in the firmware. What would you advise us ?
Is the length of the generated pulse important? Intuitively I would have generated the pulse with a simple delay (ie. "vTaskDelay(M2T(time_in_ms))" ) and used the timer only to measure the width of the received pulse. Doing it that way should make the code much simpler.
1. Once you push the current height into the estimator the same way the zranger deck is doing it, you will be able to send setpoints with absolute height. This can be done either from the firmware or from the ground.
2. I would advise sending the setpoint from the python client. There is not ready mechanism (yet) to handle this kind of high-level commands in the Crazyflie yet and since the client already have the required funtionality for sending the height-hold setpoint you will need and you will have to modify the client anyway, I would do the landing sequencing in the client.