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

Move some of the task base classes out to separate directories. #9

Merged
merged 1 commit into from
Jul 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions src/control/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
cmake_minimum_required(VERSION 3.5)
project(control)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(task REQUIRED)

include_directories(
include
../task/include
../robot/include
)

link_directories(${CMAKE_BINARY_DIR}/../libs)

add_executable(dwa_controller
src/ControlTask.cpp
src/DwaController.cpp
src/main.cpp
)

target_link_libraries(dwa_controller
robot
task
)

ament_target_dependencies(dwa_controller
rclcpp
std_msgs
task
robot
)

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

ament_package()
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright 2018 Intel Corporation. All Rights Reserved.

#ifndef TASK__CONTROLTASK_HPP_
#define TASK__CONTROLTASK_HPP_
#ifndef CONTROL__CONTROLTASK_HPP_
#define CONTROL__CONTROLTASK_HPP_

#include "task/RobotTask.hpp"

class ControlTask : public RobotTask
{
public:
explicit ControlTask(const std::string & name, Robot * robot);
ControlTask(const std::string & name, Robot * robot);
ControlTask() = delete;
~ControlTask();

virtual void executePlan() = 0;
};

#endif // TASK__CONTROLTASK_HPP_
#endif // CONTROL__CONTROLTASK_HPP_
22 changes: 22 additions & 0 deletions src/control/include/control/DwaController.hpp
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 CONTROL__DWACONTROLLER_HPP_
#define CONTROL__DWACONTROLLER_HPP_

#include "control/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 // CONTROL__DWACONTROLLER_HPP_
19 changes: 19 additions & 0 deletions src/control/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>control</name>
<version>0.1.0</version>
<description>TODO</description>
<author email="oregon.robotics.team@intel.com">Oregon Robotics Team</author>
<maintainer email="oregon.robotics.team@intel.com">Oregon Robotics Team</maintainer>
<license>Apache License 2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rclcpp</build_depend>
<build_depend>task</build_depend>
<build_depend>robot</build_depend>
<exec_depend>rclcpp</exec_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>

Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright 2018 Intel Corporation. All Rights Reserved.

#include "task/ControlTask.hpp"
#include "control/ControlTask.hpp"

ControlTask::ControlTask(const std::string & name, Robot * robot)
: RobotTask(name, robot)
Expand Down
27 changes: 27 additions & 0 deletions src/control/src/DwaController.cpp
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 "control/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");
}
20 changes: 20 additions & 0 deletions src/control/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright 2018 Intel Corporation. All Rights Reserved.

#include <string>
#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "control/DwaController.hpp"
#include "robot/RosRobot.hpp"

int main(int argc, char ** argv)
{
std::string urdf_filename;
RosRobot robot(urdf_filename);

rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<DwaController>("DwaController", &robot));
rclcpp::shutdown();

return 0;
}
4 changes: 0 additions & 4 deletions src/mission_execution/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ ament_target_dependencies(mission_execution
std_msgs
)

target_link_libraries(mission_execution
yasmine
)

