-
Notifications
You must be signed in to change notification settings - Fork 8
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
Allow the path to be computed ahead of the match start #209
Open
lukicdarkoo
wants to merge
1
commit into
main
Choose a base branch
from
feature-precompute-path
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
12 changes: 9 additions & 3 deletions
12
mep3_behavior_tree/assets/strategies/big/purple_strategy.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
<root main_tree_to_execute="BehaviorTree"> | ||
<!-- ////////// --> | ||
<BehaviorTree ID="BehaviorTree"> | ||
<SequenceStar> | ||
<Sequence> | ||
<WaitMatchStart state="1" /> | ||
<PoseToFullPose pose="0;0.3;0" full_pose="{goal}" /> | ||
<ComputePathToPose goal="{goal}" path="{path}" planner_id="GridBased" /> | ||
<WaitMatchStart state="2" /> | ||
<FollowPath path="{path}" controller_id="FollowPath" /> | ||
|
||
<Wait duration="100000.0" name="Wait one big purple main strategy" /> | ||
</SequenceStar> | ||
</Sequence> | ||
</BehaviorTree> | ||
<!-- ////////// --> | ||
</root> | ||
</root> |
80 changes: 80 additions & 0 deletions
80
mep3_behavior_tree/include/mep3_behavior_tree/pose_to_full_pose_action.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
// Copyright 2021 Memristor Robotics | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pokusao sam izbjeci kreiranje ovog cvora ali nisam uspio :/ |
||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#ifndef MEP3_BEHAVIOR_TREE__POSE_TO_FULL_POSE_ACTION_HPP_ | ||
#define MEP3_BEHAVIOR_TREE__POSE_TO_FULL_POSE_ACTION_HPP_ | ||
|
||
#include <iostream> | ||
#include <string> | ||
|
||
#include "behaviortree_cpp_v3/action_node.h" | ||
#include "rclcpp/rclcpp.hpp" | ||
#include "geometry_msgs/msg/pose_stamped.hpp" | ||
|
||
#include "mep3_behavior_tree/pose_2d.hpp" | ||
|
||
namespace mep3_behavior_tree | ||
{ | ||
class PoseToFullPoseAction : public BT::SyncActionNode | ||
{ | ||
public: | ||
PoseToFullPoseAction(const std::string & name, const BT::NodeConfiguration & config_) | ||
: BT::SyncActionNode(name, config_) | ||
{ | ||
node_ = config().blackboard->get<rclcpp::Node::SharedPtr>("node"); | ||
} | ||
|
||
PoseToFullPoseAction() = delete; | ||
|
||
BT::NodeStatus tick() override; | ||
|
||
static BT::PortsList providedPorts() | ||
{ | ||
return { | ||
BT::InputPort<BT::Pose2D>("pose"), | ||
BT::OutputPort<geometry_msgs::msg::PoseStamped>("full_pose"), | ||
}; | ||
} | ||
|
||
private: | ||
rclcpp::Node::SharedPtr node_; | ||
}; | ||
|
||
BT::NodeStatus PoseToFullPoseAction::tick() | ||
{ | ||
BT::Pose2D pose; | ||
getInput("pose", pose); | ||
|
||
geometry_msgs::msg::PoseStamped full_pose; | ||
full_pose.header.frame_id = "map"; | ||
full_pose.header.stamp = node_->get_clock()->now(); | ||
|
||
// Position | ||
full_pose.pose.position.x = pose.x; | ||
full_pose.pose.position.y = pose.y; | ||
|
||
// Orientation (yaw) | ||
// Convert deg to rad | ||
const double theta = pose.theta * M_PI / 180.0; | ||
// https://math.stackexchange.com/a/1972382 | ||
full_pose.pose.orientation.w = std::cos(theta / 2.0); | ||
full_pose.pose.orientation.z = std::sin(theta / 2.0); | ||
setOutput("full_pose", full_pose); | ||
|
||
return BT::NodeStatus::SUCCESS; | ||
} | ||
|
||
} // namespace mep3_behavior_tree | ||
|
||
#endif // MEP3_BEHAVIOR_TREE__POSE_TO_FULL_POSE_ACTION_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@angstrem98 Samo za
controller_id
stavi brzi kontrolerThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inace, ovu putanju mozemo cak i zakucati, ne moramo uopste pozivati ComputePathToPose