()
| 75 | var rosDefinitions = {}; |
| 76 | |
| 77 | function generateROSDefinitions() { |
| 78 | // order for ROS definitions is significant, so generate all ROS definitions as one |
| 79 | var code = `rospy.init_node('flight')\n\n`; |
| 80 | if (rosDefinitions.offboard) { |
| 81 | code += `get_telemetry = rospy.ServiceProxy('get_telemetry', srv.GetTelemetry)\n`; |
| 82 | code += `navigate = rospy.ServiceProxy('navigate', srv.Navigate)\n`; |
| 83 | if (rosDefinitions.navigateGlobal) { |
| 84 | code += `navigate_global = rospy.ServiceProxy('navigate_global', srv.NavigateGlobal)\n`; |
| 85 | } |
| 86 | if (rosDefinitions.setYaw) { |
| 87 | code += `set_yaw = rospy.ServiceProxy('set_yaw', srv.SetYaw)\n`; |
| 88 | } |
| 89 | if (rosDefinitions.setVelocity) { |
| 90 | code += `set_velocity = rospy.ServiceProxy('set_velocity', srv.SetVelocity)\n`; |
| 91 | } |
| 92 | if (rosDefinitions.setAttitude) { |
| 93 | code += `set_attitude = rospy.ServiceProxy('set_attitude', srv.SetAttitude)\n`; |
| 94 | } |
| 95 | if (rosDefinitions.setRates) { |
| 96 | code += `set_rates = rospy.ServiceProxy('set_rates', srv.SetRates)\n`; |
| 97 | } |
| 98 | code += `land = rospy.ServiceProxy('land', Trigger)\n`; |
| 99 | } |
| 100 | if (rosDefinitions.setEffect) { |
| 101 | Blockly.Python.definitions_['import_led_effect'] = 'from clover.srv import SetLEDEffect'; |
| 102 | code += `set_effect = rospy.ServiceProxy('led/set_effect', SetLEDEffect, persistent=True)\n`; |
| 103 | } |
| 104 | if (rosDefinitions.setLeds) { |
| 105 | Blockly.Python.definitions_['import_set_led'] = 'from led_msgs.srv import SetLEDs\nfrom led_msgs.msg import LEDState'; |
| 106 | code += `set_leds = rospy.ServiceProxy('led/set_leds', SetLEDs, persistent=True)\n`; |
| 107 | } |
| 108 | if (rosDefinitions.ledStateArray) { |
| 109 | Blockly.Python.definitions_['import_led_state_array'] = 'from led_msgs.msg import LEDStateArray'; |
| 110 | } |
| 111 | if (rosDefinitions.navigateWait) { |
| 112 | Blockly.Python.definitions_['import_math'] = 'import math'; |
| 113 | code += NAVIGATE_WAIT(); |
| 114 | } |
| 115 | if (rosDefinitions.navigateGlobalWait) { |
| 116 | Blockly.Python.definitions_['import_math'] = 'import math'; |
| 117 | code += NAVIGATE_GLOBAL_WAIT(); |
| 118 | } |
| 119 | if (rosDefinitions.landWait) { |
| 120 | code += LAND_WAIT(); |
| 121 | } |
| 122 | if (rosDefinitions.waitArrival) { |
| 123 | Blockly.Python.definitions_['import_math'] = 'import math'; |
| 124 | code += WAIT_ARRIVAL(); |
| 125 | } |
| 126 | if (rosDefinitions.arrived) { |
| 127 | Blockly.Python.definitions_['import_math'] = 'import math'; |
| 128 | code += ARRIVED(); |
| 129 | } |
| 130 | if (rosDefinitions.waitYaw) { |
| 131 | Blockly.Python.definitions_['import_math'] = 'import math'; |
| 132 | code += WAIT_YAW(); |
| 133 | } |
| 134 | if (rosDefinitions.distance) { |
no test coverage detected