5 from compliance
import Sensor_Compliance
6 from compliance
import Thruster_Compliance
8 from .. utils
import create_xacro_file
9 from .. utils
import add_gazebo_thruster_config
14 rospy.init_node(
"wamv_generator", anonymous=
True)
16 received_thruster_yaml = len(rospy.get_param(
'thruster_yaml')) > 0
17 received_sensor_yaml = len(rospy.get_param(
'sensor_yaml')) > 0
20 if received_thruster_yaml:
24 if received_sensor_yaml:
28 wamv_target = rospy.get_param(
'wamv_target')
29 wamv_gazebo = rospy.get_param(
'wamv_gazebo')
31 create_urdf_command = (
"rosrun xacro xacro --inorder -o " + wamv_target +
32 " '" + wamv_gazebo +
"'")
35 if received_thruster_yaml:
36 yaml =
'thruster_yaml' 38 create_urdf_command += (
" yaml_thruster_generation:=true " 39 "thruster_xacro_file:=" +
40 thruster_xacro_target)
41 if received_sensor_yaml:
44 create_urdf_command += (
" yaml_sensor_generation:=true " 45 "sensor_xacro_file:=" + sensor_xacro_target)
48 os.system(create_urdf_command)
49 if not (thruster_compliant
and sensor_compliant):
50 rospy.logerr(
'\nThis sensor/thruster configuration is NOT compliant ' +
51 'with the (current) VRX constraints. A urdf file will ' +
52 'be created, but please note that the above errors ' +
53 'must be fixed for this to be a valid configuration ' +
54 'for the VRX competition.\n')
56 print(
'WAM-V urdf file sucessfully generated. File location: ' +
61 Purpose: Create a thruster xacro file using the given 65 thruster_yaml = rospy.get_param(
'thruster_yaml')
66 rospy.loginfo(
'\nUsing %s as the thruster configuration yaml file\n' %
73 thruster_boiler_plate_top = (
'<?xml version="1.0"?>\n' 75 'xmlns:xacro="http://ros.org/wiki/xacro" ' 76 'name="wam-v-thrusters">\n' 77 ' <xacro:include filename=' 78 '"$(find wamv_description)/urdf/thrusters/' 82 thruster_boiler_plate_bot =
'' 85 comp = Thruster_Compliance()
86 thruster_num_test = comp.number_compliance
87 thruster_param_test = comp.param_compliance
91 xacro_target=thruster_xacro_target,
92 boiler_plate_top=thruster_boiler_plate_top,
93 boiler_plate_bot=thruster_boiler_plate_bot,
94 num_test=thruster_num_test,
95 param_test=thruster_param_test)
97 gz_boiler_plate_top = (
' <gazebo>\n' 98 ' <plugin name="wamv_gazebo_thrust" ' 99 'filename="libusv_gazebo_thrust_plugin.so">\n' 100 ' <cmdTimeout>1.0</cmdTimeout>\n' 101 ' <robotNamespace>${namespace}</robotNamespace>\n' 102 ' <xacro:include filename="$(find wamv_gazebo)' 103 '/urdf/thruster_layouts/' 104 'wamv_gazebo_thruster_config.xacro" />\n')
105 gz_boiler_plate_bot = (
' </plugin>\n' 111 xacro_target=thruster_xacro_target,
112 boiler_plate_top=gz_boiler_plate_top,
113 boiler_plate_bot=gz_boiler_plate_bot,
120 Purpose: Create a sensor xacro file using the given 124 sensor_yaml = rospy.get_param(
'sensor_yaml')
125 rospy.loginfo(
'\nUsing %s as the sensor configuration yaml file\n' %
132 sensor_boiler_plate_top = (
'<?xml version="1.0"?>\n' 134 'xmlns:xacro="http://ros.org/wiki/xacro" ' 135 'name="wam-v-sensors">\n' +
136 ' <xacro:macro name="yaml_sensors">\n')
139 sensor_boiler_plate_bot =
' </xacro:macro>\n</robot>' 142 comp = Sensor_Compliance()
143 sensor_num_test = comp.number_compliance
144 sensor_param_test = comp.param_compliance
148 xacro_target=sensor_xacro_target,
149 boiler_plate_top=sensor_boiler_plate_top,
150 boiler_plate_bot=sensor_boiler_plate_bot,
151 num_test=sensor_num_test,
152 param_test=sensor_param_test)
156 return string[0:string.index(
'.')] +
'.xacro'
def add_gazebo_thruster_config(xacro_target, yaml_file=None, requested_macros=None, boiler_plate_top='', boiler_plate_bot='')