Skip to content

Commit

Permalink
converted to typer, for a more cli solution
Browse files Browse the repository at this point in the history
  • Loading branch information
keithmk authored and keithmk committed Jan 29, 2024
1 parent f5e5a08 commit 93fd1c6
Show file tree
Hide file tree
Showing 5 changed files with 525 additions and 0 deletions.
11 changes: 11 additions & 0 deletions mil_common/utils/mil_tools/scripts/preflight/Tests/RunTests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import importlib


def getHardWareCheckist(robotName):
robotName += ".hardware"
module = importlib.import_module(robotName)

if hasattr(module, "hardwareTests"):
return module.hardwareTests
else:
return []
93 changes: 93 additions & 0 deletions mil_common/utils/mil_tools/scripts/preflight/Tests/TestLib.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import rospy
import rosservice
import rostopic


class Test:
# Constructor
def __init__(self, name, description, communicationType, address):
self.name = name
self.description = description
self.communicationType = communicationType
self.address = address
self.needsHumanAuthorization = False

# Check if the communication interface is up and running
def isActive(self):
# Check if the topic is up
if self.communicationType == "Topic":
topicType, topicStr, _ = rostopic.get_topic_class(
self.address,
) # get topic class
try:
rospy.wait_for_message(
topicStr,
topicType,
) # try to get a message from that topic
return True
except Exception:
return False

# Check if the service is up
if self.communicationType == "Service":
return rosservice.waitForService(
self.address,
) # Wait for the service to be up

# Check if the action server is up
if self.communicationType == "Action":
# action client
topicType, topicStr, _ = rostopic.get_topic_class(
self.address + "/feedback",
)
try:
# Wait for a message from the topic
rospy.wait_for_message(topicStr, topicType)
return True
except Exception:
return False

# Send data over the communication interface and pass in the return values into the check function
def VerifyData(self, args, checkFunction):
result = ""

if self.communicationType == "Topic":
# Get the class of the topic
topicType, topicStr, _ = rostopic.get_topic_class(self.address)
try:
# Get a message from the topic
result = rospy.wait_for_message(topicStr, topicType)
except Exception:
return False

if self.communicationType == "Service":
try:
# Get a message form the service
result = rosservice.call_service(self.address, args)
except Exception:
return False

if self.communicationType == "Action":
# Get the class of the topic, remember an action will publish its results to a topic with /goal at the end
topicType, topicStr, _ = rostopic.get_topic_class(
self.address + "/feedback",
)
try:
# Wait for a message from the topic
result = rospy.wait_for_message(topicStr, topicType)
except Exception:
return False

return checkFunction(args, result)

