Skip to content
Open
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
38 changes: 38 additions & 0 deletions autorun/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.8)
project(autorun)

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

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(std_msgs REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

add_executable(autorunner src/autorunner.cpp)
ament_target_dependencies(autorunner rclcpp std_msgs)
target_include_directories(autorunner PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_features(autorunner PUBLIC c_std_99 cxx_std_17) # Require C99 and C++17

install(TARGETS autorunner
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
set(ament_cmake_cpplint_FOUND TRUE)
ament_lint_auto_find_test_dependencies()
endif()

ament_package()
20 changes: 20 additions & 0 deletions autorun/package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?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>autorun</name>
<version>0.0.0</version>
<description>TODO: Package description</description>
<maintainer email="[email protected]">victor</maintainer>
<license>TODO: License declaration</license>
<depend>rclcpp</depend>
<depend>std_msgs</depend>

<buildtool_depend>ament_cmake</buildtool_depend>

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

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
72 changes: 72 additions & 0 deletions autorun/src/autorunner.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
#include <cstdio>
#include <unistd.h>
#include <functional>
#include <memory>

#include "rclcpp/rclcpp.hpp"

#include "std_msgs/msg/empty.hpp"

class Autorunner : public rclcpp::Node
{
public:
Autorunner()
: Node("autorunner")
{
init_pub = this->create_publisher<std_msgs::msg::Empty>("/atos/init", 10);
connect_pub = this->create_publisher<std_msgs::msg::Empty>("/atos/connect", 10);
arm_pub = this->create_publisher<std_msgs::msg::Empty>("/atos/arm", 10);
start_pub = this->create_publisher<std_msgs::msg::Empty>("/atos/start", 10);
abort_pub = this->create_publisher<std_msgs::msg::Empty>("/atos/abort", 10);
all_clear_pub = this->create_publisher<std_msgs::msg::Empty>("/atos/all_clear", 10);
run_experiment(20);
}

private:
rclcpp::Publisher<std_msgs::msg::Empty>::SharedPtr init_pub;
rclcpp::Publisher<std_msgs::msg::Empty>::SharedPtr connect_pub;
rclcpp::Publisher<std_msgs::msg::Empty>::SharedPtr arm_pub;
rclcpp::Publisher<std_msgs::msg::Empty>::SharedPtr start_pub;
rclcpp::Publisher<std_msgs::msg::Empty>::SharedPtr abort_pub;
rclcpp::Publisher<std_msgs::msg::Empty>::SharedPtr all_clear_pub;
void run_experiment(int n)
{
RCLCPP_INFO(this->get_logger(), "Running %d experiments", n);
std_msgs::msg::Empty message;
RCLCPP_INFO(this->get_logger(), "Sending init to ATOS");
init_pub->publish(message);
sleep(1);
init_pub->publish(message);
sleep(2);
RCLCPP_INFO(this->get_logger(), "Sending connect to ATOS");
connect_pub->publish(message);
sleep(2);

while (n > 0)
{
RCLCPP_INFO(this->get_logger(), "Experiment %d", n);
RCLCPP_INFO(this->get_logger(), "Sending arm to ATOS");
arm_pub->publish(message);
sleep(2);
RCLCPP_INFO(this->get_logger(), "Sending start to ATOS");
start_pub->publish(message);
sleep(35);
RCLCPP_INFO(this->get_logger(), "Sending abort to ATOS");
abort_pub->publish(message);
sleep(2);
RCLCPP_INFO(this->get_logger(), "Sending all_clear to ATOS");
all_clear_pub->publish(message);
sleep(2);
n--;
}
}
};


int main(int argc, char ** argv)
{
rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<Autorunner>());
rclcpp::shutdown();
return 0;
}
Loading