Skip to content
Closed
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
34 changes: 33 additions & 1 deletion ros2_control_demo_communication_headless/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,30 @@ endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(ros2_control_core REQUIRED)

## COMPILE
add_library(${PROJECT_NAME} SHARED
src/demo_robot_headless.cpp
)

target_include_directories(${PROJECT_NAME}
PRIVATE include
)

ament_target_dependencies(${PROJECT_NAME}
pluginlib
rclcpp
ros2_control_core
)

pluginlib_export_plugin_description_file(ros2_control_core ros2_control_demo_communication_headless.xml)

# INSTALL
install(TARGETS ${PROJECT_NAME}
DESTINATION lib
)

install(DIRECTORY include/
DESTINATION include)
Expand All @@ -26,6 +50,14 @@ if(BUILD_TESTING)

endif()

## EXPORTS
ament_export_dependencies(
pluginlib
rclcpp
ros2_control_core
)
ament_export_libraries(${PROJECT_NAME})
ament_export_include_directories(include)
ament_export_include_directories(
include
)
ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Copyright 2020 ROS2-Control Development Team
//
// 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 ROS2_CONTROL_DEMO_COMMUNICATION__DEMO_ROBOT_HEADLESS_HPP_
#define ROS2_CONTROL_DEMO_COMMUNICATION__DEMO_ROBOT_HEADLESS_HPP_

#include "rclcpp/rate.hpp"
#include "rclcpp/rclcpp.hpp"
#include "ros2_control_core/communication_interface/hardware_communication_interface.hpp"
#include "ros2_control_core/ros2_control_types.h"
#include "ros2_control_demo_communication_headless/visibility_control.h"


namespace ros2_control_demo_communication_headless
{
class DemoRobotHeadless : public ros2_control_core_communication_interface::HardwareCommunicationInterface
{
public:
RCLCPP_SHARED_PTR_DEFINITIONS(DemoRobotHeadless);

ROS2_CONTROL_DEMO_COMMUNICATION_HEADLESS_PUBLIC DemoRobotHeadless() = default;

ROS2_CONTROL_DEMO_COMMUNICATION_HEADLESS_PUBLIC virtual ~DemoRobotHeadless() = default;

ROS2_CONTROL_DEMO_COMMUNICATION_HEADLESS_PUBLIC ros2_control_types::return_type configure(const std::string parameters_path, const rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logging_interface, const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr parameters_interface, const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr services_interface);

ROS2_CONTROL_DEMO_COMMUNICATION_HEADLESS_PUBLIC ros2_control_types::return_type init();

protected:
};

} // namespace ros2_control_core_components

#endif // ROS2_CONTROL_DEMO_COMMUNICATION__DEMO_ROBOT_HEADLESS_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<library path="ros2_control_demo_communication_headless">
<class name="ros2_control_communicaiton_interface/DemoRobotCommunicationHeadless" type="ros2_control_demo_communication_headless::DemoRobotHeadless" base_class_type="ros2_control_core_communication_interface::HardwareCommunicationInterface">
<description>
The ROS2 Control communication interface for headless demo robot.
</description>
</class>
</library>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2020 ROS2-Control Development Team
//
// 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 "ros2_control_demo_communication_headless/demo_robot_headless.hpp"

using namespace ros2_control_demo_communication_headless;

ros2_control_types::return_type DemoRobotHeadless::configure(const std::string parameters_path, const rclcpp::node_interfaces::NodeLoggingInterface::SharedPtr logging_interface, const rclcpp::node_interfaces::NodeParametersInterface::SharedPtr parameters_interface, const rclcpp::node_interfaces::NodeServicesInterface::SharedPtr services_interface)
{
ros2_control_types::return_type ret;
ret = HardwareCommunicationInterface::configure(parameters_path, logging_interface, parameters_interface, services_interface);

RCLCPP_INFO(logging_interface_->get_logger(), "Configuring DemoRobotHeadless communication ...");

return ret;
}

ros2_control_types::return_type DemoRobotHeadless::init()
{
RCLCPP_INFO(logging_interface_->get_logger(), "Initalizing DemoRobotHeadless communication ...please wait...");

for (int i=0; i < 2; i++)
{
rclcpp::sleep_for(std::chrono::milliseconds(1*1000/2));
RCLCPP_INFO(logging_interface_->get_logger(), "%f seconds left...", 1-(i/2.0));
}

RCLCPP_INFO(logging_interface_->get_logger(), "DemoRobotHeadless communication sucessfully initalized!");

return ros2_control_types::ROS2C_RETURN_OK;
}

#include "pluginlib/class_list_macros.hpp"

PLUGINLIB_EXPORT_CLASS(
ros2_control_demo_communication_headless::DemoRobotHeadless, ros2_control_core_communication_interface::HardwareCommunicationInterface)
35 changes: 34 additions & 1 deletion ros2_control_demo_hardware/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,31 @@ endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(ros2_control_core REQUIRED)

## COMPILE
add_library(${PROJECT_NAME} SHARED
src/demo_robot_hardware_headless.cpp
src/demo_robot_hardware_minimal.cpp
)

target_include_directories(${PROJECT_NAME}
PRIVATE include
)

ament_target_dependencies(${PROJECT_NAME}
pluginlib
rclcpp
ros2_control_core
)

pluginlib_export_plugin_description_file(ros2_control_hardware ros2_control_demo_hardware_headless.xml)

# INSTALL
install(TARGETS ${PROJECT_NAME}
DESTINATION lib
)

install(DIRECTORY include/
DESTINATION include)
Expand All @@ -26,6 +51,14 @@ if(BUILD_TESTING)

endif()

## EXPORTS
ament_export_dependencies(
pluginlib
rclcpp
ros2_control_core
)
ament_export_libraries(${PROJECT_NAME})
ament_export_include_directories(include)
ament_export_include_directories(
include
)
ament_package()
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2020 ROS2-Control Development Team
//
// 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 ROS2_CONTROL_DEMO_HARDWARE__DEMO_ROBOT_HARDWARE_HEADLESS_HPP_
#define ROS2_CONTROL_DEMO_HARDWARE__DEMO_ROBOT_HARDWARE_HEADLESS_HPP_

#include "rclcpp/rate.hpp"
#include "rclcpp/rclcpp.hpp"
#include "ros2_control_core/hardware/robot_hardware.hpp"
#include "ros2_control_demo_hardware/visibility_control.h"


namespace ros2_control_demo_hardware_headless
{
class DemoRobotHardwareHeadless : public ros2_control_core_hardware::RobotHardware
{
public:
ROS2_CONTROL_DEMO_HARDWARE_PUBLIC DemoRobotHardwareHeadless() = default;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC ~DemoRobotHardwareHeadless() = default;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC ros2_control_types::return_type init_hardware();

protected:
};

} // namespace ros2_control_core_components

#endif // ROS2_CONTROL_DEMO_HARDWARE__DEMO_ROBOT_HARDWARE_HEADLESS_HPP_
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2020 ROS2-Control Development Team
//
// 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 ROS2_CONTROL_DEMO_HARDWARE__DEMO_ROBOT_HARDWARE_MINIMAL_HPP_
#define ROS2_CONTROL_DEMO_HARDWARE__DEMO_ROBOT_HARDWARE_MINIMAL_HPP_

#include "rclcpp/rclcpp.hpp"
#include "ros2_control_core/hardware/robot_hardware.hpp"
#include "ros2_control_demo_hardware/visibility_control.h"


namespace ros2_control_demo_hardware_minimal
{
class DemoRobotHardwareMinimal : public ros2_control_core_hardware::RobotHardware
{
public:
ROS2_CONTROL_DEMO_HARDWARE_PUBLIC DemoRobotHardwareMinimal() = default;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC ~DemoRobotHardwareMinimal() = default;

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC ros2_control_types::return_type init_hardware();

ROS2_CONTROL_DEMO_HARDWARE_PUBLIC ros2_control_types::return_type write();

protected:
};

} // namespace ros2_control_core_components

#endif // ROS2_CONTROL_DEMO_HARDWARE__DEMO_ROBOT_HARDWARE_MINIMAL_HPP_
12 changes: 12 additions & 0 deletions ros2_control_demo_hardware/ros2_control_demo_hardware_headless.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<library path="ros2_control_demo_hardware">
<class name="ros2_control_demo_hardware/DemoRobotHardwareHeadless" type="ros2_control_demo_hardware_headless::DemoRobotHardwareHeadless" base_class_type="ros2_control_core_hardware::RobotHardware">
<description>
The ROS2 Control robot protocol for headless demo robot.
</description>
</class>
<class name="ros2_control_demo_hardware/DemoRobotHardwareMinimal" type="ros2_control_demo_hardware_minimal::DemoRobotHardwareMinimal" base_class_type="ros2_control_core_hardware::RobotHardware">
<description>
The ROS2 Control minimal robot protocol. This is example for start porting the robot from ROS 1.
</description>
</class>
</library>
38 changes: 38 additions & 0 deletions ros2_control_demo_hardware/src/demo_robot_hardware_headless.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2020 ROS2-Control Development Team
//
// 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 "ros2_control_demo_hardware/demo_robot_hardware_headless.hpp"

using namespace ros2_control_demo_hardware_headless;

ros2_control_types::return_type DemoRobotHardwareHeadless::init_hardware()
{
RCLCPP_INFO(logging_interface_->get_logger(), "Initalizing DemoRobotHardwareHeadless ...please wait...");

for (int i=0; i < 3; i++)
{
rclcpp::sleep_for(std::chrono::seconds(1));
RCLCPP_INFO(logging_interface_->get_logger(), "%d seconds left...", 3-i);
}

RCLCPP_INFO(logging_interface_->get_logger(), "DemoRobotHardwareHeadless sucessfully initalized!");

return ros2_control_types::ROS2C_RETURN_OK;
}

#include "pluginlib/class_list_macros.hpp"

PLUGINLIB_EXPORT_CLASS(
ros2_control_demo_hardware_headless::DemoRobotHardwareHeadless, ros2_control_core_hardware::RobotHardware)
38 changes: 38 additions & 0 deletions ros2_control_demo_hardware/src/demo_robot_hardware_minimal.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2020 ROS2-Control Development Team
//
// 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 "ros2_control_demo_hardware/demo_robot_hardware_minimal.hpp"

using namespace ros2_control_demo_hardware_minimal;

ros2_control_types::return_type DemoRobotHardwareMinimal::init_hardware()
{
RCLCPP_INFO(logging_interface_->get_logger(), "Initalizing DemoRobotHardwareMinimal ...please wait...");

for (int i=0; i < 3; i++)
{
rclcpp::sleep_for(std::chrono::seconds(1));
RCLCPP_INFO(logging_interface_->get_logger(), "%d seconds left...", 3-i);
}

RCLCPP_INFO(logging_interface_->get_logger(), "DemoRobotHardwareMinimal sucessfully initalized!");

return ros2_control_types::ROS2C_RETURN_OK;
}

#include "pluginlib/class_list_macros.hpp"

PLUGINLIB_EXPORT_CLASS(
ros2_control_demo_hardware_minimal::DemoRobotHardwareMinimal, ros2_control_core_hardware::RobotHardware)
Loading