def runCommand(self, args):
# use a dictionary
if self.communicationType == "Topic":
topicType, topicStr, _ = rostopic.get_topic_class(self.address)
if self.communicationType == "Service":
# Do something
self
if self.communicationType == "Action":
# Do something
self
return False
2 changes: 2 additions & 0 deletions scripts/SubChecklist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dvl
odom
165 changes: 165 additions & 0 deletions services.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/adaptive_controller/get_loggers
/adaptive_controller/set_logger_level
/adaptive_controller/set_parameters
/alarm/get
/alarm/set
/alarm_sever/get_loggers
/alarm_sever/set_logger_level
/b_matrix
/c3_trajectory_generator/get_loggers
/c3_trajectory_generator/set_logger_level
/camera/down/down_image_proc/get_loggers
/camera/down/down_image_proc/set_logger_level
/camera/down/down_image_proc_debayer/set_parameters
/camera/down/down_image_proc_rectify_color/set_parameters
/camera/down/down_image_proc_rectify_mono/set_parameters
/camera/down/image_color/compressed/set_parameters
/camera/down/image_color/compressedDepth/set_parameters
/camera/down/image_color/theora/set_parameters
/camera/down/image_mono/compressed/set_parameters
/camera/down/image_mono/compressedDepth/set_parameters
/camera/down/image_mono/theora/set_parameters
/camera/down/image_raw/compressed/set_parameters
/camera/down/image_raw/compressedDepth/set_parameters
/camera/down/image_raw/theora/set_parameters
/camera/down/image_rect/compressed/set_parameters
/camera/down/image_rect/compressedDepth/set_parameters
/camera/down/image_rect/theora/set_parameters
/camera/down/image_rect_color/compressed/set_parameters
/camera/down/image_rect_color/compressedDepth/set_parameters
/camera/down/image_rect_color/theora/set_parameters
/camera/down/set_camera_info
/camera/down/set_parameters
/camera/front/camera_nodelet_manager/get_loggers
/camera/front/camera_nodelet_manager/list
/camera/front/camera_nodelet_manager/load_nodelet
/camera/front/camera_nodelet_manager/set_logger_level
/camera/front/camera_nodelet_manager/unload_nodelet
/camera/front/left/image_color/compressed/set_parameters
/camera/front/left/image_color/compressedDepth/set_parameters
/camera/front/left/image_color/theora/set_parameters
/camera/front/left/image_mono/compressed/set_parameters
/camera/front/left/image_mono/compressedDepth/set_parameters
/camera/front/left/image_mono/theora/set_parameters
/camera/front/left/image_raw/compressed/set_parameters
/camera/front/left/image_raw/compressedDepth/set_parameters
/camera/front/left/image_raw/theora/set_parameters
/camera/front/left/image_rect/compressed/set_parameters
/camera/front/left/image_rect/compressedDepth/set_parameters
/camera/front/left/image_rect/theora/set_parameters
/camera/front/left/image_rect_color/compressed/set_parameters
/camera/front/left/image_rect_color/compressedDepth/set_parameters
/camera/front/left/image_rect_color/theora/set_parameters
/camera/front/left/seecam_image_proc/get_loggers
/camera/front/left/seecam_image_proc/set_logger_level
/camera/front/left/seecam_image_proc_debayer/set_parameters
/camera/front/left/seecam_image_proc_rectify_color/set_parameters
/camera/front/left/seecam_image_proc_rectify_mono/set_parameters
/camera/front/left/set_camera_info
/camera/front/left/set_parameters
/camera/front/right/image_color/compressed/set_parameters
/camera/front/right/image_color/compressedDepth/set_parameters
/camera/front/right/image_color/theora/set_parameters
/camera/front/right/image_mono/compressed/set_parameters
/camera/front/right/image_mono/compressedDepth/set_parameters
/camera/front/right/image_mono/theora/set_parameters
/camera/front/right/image_raw/compressed/set_parameters
/camera/front/right/image_raw/compressedDepth/set_parameters
/camera/front/right/image_raw/theora/set_parameters
/camera/front/right/image_rect/compressed/set_parameters
/camera/front/right/image_rect/compressedDepth/set_parameters
/camera/front/right/image_rect/theora/set_parameters
/camera/front/right/image_rect_color/compressed/set_parameters
/camera/front/right/image_rect_color/compressedDepth/set_parameters
/camera/front/right/image_rect_color/theora/set_parameters
/camera/front/right/set_camera_info
/camera/front/right/set_parameters
/camera/front/right_image_proc_debayer/get_loggers
/camera/front/right_image_proc_debayer/set_logger_level
/camera/front/right_image_proc_debayer/set_parameters
/camera/front/right_image_proc_rect/get_loggers
/camera/front/right_image_proc_rect/set_logger_level
/camera/front/right_image_proc_rect/set_parameters
/camera/front/right_image_proc_rect_color/get_loggers
/camera/front/right_image_proc_rect_color/set_logger_level
/camera/front/right_image_proc_rect_color/set_parameters
/gazebo/apply_body_wrench
/gazebo/apply_joint_effort
/gazebo/clear_body_wrenches
/gazebo/clear_joint_forces
/gazebo/delete_light
/gazebo/delete_model
/gazebo/get_joint_properties
/gazebo/get_light_properties
/gazebo/get_link_properties
/gazebo/get_link_state
/gazebo/get_loggers
/gazebo/get_model_properties
/gazebo/get_model_state
/gazebo/get_physics_properties
/gazebo/get_world_properties
/gazebo/pause_physics
/gazebo/reset_simulation
/gazebo/reset_world
/gazebo/set_joint_properties
/gazebo/set_light_properties
/gazebo/set_link_properties
/gazebo/set_link_state
/gazebo/set_logger_level
/gazebo/set_model_configuration
/gazebo/set_model_state
/gazebo/set_parameters
/gazebo/set_physics_properties
/gazebo/spawn_sdf_model
/gazebo/spawn_urdf_model
/gazebo/unpause_physics
/hydrophones/hydrophones_visualization/get_loggers
/hydrophones/hydrophones_visualization/set_logger_level
/hydrophones/ping_locator/cross_correlation_debug_enable
/hydrophones/ping_locator/enable
/hydrophones/ping_locator/get_loggers
/hydrophones/ping_locator/samples_debug_enable
/hydrophones/ping_locator/set_logger_level
/hydrophones/triggering/enable
/hydrophones/triggering/filter_debug_enable
/hydrophones/triggering/filter_debug_trigger
/hydrophones/triggering/get_loggers
/hydrophones/triggering/reset
/hydrophones/triggering/sample_at_trigger_debug_enable
/hydrophones/triggering/set_logger_level
/hydrophones/triggering/trigger_debug_enable
/magnetometer_vis/get_loggers
/magnetometer_vis/set_logger_level
/mission_runner/get_loggers
/mission_runner/refresh_missions
/mission_runner/set_logger_level
/odom_estimator/get_loggers
/odom_estimator/set_ignore_magnetometer
/odom_estimator/set_logger_level
/odometry_to_tf/get_loggers
/odometry_to_tf/set_logger_level
/poi_server/add
/poi_server/delete
/poi_server/get_loggers
/poi_server/move
/poi_server/save_to_param
/poi_server/set_logger_level
/poi_server/tf2_frames
/robot_state_publisher/get_loggers
/robot_state_publisher/set_logger_level
/rosout/get_loggers
/rosout/set_logger_level
/set_mobo_kill
/set_valve
/simulate_go
/simulate_hard_kill
/simulate_soft_kill
/tf_republisher/get_loggers
/tf_republisher/set_logger_level
/thruster_mapper/get_loggers
/thruster_mapper/set_logger_level
/transform_odometry/get_loggers
/transform_odometry/set_logger_level
/update_thruster_layout
/usb_to_can_driver/get_loggers
/usb_to_can_driver/set_logger_level
Loading

0 comments on commit 93fd1c6

Please sign in to comment.