Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
0b7f85a
Move some of the task base classes out to separate directories.
Jul 26, 2018
c6e5983
Implement start/stop for TaskClient and TaskServer
Jul 26, 2018
256174c
Merge remote-tracking branch 'upstream/ros2_devel' into ros2_devel
Jul 26, 2018
b748fdf
Work on starting and stopping a task hierarchy
Jul 26, 2018
c908bb3
Clean up formatting and fix cpplint/uncrustify issues
Jul 27, 2018
73f7f17
Missed the override on SimpleNavigator's execute method
Jul 27, 2018
613646b
Begin work on returning task results
Jul 27, 2018
62ef400
Continue with result message work
Jul 27, 2018
c47f1e9
Make TaskClient and TaskServer into templates
Jul 30, 2018
ebbcd86
Fix cancellation with the new template classes
Jul 30, 2018
f5ffbaa
Propagate the task return code
Jul 30, 2018
ef11585
Start adding messages
Jul 31, 2018
39e29d5
Add planning-related messages
Jul 31, 2018
55d00c4
Start adding Request/Response messages to the planner
Jul 31, 2018
083adaf
Fix template bug
Jul 31, 2018
96527cb
Name the task requests and responses
Jul 31, 2018
c12ffb3
Fix an inconsistency with the MissionExecution class
Jul 31, 2018
7c28c57
Fix a bug with the TaskServer base class not handling the CANCELED re…
Jul 31, 2018
c61369a
Change a couple command/result messages to having consistent naming c…
Aug 1, 2018
29d7376
Make the TaskClient and Server names consistent with their correspond…
Aug 2, 2018
0d73e10
Add files needed for conformant project layout
Aug 2, 2018
86fd51d
Remove a couple test scripts
Aug 2, 2018
68a8a94
Merge remote-tracking branch 'upstream/ros2_devel' into ros2_devel
Aug 2, 2018
8a37807
A couple more fixes fro the merge
Aug 2, 2018
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
File renamed without changes.
6 changes: 2 additions & 4 deletions src/control/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(task REQUIRED)
find_package(nav2_msgs REQUIRED)

include_directories(
include
Expand All @@ -24,20 +24,18 @@ include_directories(
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
nav2_msgs
robot
)

Expand Down
File renamed without changes.
File renamed without changes.
19 changes: 0 additions & 19 deletions src/control/include/control/ControlTask.hpp

This file was deleted.

27 changes: 18 additions & 9 deletions src/control/include/control/DwaController.hpp
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright 2018 Intel Corporation. All Rights Reserved.
// Copyright (c) 2018 Intel Corporation
//
// 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 CONTROL__DWACONTROLLER_HPP_
#define CONTROL__DWACONTROLLER_HPP_

#include "control/ControlTask.hpp"
#include <string>
#include "control/FollowPathTaskServer.hpp"

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

void executePlan() override;

protected:
void workerThread() override;
TaskStatus executeAsync(const FollowPathCommand::SharedPtr path) override;
};

#endif // CONTROL__DWACONTROLLER_HPP_
23 changes: 23 additions & 0 deletions src/control/include/control/FollowPathTaskClient.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2018 Intel Corporation
//
// 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 CONTROL__FOLLOWPATHTASKCLIENT_HPP_
#define CONTROL__FOLLOWPATHTASKCLIENT_HPP_

#include "task/TaskClient.hpp"
#include "control/FollowPathTaskMessages.hpp"

using FollowPathTaskClient = TaskClient<FollowPathCommand, FollowPathResult>;

#endif // CONTROL__FOLLOWPATHTASKCLIENT_HPP_
24 changes: 24 additions & 0 deletions src/control/include/control/FollowPathTaskMessages.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2018 Intel Corporation
//
// 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 CONTROL__FOLLOWPATHTASKMESSAGES_HPP_
#define CONTROL__FOLLOWPATHTASKMESSAGES_HPP_

#include "nav2_msgs/msg/path.hpp"
#include "std_msgs/msg/empty.hpp"

using FollowPathCommand = nav2_msgs::msg::Path;
using FollowPathResult = std_msgs::msg::Empty;

#endif // CONTROL__FOLLOWPATHTASKMESSAGES_HPP_
23 changes: 23 additions & 0 deletions src/control/include/control/FollowPathTaskServer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2018 Intel Corporation
//
// 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 CONTROL__FOLLOWPATHTASKSERVER_HPP_
#define CONTROL__FOLLOWPATHTASKSERVER_HPP_

#include "task/TaskServer.hpp"
#include "control/FollowPathTaskMessages.hpp"

using FollowPathTaskServer = TaskServer<FollowPathCommand, FollowPathResult>;

