Skip to content
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

Add lazy_theta_star #1839

Merged
merged 84 commits into from
Jul 2, 2021
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
14c33e9
Add lazy_theta_star
Anshu-man567 Jul 1, 2020
cc95058
Added license
Anshu-man567 Jul 1, 2020
74946f2
Added license
Anshu-man567 Jul 1, 2020
ae6ecc4
Update lazy_theta_star_b.cpp
Anshu-man567 Jul 2, 2020
24ab823
restructured files
Anshu-man567 Jul 4, 2020
d4dd263
restructured files
Anshu-man567 Jul 4, 2020
d6f8b8f
Update CMakeLists.txt
Anshu-man567 Jul 4, 2020
a11fbd9
removed unnecessary comments
Anshu-man567 Jul 4, 2020
d6f9584
removed comments
Anshu-man567 Jul 4, 2020
ca4ac17
Delete planner.cpp
Anshu-man567 Jul 15, 2020
dd1563c
Delete lazy_theta_star_b.cpp
Anshu-man567 Jul 15, 2020
e099e08
Delete lazy_theta_star_b.h
Anshu-man567 Jul 15, 2020
efca962
Delete planner.h
Anshu-man567 Jul 15, 2020
28925f8
Delete CMakeLists.txt
Anshu-man567 Jul 15, 2020
c35ea2b
Delete global_planner_plugin.xml
Anshu-man567 Jul 15, 2020
d7f50d0
Delete package.xml
Anshu-man567 Jul 15, 2020
99efed3
replaced the files
Anshu-man567 Jul 15, 2020
f4a622b
removed comments
Anshu-man567 Jul 15, 2020
6ad8bbd
removed comments
Anshu-man567 Jul 15, 2020
6376718
Update lazy_theta_star2.cpp
Anshu-man567 Jul 15, 2020
61ceb55
update files
Anshu-man567 Jul 16, 2020
27c4d3d
update files
Anshu-man567 Jul 16, 2020
72eac93
Delete lazy_theta_star2.h
Anshu-man567 Sep 28, 2020
b5b705b
Delete lazy_theta_star_planner.h
Anshu-man567 Sep 28, 2020
3349e20
Delete lazy_theta_star2.cpp
Anshu-man567 Sep 28, 2020
2d549e1
Delete lazy_theta_star_planner.cpp
Anshu-man567 Sep 28, 2020
61d905e
Delete CMakeLists.txt
Anshu-man567 Sep 28, 2020
c70970a
Delete package.xml
Anshu-man567 Sep 28, 2020
ded0dc9
Delete global_planner_plugin.xml
Anshu-man567 Sep 28, 2020
6cf9391
upload the changed code
Anshu-man567 Sep 28, 2020
81367d1
Delete lazy_theta_star_p_planner directory
Anshu-man567 Jan 13, 2021
d2326b7
Replace the old files
Anshu-man567 Jan 13, 2021
04cf677
Delete lazy_theta_star_p_planner directory
Anshu-man567 Feb 17, 2021
62127db
update the files
Anshu-man567 Feb 17, 2021
19a8a01
Update README.md
Anshu-man567 Feb 17, 2021
3c4ef87
update the code
Anshu-man567 Feb 18, 2021
8febae2
update the readme file
Anshu-man567 Mar 30, 2021
c2baaa0
Update README.md
Anshu-man567 Mar 30, 2021
653f920
Update README.md
Anshu-man567 Mar 30, 2021
0a34ff3
Update README.md
Anshu-man567 Mar 30, 2021
6f07371
Update README.md
Anshu-man567 Mar 30, 2021
c32a338
Merge remote-tracking branch 'nav2/main'
Anshu-man567 Mar 30, 2021
d4ca17c
Delete global_planner_plugin.xml
Anshu-man567 Mar 30, 2021
fbbb8c1
fix the linting issues
Anshu-man567 Mar 30, 2021
5c42a87
remove the space on line 7
Anshu-man567 Mar 31, 2021
2137bd5
change RCLCPP_INFO to RCLCPP_DEBUG
Anshu-man567 Mar 31, 2021
6586a82
Update README.md
Anshu-man567 Mar 31, 2021
3c1bb0d
Add test coverage
Anshu-man567 Apr 16, 2021
e15ce17
update the test file
Anshu-man567 Apr 16, 2021
2f9d63f
update the test file
Anshu-man567 Apr 16, 2021
81bd2ab
Update README.md
Anshu-man567 Apr 16, 2021
727e60e
Update README.md
Anshu-man567 Apr 16, 2021
2830e54
Update README.md
Anshu-man567 Apr 16, 2021
e72f401
add test on the size of the output path
Anshu-man567 Apr 16, 2021
d6eb872
Update README.md
Anshu-man567 Apr 16, 2021
ae430d6
Update README.md
Anshu-man567 Apr 16, 2021
4ea8976
change the function name from `isSafeToPlan()` to `isUnsafeToPlan()`
Anshu-man567 Apr 16, 2021
478a843
update the files
Anshu-man567 Apr 25, 2021
81e81a6
fix typos
Anshu-man567 Apr 30, 2021
3e0bc16
Update README.md
Anshu-man567 May 9, 2021
3a9983b
Update README.md
Anshu-man567 May 9, 2021
e24baa6
Update README.md
Anshu-man567 May 9, 2021
dec0ddd
Update README.md
Anshu-man567 May 9, 2021
6c33e50
Update README.md
Anshu-man567 May 9, 2021
cbad8ff
Update README.md
Anshu-man567 May 9, 2021
da2496e
Update README.md
Anshu-man567 May 10, 2021
e8da09e
fix the typo
Anshu-man567 May 18, 2021
4210dc9
Update theta_star.hpp
Anshu-man567 Jun 11, 2021
f45980a
Update theta_star.cpp
Anshu-man567 Jun 11, 2021
8ed8364
update default parameters
Anshu-man567 Jun 17, 2021
cffb034
update default parameters
Anshu-man567 Jun 18, 2021
a7e1da0
Update README.md
Anshu-man567 Jun 18, 2021
4c04a66
update the test file
Anshu-man567 Jun 18, 2021
935fd5e
Merge branch 'master' of https://github.com/Anshu-man567/navigation2 …
Anshu-man567 Jun 18, 2021
e9f3177
fix linting issues
Anshu-man567 Jun 18, 2021
34e5b31
Update README.md
Anshu-man567 Jun 18, 2021
9b046bf
Update README.md
Anshu-man567 Jun 18, 2021
ad184e0
Update README.md
Anshu-man567 Jun 18, 2021
94c6f6a
Update theta_star_planner.cpp
Anshu-man567 Jun 21, 2021
87f7842
Merge branch 'ros-planning:main' into master
Anshu-man567 Jun 23, 2021
5d81029
update LETHAL_COST
Anshu-man567 Jun 24, 2021
13b8cde
update README.md
Anshu-man567 Jun 24, 2021
bad3d94
update dependency list
Anshu-man567 Jun 24, 2021
984a7a0
Update package.xml
Anshu-man567 Jun 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions lazy_theta_star_planner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
cmake_minimum_required(VERSION 3.5)
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
project(lazy_theta_star_planner)

