-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More work on basic command chain class hierarchy.
- Loading branch information
Michael Jeronimo
authored
Jul 25, 2018
1 parent
699debf
commit 69a647c
Showing
15 changed files
with
205 additions
and
29 deletions.
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,23 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright 2018 Intel Corporation. All Rights Reserved. | ||
|
||
#ifndef TASK__ASTARPLANNER_HPP_ | ||
#define TASK__ASTARPLANNER_HPP_ | ||
|
||
#include "task/PlanningTask.hpp" | ||
|
||
class AStarPlanner : public PlanningTask | ||
{ | ||
public: | ||
AStarPlanner(const std::string & name); | ||
AStarPlanner() = delete; | ||
~AStarPlanner(); | ||
|
||
void createPlan(const geometry_msgs::msg::PoseStamped & start, | ||
const geometry_msgs::msg::PoseStamped & goal); | ||
|
||
protected: | ||
void workerThread() override; | ||
}; | ||
|
||
#endif // TASK__ASTARPLANNER_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
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,22 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright 2018 Intel Corporation. All Rights Reserved. | ||
|
||
#ifndef TASK__SPECIFICCONTROLLER_HPP_ | ||
#define TASK__SPECIFICCONTROLLER_HPP_ | ||
|
||
#include "task/ControlTask.hpp" | ||
|
||
class DwaController : public ControlTask | ||
{ | ||
public: | ||
DwaController(const std::string & name, Robot * robot); | ||
DwaController() = delete; | ||
~DwaController(); | ||
|
||
void executePlan() override; | ||
|
||
protected: | ||
void workerThread() override; | ||
}; | ||
|
||
#endif // TASK__SPECIFICCONTROLLER_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
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
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,28 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright 2018 Intel Corporation. All Rights Reserved. | ||
|
||
#include "task/AStarPlanner.hpp" | ||
|
||
AStarPlanner::AStarPlanner(const std::string & name) | ||
: PlanningTask(name) | ||
{ | ||
RCLCPP_INFO(get_logger(), "AStarPlanner::AStarPlanner"); | ||
} | ||
|
||
AStarPlanner::~AStarPlanner() | ||
{ | ||
RCLCPP_INFO(get_logger(), "AStarPlanner::~AStarPlanner"); | ||
} | ||
|
||
void | ||
AStarPlanner::createPlan(const geometry_msgs::msg::PoseStamped & start, | ||
const geometry_msgs::msg::PoseStamped & goal) | ||
{ | ||
RCLCPP_INFO(get_logger(), "AStarPlanner::createPlan"); | ||
} | ||
|
||
void | ||
AStarPlanner::workerThread() | ||
{ | ||
RCLCPP_INFO(get_logger(), "AStarPlanner::workerThread"); | ||
} |
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,27 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright 2018 Intel Corporation. All Rights Reserved. | ||
|
||
#include "task/DwaController.hpp" | ||
|
||
DwaController::DwaController(const std::string & name, Robot * robot) | ||
: ControlTask(name, robot) | ||
{ | ||
RCLCPP_INFO(get_logger(), "DwaController::DwaController"); | ||
} | ||
|
||
DwaController::~DwaController() | ||
{ | ||
RCLCPP_INFO(get_logger(), "DwaController::~DwaController"); | ||
} | ||
|
||
void | ||
DwaController::executePlan() | ||
{ | ||
RCLCPP_INFO(get_logger(), "DwaController::executePlan"); | ||
} | ||
|
||
void | ||
DwaController::workerThread() | ||
{ | ||
RCLCPP_INFO(get_logger(), "DwaController::workerThread"); | ||
} |
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
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,54 @@ | ||
// License: Apache 2.0. See LICENSE file in root directory. | ||
// Copyright 2018 Intel Corporation. All Rights Reserved. | ||
|
||
#include "task/Task.hpp" | ||
|
||
Task::Task(const std::string & name) | ||
: Node(name), workerThread_(nullptr), stopWorkerThread_(false) | ||
{ | ||
RCLCPP_INFO(get_logger(), "Task::Task"); | ||
|
||
cmdSub_ = create_subscription<std_msgs::msg::String>("TaskCmd", | ||
std::bind(&Task::onCmdReceived, this, std::placeholders::_1)); | ||
} | ||
|
||
Task::~Task() | ||
{ | ||
RCLCPP_INFO(get_logger(), "Task::~Task"); | ||
if (workerThread_ != nullptr) | ||
cancel(); | ||
} | ||
|
||
void | ||
Task::execute() | ||
{ | ||
RCLCPP_INFO(get_logger(), "Task::execute"); | ||
stopWorkerThread_ = false; | ||
workerThread_ = new std::thread(&Task::workerThread, this); | ||
} | ||
|
||
void | ||
Task::cancel() | ||
{ | ||
RCLCPP_INFO(get_logger(), "Task::cancel"); | ||
stopWorkerThread_ = true; | ||
workerThread_->join(); | ||
|
||
delete workerThread_; | ||
workerThread_ = nullptr; | ||
} | ||
|
||
void | ||
Task::onCmdReceived(const std_msgs::msg::String::SharedPtr msg) | ||
{ | ||
RCLCPP_INFO(get_logger(), "Task::onCmdReceived: \"%s\"", msg->data.c_str()) | ||
|
||
if (msg->data.compare("ExecuteTask") == 0) { | ||
execute(); | ||
} else if (msg->data.compare("CancelTask") == 0) { | ||
cancel(); | ||
} else { | ||
RCLCPP_INFO(get_logger(), "Task::onCmdReceived: invalid command: \"%s\"", | ||
msg->data.c_str()) | ||
} | ||
} |