-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
New commander packet #113
Comments
|
|
If the first byte of the new command is a mode/type, we could easily add different versions later once required. This is also consistent with the CRTP usage for the logging/parameter subsystem. I think in general it would be nice if the required setpoint packet to send can be as small as possible to increase the possible frequency (flight performance is much smoother at 100 Hz). Hence, I would prefer if it is not a big generic struct with unused values, but rather has a mode and then depending on the exact mode we only send exactly the required data over the radio. |
Yes agreed for the not-too-generic (and by using a type as fist byte of the packet we can always make a "generic" type later if required ;-) So What about doing a packet with:
That way we go forward and just add types when we need them. |
I have some thoughts on this as well, but keep in mind my input is biased more towards bigquad/acro/racing/outdoor type flight, rather than indoor autonomous flight. I like this idea with the type byte. Makes it nice and future proof. I don't know much about the "position hold" system -- does it have any dead-reckoning approximations when flying without the loco positioning system? If so, I think it would make sense to drop "altitude hold" as a standalone mode and roll that into position hold -- it's just a single axis version of position hold. In terms of supported types, I'd like to see at least these in addition to whatever's needed for the position hold system:
Other open questions:
Is anyone working on this yet? I've got a hacked up version of the current commander packet to enable switching between level/rate on the fly, but I'd love to get it implemented in a more official way. I'm happy to start plumbing it unless someone else is already on it. |
This is waiting for a proper implementation of #113. The position setpoint is mapped to: x: Roll y: -1*Pitch z: Thrust/1000 Yaw: Yaw! The mode is activated by the paramter flightmode.posSetMode. A Z setpoint of 0 turns off the motors and since the Z setpoint is mapped on the uint16 thrust the maximal altitude is limited to about 65m.
I have started working on the new commander and for once I started with the documentation and it looks like that:
How does it looks? I will add an X/Y/Z waypoint type/mode and push it so that we can start adding format for all our preferred control modes :-) Since this will require a ROS driver modification I hacked X/Y/Z that we need now for the LPS in the current commander (sorry about that...). @whoenig if we start running an internal controller in the Crazyflie, is there a standard interface for it in ROS (to set position/velocity)? |
This looks good to me. Instead of a "decoder function", I would suggest using a "packed" struct and then just casting the data portion to that struct (similar to how it is done for the logging/parameter subsystem in the firmware). This is very clear as documentation, and can be re-used on the client side as well. I can change the ROS driver once the firmware is ready. I don't have a problem with breaking changes as long as they make sense:-) For your question: In ROS it always depends on the robot. Typically, a Twist message (http://docs.ros.org/api/geometry_msgs/html/msg/Twist.html) is used if you control the velocity (i.e. what you call rate mode) and a Pose message (http://docs.ros.org/api/geometry_msgs/html/msg/Pose.html) is used to set the pose (in case of a quadcopter it would only take the position and yaw into account). Of course, more advanced controllers might need more input data to follow a trajectory - in this case you would need to create a custom message in ROS. |
Casting the data portion to a packed struct doesn't produce a setpoint_t -- I like the array of decoder function idea. That way the code in the commander can be something like But, using a packed struct to define all the types isn't a bad idea, and would be good practice. It just doesn't provide the mapping to setpoint_t. I'd suggest not naming it the 'new commander' -- what would you call the third generation of the commander..the new new commandr? :D How about 'simple' for the current one and 'advanced' or 'complex' or something like that? |
I have continued implementing the file and the functions actually decodes with a structure, I agree this is a good documentation for the packet structure. If we where to just provide a structure we would still need some code to copy the data in setpoint_t so having it in separate function seems cleaner and allow for some per-packet custom logic (like unit conversion). The client side consideration is interesting, are you meaning copy-pasting the structure or re-using the same header file? Though I did hit a problem testing it because the current commander contains a lot of code to multiplex PPM. I will separate the two code (decoding and multiplexing) but I need some tester for it. Now Tobias is back from vacation and you could test as well @theseankelly ;-) For the name what about commander packet V2, so it solves the future names :-). I don't like complex since this commander packet is supposed to be simpler in the end. |
Sure, I can take a look. Is there a branch you're working out of? At the risk of going off topic: Why does the commander have a ping-pong buffer for CommanderCrtpValues? Unless I'm missing something subtle, it doesn't seem to be serving a function since the activeside is updated immediately when a new commander packet is received. Could be extended pretty easily to more of a locking implementation if that's something that's necessary. [Edit: if the answer to this is more complex and involved and unrelated to the commander packet, let me know and I'll start a new issue or forum post on it instead :D] |
I have been lagging on this ticket for a while, sorry about that, though it becomes required to have at least one packet for position control so lets agree on the format and just add it to the current comander.c code. @theseankelly This is not off-topic at all, the current ping-pong buffering is something I have been wanting to change. My idea is to replace it with a 1-value FreeRTOS queue and to use the xQueueSendToFront function to update the value. While I wanted to do everything at once maybe revamping the code is good for another ticket as you are saying. Wrapping it up: we can decide on a packet format in this ticket and maybe clean the actual code in another one. Since this is dealing with interfaces that span multiple projects it is important to decide on something that works well for all of us. What about the format I described earlier with a type byte and a structure of data corresponding to this type? |
Sounds good to me. Would be nice to have so that we can provide a stock example on how to fly with the onboard position controller. |
Sounds good to me too. The paranoia inside of me suggests adding a 'version' value right before 'type' to make it more future proof, but the rational part of me says no, that's a waste of packet space. |
Versions could be determined by switching to a new CRTP port/channel. Also, it would be possible to query the firmware version and adjust the logic based on that. Adding it to each packet might make the logic simpler, but is ultimately a big overhead (technically we should have that for each packet then). |
Yep, agreed. My day job is in a very heavily versioned environment, so any time there's an externally consumed data type without a version, alarms go off. Here, though, it doesn't make sense. |
Curious whether you've got something ready to commit? :D |
Not yet, it is on my todo list. I'll try to push a simple first implementation soon. |
The commander is now accepting setpoint structure with a priority information: the function that pushes a setpoint with the highest priority will set the actual setpoint. Moved current Roll Pitch Yaw Thrust CRTP setpoint to its own file in preparation for the new 'type' CRTP setpoint.
The generic commander packet contains type and data of the setpoint. The type selects a decoder function that is used to decode the data into a setpoint. The two first type implemented are: - Stop: stops the motors, falls if in the air - velocity_world: Sets CF velocity in the world coordinate
This is to make it easier to keep backward compatibility. The new commander generic packet is set to port 7 channel 0, this was previously unused so it can be used by TX-only clients
We have finally made and pushed the new commander packet infrastructure! It is located there: https://github.com/bitcraze/crazyflie-firmware/blob/master/src/modules/src/crtp_commander_generic.c (commander_generic is the least bad name we could come-up with...). We started by implementing a velocity control packet. I bumped the protocol version to 3 but I also put the new generic commander packet in a new port (CRTP port 7, channel 0). This allows for TX-only clients (like the ios client) to send the new packets without risk. There is now a check for the channel so we have 3 more 'version' possible for this packet ;-). There has also been a quite extensive refactor of the commander/setpoint code. There is now a single entry point for setpoints that takes a priority value: https://github.com/bitcraze/crazyflie-firmware/blob/master/src/modules/interface/commander.h#L50. The intent is that any part of the code could push setpoint. The setpoint with the highest priority wins. If the setpoint with high priority is not set for 500ms a setpoint with lower priority will be allowed. This allows to fly with a PPM RC transmitter while being connected to the client (PPM has higher priority). This is also thought to help implementing more autonomous flight in the future (like reading a sequence of setpoint from an SD-Card). Any comments are welcome! This is very new so we can still change it if we find flaws in it. |
Hi, |
Thanks! Glad this is useful, I am then closing this ticket and consider it done. Feel free to open a ticket if the commander/setpoint subsystem need more work. |
Currently the commander packet format assumes a "normal" angle-based control mode and every other modes like altitude hold, position hold, rate mode, are handled using parameter and by fitting the relevant values in the current commander fields.
The plan is to make a new commander packet that encodes both the flight modes and the relevant setpoints values. This would make handling thing like altitude-hold and rate mode easier and it is required to start implementing position control in the Crazyflie.
We need to handle at least:
The text was updated successfully, but these errors were encountered: