584 task gripper controller merge into main we want juicy gripper inside of main#10
584 task gripper controller merge into main we want juicy gripper inside of main#10
Conversation
…lder as well as removed the previously added dependencies as consequence of making the controller module within the interface
… originally in the gripper_interface/
…n vortex_auv repo: vortex-auv/guidance/reference_filter_dp -Rather than following the recipe to construct the model after p. 337 EQ 12.11 and 12.12 in Thor I. Fossens book, dimensions and names have been changed to match the p.336 EQ 12.5 and 12.6. -Notice several TODO's for future work and consultation with Cyp & Jøg
…with entire system, needs actual servo states to simulate proper topic relationships
…4-task-gripper-controller
…im interface with functioning goal sends to ref filter playing out in sim environment
jorgenfj
left a comment
There was a problem hiding this comment.
The dp reference filter has been rewritten to have a separate cpp class to handle the action state execution. Up to you whether you want to implement that here as well, both options are fine.
Also should look over the files changed and just slap const qualifiers on variables where it is suited.
| types::GripperState measured_state; | ||
| types::GripperState reference_state; | ||
|
|
||
| { | ||
| std::lock_guard<std::mutex> lock(state_mutex_); | ||
| measured_state.roll = roll_measured_; | ||
| measured_state.pinch = pinch_measured_; | ||
| reference_state.roll = roll_ref_; | ||
| reference_state.pinch = pinch_ref_; | ||
| } |
There was a problem hiding this comment.
These local state variables should preferably be a const.
Should look into this for complex const initialization using lambdas
| reference_sub_ = this->create_subscription<vortex_msgs::msg::GripperState>( | ||
| gripper_state_topic, qos_sensor_data, | ||
| std::bind(&GripperReferenceFilterNode::reference_callback, this, | ||
| std::placeholders::_1)); |
There was a problem hiding this comment.
Consider using lambdas instead of std::bind to avoid using std::placeholders
| action_server_ = rclcpp_action::create_server< | ||
| vortex_msgs::action::GripperReferenceFilterWaypoint>( | ||
|
|
||
| this, | ||
|
|
||
| action_server_name, | ||
|
|
||
| std::bind(&GripperReferenceFilterNode::handle_goal, this, | ||
| std::placeholders::_1, std::placeholders::_2), | ||
|
|
||
| std::bind(&GripperReferenceFilterNode::handle_cancel, this, | ||
| std::placeholders::_1), | ||
|
|
||
| std::bind(&GripperReferenceFilterNode::handle_accepted, this, | ||
| std::placeholders::_1), | ||
|
|
||
| rcl_action_server_get_default_options(), cb_group_); |
There was a problem hiding this comment.
What is this line spacing? I need a vertical monitor to read this...
| rclcpp_action::GoalResponse GripperReferenceFilterNode::handle_goal( | ||
| const rclcpp_action::GoalUUID& uuid, | ||
| std::shared_ptr<const vortex_msgs::action::GripperReferenceFilterWaypoint::Goal> | ||
| goal) { | ||
| (void)uuid; | ||
| (void)goal; |
There was a problem hiding this comment.
For unused function args a more explicit approach is to comment out the args themselvs instead of using (void).
const rclcpp_action::GoalUUID& /*uuid*/,
std::shared_ptr<const vortex_msgs::action::GripperReferenceFilterWaypoint::Goal>
/*goal*/| void GripperReferenceFilterNode::handle_accepted( | ||
| const std::shared_ptr<rclcpp_action::ServerGoalHandle< | ||
| vortex_msgs::action::GripperReferenceFilterWaypoint>> goal_handle) { | ||
| std::thread{std::bind(&GripperReferenceFilterNode::execute, this, | ||
| std::placeholders::_1), goal_handle}.detach(); | ||
| } |
There was a problem hiding this comment.
This node currently uses both a Reentrant callback group for the action server and detaches a thread for the execute function, which IMO is overkill. We also had some race condition issues with this setup in the previous implementation of the reference filter, which is now fixed so you can take inspiration from that.
| x(0) = reference_(0); // roll | ||
| x(1) = reference_(1); // pinch | ||
| x(2) = 0.0; // roll_dot | ||
| x(3) = 0.0; // pinch_dot | ||
| x(4) = 0.0; // roll_dotdot | ||
| x(5) = 0.0; // pinch_dotdot |
There was a problem hiding this comment.
Does the gripper reference message need to be 6d if we ever only use the first two dims?
| Eigen::Vector6d GripperReferenceFilterNode::fill_reference_state() { | ||
| Eigen::Vector6d x = Eigen::Vector6d::Zero(); | ||
|
|
||
| x(0) = reference_(0); // roll | ||
| x(1) = reference_(1); // pinch | ||
| x(2) = 0.0; // roll_dot | ||
| x(3) = 0.0; // pinch_dot | ||
| x(4) = 0.0; // roll_dotdot | ||
| x(5) = 0.0; // pinch_dotdot | ||
|
|
||
| return x; | ||
| } | ||
|
|
||
| Eigen::Vector2d GripperReferenceFilterNode::fill_reference_goal( | ||
| const vortex_msgs::msg::GripperWaypoint& goal) { | ||
|
|
||
| double roll{goal.roll.roll}; | ||
| double pinch{goal.pinch.pinch}; | ||
|
|
||
| Eigen::Vector2d reference; | ||
| reference << roll, pinch; | ||
|
|
||
| return reference; | ||
| } | ||
|
|
||
| vortex_msgs::msg::GripperReferenceFilter GripperReferenceFilterNode::fill_reference_msg() { | ||
| vortex_msgs::msg::GripperReferenceFilter feedback_msg; | ||
|
|
||
| feedback_msg.roll = x_(0); | ||
| feedback_msg.pinch = x_(1); | ||
| feedback_msg.roll_dot = x_(2); | ||
| feedback_msg.pinch_dot = x_(3); | ||
| feedback_msg.roll_dotdot = x_(4); | ||
| feedback_msg.pinch_dotdot = x_(5); | ||
|
|
||
| return feedback_msg; | ||
| } |
There was a problem hiding this comment.
Maybe move these conversion functions to a separate util file to avoid clutter in the ros node
| auto feedback = std::make_shared< | ||
| vortex_msgs::action::GripperReferenceFilterWaypoint::Feedback>(); |
There was a problem hiding this comment.
Should remove feedback from the action definition and just publish to topic if anyone is interested
| vortex_msgs::msg::GripperReferenceFilter feedback_msg = fill_reference_msg(); | ||
| feedback->reference = feedback_msg; | ||
| reference_pub_->publish(feedback_msg); |
There was a problem hiding this comment.
Should use unique pointer for this kind of pipeline style publishing. Ref: https://vortex.a2hosted.com/index.php/Composable_nodes
|
|
||
| GripperReferenceFilterNode::GripperReferenceFilterNode(const rclcpp::NodeOptions& options) | ||
| : Node("gripper_reference_filter_node", options) { | ||
| time_step_ = std::chrono::milliseconds(10); |
There was a problem hiding this comment.
should rename the variable to time_step_ms_ to make it more explicit that it is milliseconds and not seconds. Also would be nice to expose this as a ros param
THE CODE SHOULD SPEAK FOR ITSELF inshallah