install(TARGETS ${PROJECT_NAME}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
Expand Down
53 changes: 53 additions & 0 deletions src/navigation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required(VERSION 3.5)
project(navigation)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(task REQUIRED)

include_directories(
include
../task/include
../robot/include
../planning/include
../control/include
)

link_directories(${CMAKE_BINARY_DIR}/../libs)

add_executable(simple_navigator
src/NavigateToPoseTask.cpp
src/SimpleNavigator.cpp
src/main.cpp
)

target_link_libraries(simple_navigator
robot
task
)

ament_target_dependencies(simple_navigator
rclcpp
std_msgs
planning
control
task
robot
)

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

ament_package()
19 changes: 19 additions & 0 deletions src/navigation/include/navigation/NavigateToPoseTask.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright 2018 Intel Corporation. All Rights Reserved.

#ifndef NAVIGATION__NAVIGATETOPOSETASK_HPP_
#define NAVIGATION__NAVIGATETOPOSETASK_HPP_

#include "task/RobotTask.hpp"

class NavigateToPoseTask : public RobotTask
{
public:
NavigateToPoseTask(const std::string & name, Robot * robot);
NavigateToPoseTask() = delete;
~NavigateToPoseTask();

virtual void navigateTo(/*pose*/) = 0;
};

#endif // NAVIGATION__NAVIGATETOPOSETASK_HPP_
28 changes: 28 additions & 0 deletions src/navigation/include/navigation/SimpleNavigator.hpp
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.

#ifndef NAVIGATION__SIMPLENAVIGATOR_HPP_
#define NAVIGATION__SIMPLENAVIGATOR_HPP_

#include "navigation/NavigateToPoseTask.hpp"
#include "planning/AStarPlanner.hpp"
#include "control/DwaController.hpp"

class SimpleNavigator : public NavigateToPoseTask
{
public:
SimpleNavigator(const std::string & name, Robot * robot);
SimpleNavigator() = delete;
~SimpleNavigator();

void navigateTo(/*pose*/) override;

protected:
void workerThread();

// TODO: These will be the client-side proxies (like SimpleActionClient):
AStarPlanner * planner_;
DwaController * controller_;
};

#endif // NAVIGATION__SIMPLENAVIGATOR_HPP_
19 changes: 19 additions & 0 deletions src/navigation/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="2">
<name>navigation</name>
<version>0.1.0</version>
<description>TODO</description>
<author email="oregon.robotics.team@intel.com">Oregon Robotics Team</author>
<maintainer email="oregon.robotics.team@intel.com">Oregon Robotics Team</maintainer>
<license>Apache License 2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rclcpp</build_depend>
<build_depend>task</build_depend>
<build_depend>robot</build_depend>
<exec_depend>rclcpp</exec_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
</package>

15 changes: 15 additions & 0 deletions src/navigation/src/NavigateToPoseTask.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright 2018 Intel Corporation. All Rights Reserved.

#include "navigation/NavigateToPoseTask.hpp"

NavigateToPoseTask::NavigateToPoseTask(const std::string & name, Robot * robot)
: RobotTask(name, robot)
{
RCLCPP_INFO(get_logger(), "NavigateToPoseTask::NavigateToPoseTask");
}

NavigateToPoseTask::~NavigateToPoseTask()
{
RCLCPP_INFO(get_logger(), "NavigateToPoseTask::~NavigateToPoseTask");
}
27 changes: 27 additions & 0 deletions src/navigation/src/SimpleNavigator.cpp
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 "navigation/SimpleNavigator.hpp"

SimpleNavigator::SimpleNavigator(const std::string & name, Robot * robot)
: NavigateToPoseTask(name, robot), planner_(nullptr), controller_(nullptr)
{
RCLCPP_INFO(get_logger(), "SimpleNavigator::SimpleNavigator");
}

SimpleNavigator::~SimpleNavigator()
{
RCLCPP_INFO(get_logger(), "SimpleNavigator::~SimpleNavigator");
}

void
SimpleNavigator::navigateTo()
{
RCLCPP_INFO(get_logger(), "SimpleNavigator::executePlan");
}

void
SimpleNavigator::workerThread()
{
RCLCPP_INFO(get_logger(), "SimpleNavigator::workerThread");
}
20 changes: 20 additions & 0 deletions src/navigation/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright 2018 Intel Corporation. All Rights Reserved.

#include <string>
#include <memory>
#include "rclcpp/rclcpp.hpp"
#include "navigation/SimpleNavigator.hpp"
#include "robot/RosRobot.hpp"

int main(int argc, char ** argv)
{
std::string urdf_filename;
RosRobot robot(urdf_filename);

rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<SimpleNavigator>("SimpleNavigator", &robot));
rclcpp::shutdown();

return 0;
}
Loading