payload_deliverer & gripper: Improve intermediate state & vcmd_ack

Gripper:
- Don't command gripper (via uORB `gripper` topic, which maps into an
actuator via Control Allocation) if we are already at the state we want
(e.g. Grabbed / Released) or in the intermediate state to the state we
want -> This prevents spamming on `gripper` topic

Payload Deliverer:
- Add read-once function for Gripper's released / grabbed state
- Send vehicle_command_ack for both release/grab actions.

TODO: target_system & target_component for the released/grabbed vcmd_ack
is incomplete, since we are not keeping track of the vehicle_command
that corresponds to this. This needs to be dealt with in the future, not
sure what the best solution it is for now.

Possible solutions:
- Queue-ing the vehicle command?
- Tying the gripper's action to specific vehicle command one-on-one, to make sure if we send multiple vehicle commands, we know
which command resulted in the action exactly?)

Only command Gripper grab when we are actually initializing gripper

- Previously, on every parameter update, gripper grab was being
commanded
- This commit narrows that scope to only when we are actually
initializing the gripper

Handle gripper de-initialization upon parameter change

- Also added some local state initialization code to init() function of
Gripper
- This will now make init / de-init more graceful & controlled compared
to before
This commit is contained in:
Junwoo Hwang
2022-10-27 07:51:17 +02:00
committed by Beat Küng
parent 36a3c716d6
commit 6529e39f8b
4 changed files with 107 additions and 30 deletions
@@ -100,9 +100,12 @@ private:
void parameter_update();
/**
* @brief Initialize gripper with current parameter settings
* @brief Initialize or deinitialize gripper instance based on parameter settings
*
* Depending on `PD_GRIPPER_EN` and the state of `_gripper` instance, this function will
* either try to initialize or de-initialize the gripper appropriately.
*/
bool initialize_gripper();
void configure_gripper();
/**
* @brief Update gipper instance's state and send vehicle command ack