Skip to content

Commit

Permalink
adding example action node
Browse files Browse the repository at this point in the history
  • Loading branch information
marinagmoreira committed Dec 7, 2023
1 parent a7c09ca commit e63ff36
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions astrobee/survey_manager/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ include_directories(
)


# Uncomment this when plansys merged
# # Action for move_inspect
# add_executable(move_action_node src/move_action_node.cpp)
# target_link_libraries(move_action_node ${catkin_LIBRARIES} )

#############
## Install ##
#############
Expand Down
59 changes: 59 additions & 0 deletions astrobee/survey_manager/src/move_action_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/* Copyright (c) 2021, United States Government, as represented by the
* Administrator of the National Aeronautics and Space Administration.
*
* All rights reserved.
*
* The "ISAAC - Integrated System for Autonomous and Adaptive Caretaking
* platform" software is 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 <ros/ros.h>

#include <plansys2_executor/ActionExecutorClient.hpp>

#include <string>

namespace plansys2_actions {

class MoveAction : public plansys2::ActionExecutorClient {
public:
MoveAction(ros::NodeHandle nh, const std::string& action, const std::chrono::nanoseconds& rate)
: ActionExecutorClient(nh, action, rate) {}

protected:
void do_work() {
ROS_ERROR_STREAM("Executing [MOVE]");
// std::string from, towards;
// from = get_arguments()[1];
// towards = get_arguments()[2];
}
};
} // namespace plansys2_actions


// Main entry point for application
int main(int argc, char *argv[]) {
// Initialize a ros node
ros::init(argc, argv, "move_action");
ros::NodeHandle nh(name);

// Start action node
// We could actually add multiple action nodes here being aware that we might need a ros::AsyncSpinner
// (https://github.com/Bckempa/ros2_planning_system/blob/noetic-devel/plansys2_bt_actions/src/bt_action_node.cpp#L41)
auto action_node = std::make_shared<plansys2::MoveAction>(nh, name, std::chrono_literals::1s);
action_node->trigger_transition(ros::lifecycle::CONFIGURE);

// Synchronous mode
ros::spin();
// Make for great success
return 0;

0 comments on commit e63ff36

Please sign in to comment.