Hey,
I am trying to implement a controller for the rate of ascend/descend, in which the ascend/descend speed is the setpoint given by the PS4-Controller. Therefore I need to read the raw "thrust" value from the gamepad, but with negative values as well. So that the midpoint is zero.
At which point of the firmware I can access these values? I already logged different values from the files "crtp_commander_generic.c" and "crtp_commander_rpyt.c" (e.g. values->channelThrust, rawThrust, values->thrust), but didn't get any value which could be negative. For me, it doesn't matter which assist-mode is chosen, because I am using my own attitude controller either way.
I also want to implement an autonomous flight maneuver which starts if a certain button is pressed on the gamepad. For this, I additionally need to read the state of another aux button. Does anybody know how to do that?
I would be very glad if someone could provide further information. Thank you very much!
Accessing raw thrust channel values in firmware (PS4 controller)
Re: Accessing raw thrust channel values in firmware (PS4 controller)
When setting the assist mode to "position hold", a velocity setpoint is sent: https://github.com/bitcraze/crazyflie-c ... in.py#L255. This setpoint is received there in the Crazyflie: https://github.com/bitcraze/crazyflie-f ... eric.c#L98 and so you will be able to get a velocity setpoint both positive and negative in setpoint->velocity.z.
As for button press, you will need to dig a little bit into the client code. For a start, in the client, the button are read there: https://github.com/bitcraze/crazyflie-c ... __.py#L285.
As for button press, you will need to dig a little bit into the client code. For a start, in the client, the button are read there: https://github.com/bitcraze/crazyflie-c ... __.py#L285.
Re: Accessing raw thrust channel values in firmware (PS4 controller)
Thank you for helping, Arnaud! I have not pressed the "assisted control"-button first, so that the "position hold" was not activated. But now it works and I can read the values.
But for the second issue: Can you tell me, at which point in the crayzflie firmware the "pressed-buttons-signals" are read? For example the "killswitch" and "Exit app"? Then I maybe can read these signals and just use them for my functions. As I don't know python language, I cannot really dig into the client code.
But for the second issue: Can you tell me, at which point in the crayzflie firmware the "pressed-buttons-signals" are read? For example the "killswitch" and "Exit app"? Then I maybe can read these signals and just use them for my functions. As I don't know python language, I cannot really dig into the client code.
Re: Accessing raw thrust channel values in firmware (PS4 controller)
The buttons values are not sent to the Crazyflie. I do not think these button in particular sends messages to the Crazyflie (the Crazyflie has a "stop" message that could be used for kill-switch but I think the current client implementation will "just" stop sending packets when this button is pressed and not send the stop message.
Unfortunately if you want to add functionalities accessible with the gamepad you cannot do that from the Firmware, the firmware knows nothing about gamepads. I see a couple of option I can think abou:
- Modifying the client in Python
- Make your own client, you can for example use existing library to connect the Crazyflie like the crazyflie_cpp lib made for the ROS crazyflie driver. You will have to write everything else though.
- Use ROS, ROS has a Crazyflie driver to connect Crazyflie and a Gamepad driver that publishes gamepad state as a ROS topic. ROS nodes can be written in C++ or python and are usually much simpler than a full-fledged client.
Unfortunately if you want to add functionalities accessible with the gamepad you cannot do that from the Firmware, the firmware knows nothing about gamepads. I see a couple of option I can think abou:
- Modifying the client in Python
- Make your own client, you can for example use existing library to connect the Crazyflie like the crazyflie_cpp lib made for the ROS crazyflie driver. You will have to write everything else though.
- Use ROS, ROS has a Crazyflie driver to connect Crazyflie and a Gamepad driver that publishes gamepad state as a ROS topic. ROS nodes can be written in C++ or python and are usually much simpler than a full-fledged client.