Skip to content

Commit

Permalink
Minor fixes + cleanup (#119)
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-labs authored Jul 25, 2024
1 parent bbd5978 commit 0bc403e
Show file tree
Hide file tree
Showing 19 changed files with 43 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: test-build
on:
pull_request:
branches: [main]
branches: [main, humble, jazzy]
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
2 changes: 1 addition & 1 deletion deb_requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ ros-humble-py-trees-ros-interfaces
ros-humble-py-trees
python3-autopep8
clang-format
pylint
pylint
6 changes: 3 additions & 3 deletions examples/example_multi_robot/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<author email="[email protected]">Intel Labs</author>
<maintainer email="[email protected]">Intel Labs</maintainer>
<license file="../../LICENSE">Apache-2.0</license>

<exec_depend>rclpy</exec_depend>
<exec_depend>scenario_execution_gazebo</exec_depend>
<exec_depend>gazebo_static_camera</exec_depend>
Expand All @@ -17,8 +17,8 @@
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>python3-pytest</test_depend>

<export>
<build_type>ament_python</build_type>
</export>
</package>
</package>
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
class ScenarioBatchExecution(object):

def __init__(self, args) -> None:
self.ignore_process_return_value = args.ignore_process_return_value
if not os.path.isdir(args.output_dir):
try:
os.mkdir(args.output_dir)
Expand Down Expand Up @@ -139,7 +140,10 @@ def configure_logger(log_file_path):
file_handler.flush()
file_handler.close()
xml_ret = self.combine_test_xml()
return xml_ret and ret
if self.ignore_process_return_value:
return xml_ret
else:
return xml_ret and ret

def combine_test_xml(self):
print(f"### Writing combined tests to '{self.output_dir}/test.xml'.....")
Expand Down Expand Up @@ -198,6 +202,8 @@ def main():
parser = argparse.ArgumentParser()
parser.add_argument('-i', '--scenario-dir', type=str, help='Directory containing the scenarios')
parser.add_argument('-o', '--output-dir', type=str, help='Directory containing the output', default='out')
parser.add_argument('-r', '--ignore-process-return-value', action='store_true',
help='Should a non-zero return value of the executed process result in a failure?')
parser.add_argument('launch_command', nargs='+')
args = parser.parse_args(sys.argv[1:])

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

class TfCloseTo(BaseAction):
"""
class for distance condition in ROS Gazebo simulation
class for distance condition
"""

def __init__(
Expand Down Expand Up @@ -121,20 +121,20 @@ def update(self) -> py_trees.common.Status:
"""
robot_pose, success = self.get_robot_pose_from_tf()
if not success:
self.feedback_message = f"the pose of {self.namespace} could not be retrieved from tf" # pylint: disable= attribute-defined-outside-init
self.feedback_message = f"the pose of {self.robot_frame_id} could not be retrieved from tf" # pylint: disable= attribute-defined-outside-init
return Status.RUNNING
dist = self.euclidean_dist(robot_pose.pose.position)
marker = self.marker_handler.get_marker(self.marker_id)
self.success = dist <= self.threshold
if self.success:
self.feedback_message = f"{self.namespace} reached point." # pylint: disable= attribute-defined-outside-init
self.feedback_message = f"{self.robot_frame_id} reached point." # pylint: disable= attribute-defined-outside-init
marker.color.r = 0.0
marker.color.g = 1.0
marker.color.b = 0.0
self.marker_handler.update_marker(self.marker_id, marker)
return Status.SUCCESS
else:
self.feedback_message = f"{self.namespace} has not reached point (distance={dist-self.threshold:.2f})" # pylint: disable= attribute-defined-outside-init
self.feedback_message = f"{self.robot_frame_id} has not reached point (distance={dist-self.threshold:.2f})" # pylint: disable= attribute-defined-outside-init
marker.color.r = 1.0
marker.color.g = 1.0
marker.color.b = 0.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ action differential_drive_robot.nav_to_pose:

action differential_drive_robot.odometry_distance_traveled:
# Wait until a defined distance was traveled, based on odometry
namespace_override: string = '' # if set, it's used as namespace (instead of the associated actor's name)
distance: length # traveled distance at which the action succeeds.
namespace_override: string = '' # if set, it's used as namespace (instead of the associated actor's name)

action differential_drive_robot.tf_close_to:
# Wait until a TF frame is close to a defined reference point
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@ scenario test_ros_service_call:
keep(it.service_name == '/bla')
keep(it.service_type == 'std_srvs.srv.SetBool')
keep(it.data == '{\"data\": True}')
wait elapsed(2s)
emit_arrival: emit end
emit end
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,34 @@ scenario test_ros_service_call_blocking:
keep(it.service_name == '/bla_service')
keep(it.service_type == 'std_srvs.srv.SetBool')
keep(it.data == '{\"data\": True}')
wait elapsed(10s)
emit end
test2: serial:
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 0}')
wait elapsed(1s)
wait elapsed(2s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 1}')
wait elapsed(1s)
wait elapsed(2s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 2}')
wait elapsed(1s)
wait elapsed(2s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 3}')
wait elapsed(1s)
wait elapsed(2s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 4}')
wait elapsed(1s)
wait elapsed(2s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 5}')
wait elapsed(1s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 6}')
wait elapsed(1s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 7}')
wait elapsed(1s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 8}')
wait elapsed(1s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 9}')
wait elapsed(1s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 10}')
wait elapsed(1s)
topic_publish() with:
keep(it.topic_name == '/bla')
keep(it.topic_type == 'std_msgs.msg.Int32')
keep(it.value == '{\"data\": 11}')
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,3 @@ scenario test_ros_set_node_parameter:
keep(it.node_name == '/test_node')
keep(it.parameter_name == 'testBoolParam')
keep(it.parameter_value == 'True')
wait elapsed(3s)
2 changes: 1 addition & 1 deletion scenario_execution_ros/test/test_assert_lifecycle_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
import time


class TestScenarioExectionSuccess(unittest.TestCase):
class TestAssertLifecycle(unittest.TestCase):
# pylint: disable=missing-function-docstring

def setUp(self) -> None:
Expand Down
18 changes: 10 additions & 8 deletions scenario_execution_ros/test/test_assert_tf_moving.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,19 @@
import tf2_ros


class TestScenarioExecutionSuccess(unittest.TestCase):
class TestAssertTfMoving(unittest.TestCase):

def setUp(self) -> None:
rclpy.init()
self.running = True
self.parser = OpenScenario2Parser(Logger('test', False))
self.scenario_execution_ros = ROSScenarioExecution()
self.node = rclpy.create_node('test_node')
self.tf_broadcaster = tf2_ros.StaticTransformBroadcaster(self.node)
self.timer = self.node.create_timer(0.1, self.publish_tf)
self.timer = self.node.create_timer(0.1, self.publish_static_tf)
self.timer = self.node.create_timer(0.1, self.publish_rotate_tf)
self.static_tf_broadcaster = tf2_ros.StaticTransformBroadcaster(self.node)
self.tf_broadcaster = tf2_ros.TransformBroadcaster(self.node)
self.timer_tf = self.node.create_timer(0.1, self.publish_tf)
self.timer_static_tf = self.node.create_timer(0.1, self.publish_static_tf)
self.timer_rotate_tf = self.node.create_timer(0.1, self.publish_rotate_tf)
self.time = 0.0
self.executor = rclpy.executors.MultiThreadedExecutor()
self.executor.add_node(self.node)
Expand All @@ -58,6 +59,7 @@ def execute(self, scenario_content):
self.scenario_execution_ros.run()

def publish_static_tf(self):
self.node.destroy_timer(self.timer_static_tf)
static_transform_stamped = TransformStamped()
static_transform_stamped.header.stamp = self.node.get_clock().now().to_msg()
static_transform_stamped.header.frame_id = 'map'
Expand All @@ -69,7 +71,7 @@ def publish_static_tf(self):
static_transform_stamped.transform.rotation.y = 0.0
static_transform_stamped.transform.rotation.z = 0.0
static_transform_stamped.transform.rotation.w = 1.0
self.tf_broadcaster.sendTransform(static_transform_stamped)
self.static_tf_broadcaster.sendTransform(static_transform_stamped)

def publish_tf(self):
self.time += 0.1
Expand Down Expand Up @@ -167,10 +169,10 @@ def test_case_2(self):
serial:
assert_tf_moving(
frame_id: 'robot_moving',
timeout: 1s)
timeout: 2s)
emit fail
time_out: serial:
wait elapsed(2s)
wait elapsed(4s)
emit end
"""
self.execute(scenario_content)
Expand Down
2 changes: 1 addition & 1 deletion scenario_execution_ros/test/test_assert_topic_latency.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from antlr4.InputStream import InputStream


class TestScenarioExectionSuccess(unittest.TestCase):
class TestAssertTopicLatency(unittest.TestCase):
# pylint: disable=missing-function-docstring

def setUp(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion scenario_execution_ros/test/test_ros_action_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
os.environ["PYTHONUNBUFFERED"] = '1'


class TestScenarioExectionSuccess(unittest.TestCase):
class TestRosActionCall(unittest.TestCase):
# pylint: disable=missing-function-docstring

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion scenario_execution_ros/test/test_ros_log_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
os.environ["PYTHONUNBUFFERED"] = '1'


class TestScenarioExectionSuccess(unittest.TestCase):
class TestRosLogCheck(unittest.TestCase):
# pylint: disable=missing-function-docstring

def setUp(self):
Expand Down
2 changes: 1 addition & 1 deletion scenario_execution_ros/test/test_ros_publish_receive.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from antlr4.InputStream import InputStream


class TestScenarioExectionSuccess(unittest.TestCase):
class TestRosPublishReceive(unittest.TestCase):
# pylint: disable=missing-function-docstring

def setUp(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion scenario_execution_ros/test/test_ros_service_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
os.environ["PYTHONUNBUFFERED"] = '1'


class TestScenarioExectionSuccess(unittest.TestCase):
class TestRosServiceCall(unittest.TestCase):
# pylint: disable=missing-function-docstring

def setUp(self):
Expand Down
6 changes: 3 additions & 3 deletions scenario_execution_ros/test/test_ros_service_call_blocking.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
os.environ["PYTHONUNBUFFERED"] = '1'


class TestScenarioExectionSuccess(unittest.TestCase):
class TestRosServiceCallBlocking(unittest.TestCase):
# pylint: disable=missing-function-docstring

def setUp(self):
Expand Down Expand Up @@ -85,6 +85,6 @@ def test_success(self):
for elem in self.received_msgs[1:]:
self.assertGreater(elem[1].data, prev_elem[1].data)
time_since_last = elem[0]-prev_elem[0]
self.assertGreaterEqual(time_since_last, rclpy.duration.Duration(seconds=0.5))
self.assertLessEqual(time_since_last, rclpy.duration.Duration(seconds=1.7))
self.assertGreaterEqual(time_since_last, rclpy.duration.Duration(seconds=1.0))
self.assertLessEqual(time_since_last, rclpy.duration.Duration(seconds=3.0))
prev_elem = elem
2 changes: 1 addition & 1 deletion scenario_execution_rviz/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.3)
cmake_minimum_required(VERSION 3.5)
project(scenario_execution_rviz)

set(CXX_STANDARD_REQUIRED ON)
Expand Down
2 changes: 0 additions & 2 deletions simulation/gazebo/tb4_sim_scenario/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ endif()
# find dependencies
find_package(ament_cmake REQUIRED)

find_package(ros_ign_interfaces REQUIRED)

install(
DIRECTORY config launch params worlds urdf
DESTINATION share/${PROJECT_NAME}
Expand Down

0 comments on commit 0bc403e

Please sign in to comment.