#endif // CONTROL__FOLLOWPATHTASKSERVER_HPP_
5 changes: 4 additions & 1 deletion src/control/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@
<license>Apache License 2.0</license>
<buildtool_depend>ament_cmake</buildtool_depend>
<build_depend>rclcpp</build_depend>
<build_depend>task</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>nav2_msgs</build_depend>
<build_depend>robot</build_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>nav2_msgs</exec_depend>
<export>
<build_type>ament_cmake</build_type>
</export>
Expand Down
15 changes: 0 additions & 15 deletions src/control/src/ControlTask.cpp

This file was deleted.

59 changes: 41 additions & 18 deletions src/control/src/DwaController.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright 2018 Intel Corporation. All Rights Reserved.
// Copyright (c) 2018 Intel Corporation
//
// 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.

#include "control/DwaController.hpp"
#include <string>
#include <chrono>
#include "control/DwaController.hpp"

using namespace std::chrono_literals;

DwaController::DwaController(const std::string & name, Robot * robot)
: ControlTask(name, robot)
DwaController::DwaController(const std::string & name)
: FollowPathTaskServer(name)
{
RCLCPP_INFO(get_logger(), "DwaController::DwaController");
}
Expand All @@ -15,21 +29,30 @@ DwaController::~DwaController()
RCLCPP_INFO(get_logger(), "DwaController::~DwaController");
}

void
DwaController::executePlan()
TaskStatus
DwaController::executeAsync(const FollowPathCommand::SharedPtr command)
{
RCLCPP_INFO(get_logger(), "DwaController::executePlan");
}
RCLCPP_INFO(get_logger(), "DwaController::executeAsync");

void
DwaController::workerThread()
{
RCLCPP_INFO(get_logger(), "DwaController::workerThread");
// Spin here for a bit to fake out some processing time
for (int i = 0; i < 10; i++) {
// Do a bit of the task
RCLCPP_INFO(get_logger(), "DwaController::executeAsync: doing work: %d", i);
std::this_thread::sleep_for(250ms);

while (!stopWorkerThread_)
{
std::this_thread::sleep_for(std::chrono::milliseconds(500));
RCLCPP_INFO(get_logger(), "DwaController::workerThread: doing work");
// Before we loop again to do more work, check if we've been canceled
if (cancelRequested()) {
RCLCPP_INFO(get_logger(), "DwaController::executeAsync: task has been canceled");
setCanceled();
return TaskStatus::CANCELED;
}
}
}

// We've successfully completed the task, so return the result
RCLCPP_INFO(get_logger(), "DwaController::executeAsync: task completed");

FollowPathResult result;
setResult(result);

return TaskStatus::SUCCEEDED;
}
21 changes: 14 additions & 7 deletions src/control/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,19 +1,26 @@
// License: Apache 2.0. See LICENSE file in root directory.
// Copyright 2018 Intel Corporation. All Rights Reserved.
// Copyright (c) 2018 Intel Corporation
//
// 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.

#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::spin(std::make_shared<DwaController>("DwaController"));
rclcpp::shutdown();

return 0;
Expand Down
File renamed without changes.
Empty file.
9 changes: 7 additions & 2 deletions src/mission_execution/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ endif()
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
find_package(nav2_msgs REQUIRED)

include_directories(
include
../libs/task/include
../task/include
../navigation/include
)

link_directories(${CMAKE_BINARY_DIR}/../libs)
Expand All @@ -26,10 +28,13 @@ add_executable(mission_execution
src/MissionExecution.cpp
)

target_link_libraries(mission_execution
)

ament_target_dependencies(mission_execution
rclcpp
std_msgs
task
nav2_msgs
)

install(TARGETS ${PROJECT_NAME}
Expand Down
Empty file added src/mission_execution/README.md
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Copyright (c) 2018 Intel Corporation
//
// 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 MISSION_EXECUTION__EXECUTEMISSIONTASKCLIENT_HPP_
#define MISSION_EXECUTION__EXECUTEMISSIONTASKCLIENT_HPP_

#include "task/TaskClient.hpp"
#include "mission_execution/ExecuteMissionTaskMessages.hpp"

using ExecuteMissionTaskClient = TaskClient<ExecuteMissionCommand, ExecuteMissionResult>;

#endif // MISSION_EXECUTION__EXECUTEMISSIONTASKCLIENT_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright (c) 2018 Intel Corporation
//
// 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 MISSION_EXECUTION__EXECUTEMISSIONTASKMESSAGES_HPP_
#define MISSION_EXECUTION__EXECUTEMISSIONTASKMESSAGES_HPP_

#include "nav2_msgs/msg/mission_plan.hpp"
#include "std_msgs/msg/empty.hpp"

using ExecuteMissionCommand = nav2_msgs::msg::MissionPlan;
using ExecuteMissionResult = std_msgs::msg::Empty;

#endif // MISSION_EXECUTION__EXECUTEMISSIONTASKMESSAGES_HPP_
Loading