Skip to content

Gstreamer Aruco Detection - #45

Open
chosterto wants to merge 13 commits into
mainfrom
feature/keyboard_auto
Open

Gstreamer Aruco Detection#45
chosterto wants to merge 13 commits into
mainfrom
feature/keyboard_auto

Conversation

@chosterto

Copy link
Copy Markdown
Member

No description provided.

RCLCPP_INFO(this->get_logger(), "Target pose: x=%.3f y=%.3f z=%.3f",
target_pose.pose.position.x,
target_pose.pose.position.y,
target_pose.pose.position.z);

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming this is a typo?

Comment on lines +141 to +154
rclcpp::Subscription<geometry_msgs::msg::PoseStamped>::SharedPtr key_pose_sub_;
rclcpp::Subscription<std_msgs::msg::String>::SharedPtr string_sub_;
rclcpp::Publisher<std_msgs::msg::String>::SharedPtr target_key_pub_;
std::shared_ptr<moveit::planning_interface::MoveGroupInterface> move_group_;
std::shared_ptr<rclcpp::executors::SingleThreadedExecutor> moveit_executor_;
std::thread moveit_spin_thread_;
std::thread typing_thread_;
geometry_msgs::msg::PoseStamped stored_pose_;
geometry_msgs::msg::PoseStamped home_pose_;
geometry_msgs::msg::PoseStamped latest_key_pose_;
std::atomic<bool> is_typing_{false};
std::mutex pose_mutex_;
std::condition_variable pose_cv_;
bool pose_ready_{false};

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better to move these declarations to a dedicated header file, just for cleanliness

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this serve a purpose anymore now that we have the moveit node?

import threading
import time

gstreamer_pipeline = ('udpsrc port=40627 caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H265" ! rtpjitterbuffer latency=50 ! rtph265depay ! h265parse ! queue max-size-buffers=20 max-size-time=0 max-size-bytes=0 leaky=downstream ! avdec_h265 ! videoconvert ! appsink')

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, will need to test this eventually

Comment thread curie_ws/src/curie_aruco/curie_aruco/curie_aruco.py Outdated
"moveit_testing",
rclcpp::NodeOptions().automatically_declare_parameters_from_overrides(true))
{
key_pose_sub_ = this->create_subscription<geometry_msgs::msg::PoseStamped>(

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to be a PoseStamped? Can't it just be a Pose

Comment on lines +86 to +92
self.key_target_pub = self.create_publisher(PoseStamped, 'key_target_pose', 1)
self.target_key_sub = self.create_subscription(
String,
'target_key',
self.target_key_callback,
10
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we transition to using service calls, both of these can be replaced with a single service, although it may need to be a custom interface. In this case, the request is of type string or char and the response is a PoseStamped or Pose.

Comment on lines +72 to +82
// Publish key
auto key_msg = std_msgs::msg::String();
key_msg.data = key;
target_key_pub_->publish(key_msg);

// Wait for ArUco to respond
std::unique_lock<std::mutex> lock(pose_mutex_);
pose_cv_.wait(lock, [this] { return pose_ready_; });

plan_and_execute(latest_key_pose_);
go_home();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Synchronizing the 2 nodes like this does work, but I think it's easier to use a service request here. So instead of this, you can replace it with something along the lines of

...
  auto result_future = client->async_send_request(request);
  if (rclcpp::spin_until_future_complete(this, result_future) ==
    rclcpp::FutureReturnCode::SUCCESS)
  {
     auto result = result_future.get();
     plan_and_execute(result->key_pose);
     go_home();
  }
...

And change /target_key to be a service rather than a topic.
What do you think @WillScott9214 ?

Comment on lines +128 to +139
void go_home()
{
std::vector<double> home_joints = {0.0, 0.0, 0.0, 0.0};
move_group_->setJointValueTarget(home_joints);
move_group_->setPlanningTime(10.0);

moveit::planning_interface::MoveGroupInterface::Plan my_plan;
bool success = (move_group_->plan(my_plan) == moveit::core::MoveItErrorCode::SUCCESS);
if (success) {
move_group_->execute(my_plan);
}
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Home" may need to be better defined, because we don't want the arm to go back to its zero position (it'll be too high up to see the keyboard)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants