-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial development of ROS 2 release
- Loading branch information
Showing
155 changed files
with
2,927 additions
and
1,269 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
cmake_minimum_required(VERSION 3.0.2) | ||
cmake_minimum_required(VERSION 3.5) | ||
project(flexbe_behavior_engine) | ||
find_package(catkin REQUIRED) | ||
catkin_metapackage() | ||
|
||
# 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) | ||
|
||
ament_package() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[flake8] | ||
exclude = .git | ||
max-line-length = 119 |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#!/usr/bin/env python | ||
from rclpy.exceptions import ParameterNotDeclaredException | ||
from flexbe_core.proxy import ProxyPublisher, ProxySubscriberCached | ||
|
||
from flexbe_core.core.state import State | ||
from flexbe_core.logger import Logger | ||
from flexbe_core.state_logger import StateLogger | ||
|
||
|
||
class RosState(State): | ||
""" | ||
A state to interface with ROS. | ||
""" | ||
_node = None | ||
_breakpoints = [] | ||
|
||
@staticmethod | ||
def initialize_ros(node): | ||
RosState._node = node | ||
try: | ||
RosState._breakpoints = node.get_parameter('breakpoints') | ||
except ParameterNotDeclaredException as e: | ||
node.declare_parameter('breakpoints', []) | ||
RosState._breakpoints = node.get_parameter('breakpoints') | ||
# RosState._breakpoints = node.declare_parameter('breakpoints', []) | ||
ProxyPublisher._initialize(RosState._node) | ||
ProxySubscriberCached._initialize(RosState._node) | ||
StateLogger.initialize_ros(RosState._node) | ||
Logger.initialize(RosState._node) | ||
|
||
def __init__(self, *args, **kwargs): | ||
super(RosState, self).__init__(*args, **kwargs) | ||
self._rate = RosState._node.create_rate(10) | ||
self._is_controlled = False | ||
|
||
self._pub = ProxyPublisher() | ||
self._sub = ProxySubscriberCached() | ||
|
||
def sleep(self): | ||
self._rate.sleep() | ||
|
||
@property | ||
def sleep_duration(self): | ||
return self._rate._timer.timer_period_ns | ||
|
||
def set_rate(self, rate): | ||
""" | ||
Set the execution rate of this state, | ||
i.e., the rate with which the execute method is being called. | ||
Note: The rate is best-effort, real-time support is not yet available. | ||
@type label: float | ||
@param label: The desired rate in Hz. | ||
""" | ||
self._rate.destroy() | ||
self._rate = RosState._node.create_rate(rate) | ||
|
||
def _enable_ros_control(self): | ||
self._is_controlled = True | ||
|
||
def _disable_ros_control(self): | ||
self._is_controlled = False | ||
|
||
@property | ||
def is_breakpoint(self): | ||
return self.path in RosState._breakpoints.get_parameter_value().string_array_value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.