-
Notifications
You must be signed in to change notification settings - Fork 186
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
Ball placement obstacle with Stadium Shape on their ball placement #2294
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a48f044
added some code for obstacles, has bugs, will fix next time
shourikb 09b4da6
created the right shape. now just need to make it an obstacle properl…
shourikb 4f645bc
added the stadium shape obstacle through composite shape. next step i…
shourikb 50b7aee
trying to add stadium shape. structure is built, now need to implemen…
shourikb 19504d8
stadium shape is fully working and has been implemented into plan req…
shourikb 8418efe
resolved changes requested in my pr
shourikb c593823
Intermediate Pathgen (#2266)
sanatd33 2d0b689
Update Github Actions (#2283)
sanatd33 5314aa9
Remove Dependency on Deprecated Disutils (#2281)
Squid5678 079fb72
Dribble in Sim (#2287)
sanatd33 27cb3d6
add ros env vars to source script (#2288)
sid-parikh 76cbe71
Update tutorial.rst (#2286)
jacksherling 091a744
Fix the Fix Style (#2296)
sanatd33 ee9d3b2
Waller Planner (#2293)
sanatd33 664d8fc
Fix Code Style On ball-placement-obstacle (#2304)
github-actions[bot] 81d751d
Merge branch 'ros2' into ball-placement-obstacle
shourikb f6db777
Fix Code Style On ball-placement-obstacle (#2316)
github-actions[bot] 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
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
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,93 @@ | ||
#pragma once | ||
|
||
#include <memory> | ||
#include <set> | ||
#include <vector> | ||
|
||
#include "point.hpp" | ||
#include "polygon.hpp" | ||
#include "segment.hpp" | ||
#include "shape.hpp" | ||
#include "shape_set.hpp" | ||
|
||
namespace rj_geometry { | ||
|
||
/** | ||
* A rj_geometry::StadiumShape is a Shape that is made up of 2 circles and a polygon. It represents | ||
* the shape of a track from track and field. | ||
*/ | ||
class StadiumShape : public Shape { | ||
Check warning on line 19 in rj_geometry/include/rj_geometry/stadium_shape.hpp GitHub Actions / build-and-test
|
||
public: | ||
~StadiumShape() = default; | ||
|
||
StadiumShape() = default; | ||
|
||
StadiumShape(Point c1, Point c2, float r) { init(c1, c2, r); } | ||
|
||
StadiumShape(const StadiumShape& other) { | ||
for (const auto& shape : other.subshapes_) { | ||
std::shared_ptr<Shape> itr_shape = std::shared_ptr<Shape>(shape->clone()); | ||
subshapes_.push_back(itr_shape); | ||
} | ||
drawshapes_ = other.drawshapes_; | ||
} | ||
|
||
[[nodiscard]] Shape* clone() const override; | ||
|
||
[[nodiscard]] bool contains_point(Point pt) const override; | ||
[[nodiscard]] bool near_point(Point pt, float threshold) const override; | ||
|
||
using const_iterator = std::vector<std::shared_ptr<Shape>>::const_iterator; | ||
using iterator = std::vector<std::shared_ptr<Shape>>::iterator; | ||
|
||
[[nodiscard]] const_iterator begin() const { return subshapes_.begin(); } | ||
[[nodiscard]] const_iterator end() const { return subshapes_.end(); } | ||
|
||
iterator begin() { return subshapes_.begin(); } | ||
iterator end() { return subshapes_.end(); } | ||
|
||
[[nodiscard]] const std::vector<std::shared_ptr<Shape>>& subshapes() const { | ||
return subshapes_; | ||
} | ||
|
||
[[nodiscard]] const rj_geometry::ShapeSet drawshapes() const { return drawshapes_; } | ||
|
||
std::shared_ptr<Shape> operator[](unsigned int index) { return subshapes_[index]; } | ||
|
||
std::shared_ptr<const Shape> operator[](unsigned int index) const { return subshapes_[index]; } | ||
|
||
template <typename T> | ||
[[nodiscard]] bool hit(const T& obj) const { | ||
for (const auto& it : *this) { | ||
if (it->hit(obj)) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
[[nodiscard]] bool hit(Point pt) const override { return hit<Point>(pt); } | ||
|
||
[[nodiscard]] bool hit(const Segment& seg) const override { return hit<Segment>(seg); } | ||
|
||
std::string to_string() override { | ||
std::stringstream str; | ||
str << "StadiumShape<"; | ||
for (auto& subshape : subshapes_) { | ||
str << subshape->to_string() << ", "; | ||
} | ||
str << ">"; | ||
|
||
return str.str(); | ||
} | ||
|
||
protected: | ||
void init(Point c1, Point c2, float r); | ||
|
||
private: | ||
std::vector<std::shared_ptr<Shape>> subshapes_; | ||
rj_geometry::ShapeSet drawshapes_; | ||
}; | ||
|
||
} // namespace rj_geometry |
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
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,55 @@ | ||
#include <rj_geometry/stadium_shape.hpp> | ||
|
||
namespace rj_geometry { | ||
|
||
Shape* StadiumShape::clone() const { return new StadiumShape(*this); } | ||
|
||
void StadiumShape::init(Point c1, Point c2, float r) { | ||
rj_geometry::Circle first_circle = rj_geometry::Circle{c1, static_cast<float>(r)}; | ||
rj_geometry::Circle second_circle = rj_geometry::Circle{c2, static_cast<float>(r)}; | ||
|
||
rj_geometry::Segment vect{c1, c2}; | ||
|
||
rj_geometry::Point end1{c1.x() + r * (c2.x() - c1.x()) / vect.length(), | ||
c1.y() + r * (c2.y() - c1.y()) / vect.length()}; | ||
rj_geometry::Point end2{c2.x() - r * (c2.x() - c1.x()) / vect.length(), | ||
c2.y() - r * (c2.y() - c1.y()) / vect.length()}; | ||
|
||
rj_geometry::Segment vect_updated{end1, end2}; | ||
rj_geometry::Polygon rect_obs{vect_updated, r}; | ||
|
||
std::shared_ptr<rj_geometry::Circle> c1_obs_ptr = | ||
std::make_shared<rj_geometry::Circle>(first_circle); | ||
std::shared_ptr<rj_geometry::Polygon> rect_obs_ptr = | ||
std::make_shared<rj_geometry::Polygon>(rect_obs); | ||
std::shared_ptr<rj_geometry::Circle> c2_obs_ptr = | ||
std::make_shared<rj_geometry::Circle>(second_circle); | ||
|
||
subshapes_.push_back(c1_obs_ptr); | ||
subshapes_.push_back(rect_obs_ptr); | ||
subshapes_.push_back(c2_obs_ptr); | ||
|
||
drawshapes_.add(c1_obs_ptr); | ||
drawshapes_.add(rect_obs_ptr); | ||
drawshapes_.add(c2_obs_ptr); | ||
} | ||
|
||
bool StadiumShape::contains_point(Point pt) const { | ||
for (const auto& subshape : subshapes_) { | ||
if (subshape->contains_point(pt)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
bool StadiumShape::near_point(Point pt, float threshold) const { | ||
for (const auto& subshape : subshapes_) { | ||
if (subshape->near_point(pt, threshold)) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
} // namespace rj_geometry |
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
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
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
Oops, something went wrong.
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.
add a move constructor