find_package(ament_cmake REQUIRED)
find_package(builtin_interfaces REQUIRED)
find_package(nav2_common REQUIRED)
find_package(nav2_core REQUIRED)
find_package(nav2_costmap_2d REQUIRED)
find_package(nav2_msgs REQUIRED)
find_package(nav2_util REQUIRED)
find_package(pluginlib REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rclcpp_action REQUIRED)
find_package(rclcpp_lifecycle REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(ament_cmake_gtest REQUIRED)

include_directories(
include
)

set(library_name ${PROJECT_NAME}_plugin)

set(dependencies
ament_cmake
builtin_interfaces
nav2_common
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
nav2_core
nav2_costmap_2d
nav2_msgs
nav2_util
pluginlib
rclcpp
rclcpp_action
rclcpp_lifecycle
tf2_ros
)

add_library(${library_name} SHARED
src/lazy_theta_star2.cpp
src/lazy_theta_star_planner.cpp
)

ament_target_dependencies(${library_name}
${dependencies}
)

target_compile_definitions(${library_name} PUBLIC "PLUGINLIB_DISABLE_BOOST_FUNCTIONS")

pluginlib_export_plugin_description_file(nav2_core global_planner_plugin.xml)

install(TARGETS ${library_name}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION lib/${PROJECT_NAME}
)

install(DIRECTORY include/
DESTINATION include/
)

install(FILES global_planner_plugin.xml
DESTINATION share/${PROJECT_NAME}
)



if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()


ament_export_include_directories(include)
ament_export_libraries(${library_name})
ament_export_dependencies(${dependencies})
ament_package()
5 changes: 5 additions & 0 deletions lazy_theta_star_planner/global_planner_plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<library path="lazy_theta_star_planner_plugin">
<class name="lazyThetaStarPlanner/LazyThetaStarPlanner" type="lazyThetaStarPlanner::LazyThetaStarPlanner" base_class_type="nav2_core::GlobalPlanner">
<description>The implementation of lazy theta_star</description>
</class>
</library>
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
// Copyright 2020 Anshumaan Singh
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
//
// Licensed under the Apache License, Version 2.0 (the "License");
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
// 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 LAZY_THETA_STAR_B__LAZY_THETA_STAR_H_
#define LAZY_THETA_STAR_B__LAZY_THETA_STAR_H_

#include <cmath>
#include <vector>
#include <queue>
#include <algorithm>
#include "rclcpp/rclcpp.hpp"
#include "nav2_costmap_2d/costmap_2d_ros.hpp"
#include "nav2_costmap_2d/cost_values.hpp"

typedef int id;
typedef double cost;
typedef int map_pts;
typedef double world_pts;

#define INF_COST DBL_MAX
#define LETHAL_COST 252

template<typename coordsT>
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
struct coords
{
coordsT x, y;
};

struct pos
{
id pos_id;
cost * f;
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
};

struct tree_node
{
map_pts x, y;
cost g = INF_COST;
cost h = INF_COST;
id parent_id;
int closed = 0;
cost f = INF_COST;
};

struct comp
{
bool operator()(pos & p1, pos & p2)
{
return *(p1.f) > *(p2.f);
}
};
namespace lazyThetaStar
{
class LazyThetaStar
{
public:
nav2_costmap_2d::Costmap2D * costmap_;
nav2_util::LifecycleNode::SharedPtr node_;

std::vector<id> posn;
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
std::vector<tree_node> data;
std::priority_queue<pos, std::vector<pos>, comp> pq;
int sizeX, sizeY;
int how_many_corners;
id id_gen;
coords<map_pts> src{}, dst{};
int lethal_cost = LETHAL_COST;
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved

const map_pts moves[8][2] = {{0, 1},
{0, -1},
{1, 0},
{-1, 0},
{1, -1},
{-1, 1},
{1, 1},
{-1, -1}};

LazyThetaStar();

bool getPath(std::vector<coords<world_pts>> & raw_path);

bool losCheck(map_pts & x0, map_pts & y0, map_pts & x1, map_pts & y1) const;

cost dist(map_pts & ax, map_pts & ay, map_pts & bx, map_pts & by)
{
return sqrt(pow(ax - bx, 2) + pow(ay - by, 2));
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
}

// TODO (Anshu-man567) : FIND A WAY TO ADD REFERENCES TO THIS FUNCTION THAT IS IF POSSIBLE
bool isSafe(map_pts cx, map_pts cy) const
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
{
return costmap_->getCost(cx, cy) < lethal_cost;
}

bool withinLimits(map_pts & cx, map_pts & cy) const
{
return cx >= 0 && cx < sizeX && cy >= 0 && cy < sizeY;
}

void addIndex(map_pts cx, map_pts cy, id id_this)
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
{
posn[sizeX * cy + cx] = id_this;
}

void getIndex(map_pts & cx, map_pts & cy, id & id_this)
{
id_this = posn[sizeX * cy + cx];
}
void initializePosn();

void backtrace(std::vector<coords<world_pts>> & raw_points, id & curr_id);

bool isGoal(map_pts & cx, map_pts & cy);

void initializeStuff();
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved

void clearStuff();

void resetParent(tree_node & curr_data);

void setNeighbors(tree_node & curr_data);
};
} // namespace lazyThetaStar

#endif // LAZY_THETA_STAR_B_LAZY_THETA_STAR_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright 2020 Anshumaan Singh
//
// 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 LAZY_THETA_STAR_PLANNER__LAZY_THETA_STAR_PLANNER_H_
#define LAZY_THETA_STAR_PLANNER__LAZY_THETA_STAR_PLANNER_H_

#include <iostream>
#include <cmath>
#include <string>
#include <chrono>
#include <queue>
#include <algorithm>
#include <memory>
#include <vector>
#include "rclcpp/rclcpp.hpp"
#include "nav2_core/global_planner.hpp"
#include "nav_msgs/msg/path.hpp"
#include "nav2_util/robot_utils.hpp"
#include "nav2_util/lifecycle_node.hpp"
#include "nav2_costmap_2d/costmap_2d_ros.hpp"
#include "nav2_costmap_2d/cost_values.hpp"
#include "nav2_util/node_utils.hpp"
#include "lazy_theta_star_planner/lazy_theta_star2.h"

namespace lazyThetaStarPlanner
{

class LazyThetaStarPlanner : public nav2_core::GlobalPlanner
{
public:
std::shared_ptr<tf2_ros::Buffer> tf_;
nav2_util::LifecycleNode::SharedPtr node_;
nav2_costmap_2d::Costmap2D * costmap_;

std::string globalFrame_, name_;
int how_many_corners_;
double interpolation_dist_;
int lethal_cost_;
std::unique_ptr<lazyThetaStar::LazyThetaStar> planner_;

unsigned int src_[2], dst_[2];
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved

void configure(
rclcpp_lifecycle::LifecycleNode::SharedPtr parent,
std::string name, std::shared_ptr<tf2_ros::Buffer> tf,
std::shared_ptr<nav2_costmap_2d::Costmap2DROS> costmapRos) override;

void cleanup() override;

void activate() override;

void deactivate() override;

nav_msgs::msg::Path createPlan(
const geometry_msgs::msg::PoseStamped & start,
const geometry_msgs::msg::PoseStamped & goal) override;

nav_msgs::msg::Path linearInterpolation(
std::vector<coords<world_pts>> & raw_path,
double dist_bw_points);
};
} // namespace lazyThetaStarPlanner

#endif // LAZY_THETA_STAR_PLANNER__LAZY_THETA_STAR_PLANNER_H_
31 changes: 31 additions & 0 deletions lazy_theta_star_planner/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>lazy_theta_star_planner</name>
<version>0.0.1</version>
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
<description>TODO: Package description</description>
<maintainer email="[email protected]">anshu-man</maintainer>
SteveMacenski marked this conversation as resolved.
Show resolved Hide resolved
<license>Apache-2.0</license>

<buildtool_depend>ament_cmake</buildtool_depend>
<depend>rclcpp</depend>
<depend>nav2_core</depend>
<depend>rclcpp_action</depend>
<depend>rclcpp_lifecycle</depend>
<depend>std_msgs</depend>
<depend>visualization_msgs</depend>
<depend>nav2_util</depend>
<depend>nav2_msgs</depend>
<depend>builtin_interfaces</depend>
<depend>tf2_ros</depend>
<depend>nav2_costmap_2d</depend>
<depend>pluginlib</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>

<export>
<build_type>ament_cmake</build_type>
<nav2_core plugin="${prefix}/global_planner_plugin.xml" />
</export>
</package>
Loading