|
| 1 | +# Copyright 2022 The Regents of the University of California (Regents) |
| 2 | +# |
| 3 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# you may not use this file except in compliance with the License. |
| 5 | +# You may obtain a copy of the License at |
| 6 | +# |
| 7 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +# |
| 9 | +# Unless required by applicable law or agreed to in writing, software |
| 10 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +# See the License for the specific language governing permissions and |
| 13 | +# limitations under the License. |
| 14 | +# |
| 15 | +# Copyright ©2022. The Regents of the University of California (Regents). |
| 16 | +# All Rights Reserved. Permission to use, copy, modify, and distribute this |
| 17 | +# software and its documentation for educational, research, and not-for-profit |
| 18 | +# purposes, without fee and without a signed licensing agreement, is hereby |
| 19 | +# granted, provided that the above copyright notice, this paragraph and the |
| 20 | +# following two paragraphs appear in all copies, modifications, and |
| 21 | +# distributions. Contact The Office of Technology Licensing, UC Berkeley, 2150 |
| 22 | +# Shattuck Avenue, Suite 510, Berkeley, CA 94720-1620, (510) 643-7201, |
| 23 | +# [email protected], http://ipira.berkeley.edu/industry-info for commercial |
| 24 | +# licensing opportunities. IN NO EVENT SHALL REGENTS BE LIABLE TO ANY PARTY |
| 25 | +# FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, |
| 26 | +# INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS |
| 27 | +# DOCUMENTATION, EVEN IF REGENTS HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH |
| 28 | +# DAMAGE. REGENTS SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT |
| 29 | +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A |
| 30 | +# PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF ANY, |
| 31 | +# PROVIDED HEREUNDER IS PROVIDED "AS IS". REGENTS HAS NO OBLIGATION TO PROVIDE |
| 32 | +# MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 33 | + |
| 34 | +from launch_ros.actions import Node |
| 35 | +import fogros2 |
| 36 | +from utils import region_ami_selection, ec2_instance_type_selection |
| 37 | + |
| 38 | + |
| 39 | +def generic_ubuntu_ami(): |
| 40 | + return { |
| 41 | + "us-west-1": { "ami_image": "ami-01154c8b2e9a14885" }, |
| 42 | + "us-west-2": { "ami_image": "ami-0ddf424f81ddb0720" }, |
| 43 | + "us-east-1": { "ami_image": "ami-08d4ac5b634553e16" }, |
| 44 | + "us-east-2": { "ami_image": "ami-0960ab670c8bb45f3" }, |
| 45 | + } |
| 46 | + |
| 47 | +def generate_launch_description(): |
| 48 | + """Talker example that launches the listener on AWS.""" |
| 49 | + ld = fogros2.FogROSLaunchDescription() |
| 50 | + |
| 51 | + region, ami = region_ami_selection.find_nearest_region_and_ami(generic_ubuntu_ami()) |
| 52 | + |
| 53 | + ec2_instance_type = ec2_instance_type_selection.find_cheapest_ec2_instance_type(region) |
| 54 | + |
| 55 | + print(region, ami, ec2_instance_type) |
| 56 | + machine1 = fogros2.AWSCloudInstance( |
| 57 | + region=region, ec2_instance_type=ec2_instance_type, ami_image=ami |
| 58 | + ) |
| 59 | + |
| 60 | + listener_node = Node( |
| 61 | + package="fogros2_examples", executable="listener", output="screen" |
| 62 | + ) |
| 63 | + |
| 64 | + talker_node = fogros2.CloudNode( |
| 65 | + package="fogros2_examples", |
| 66 | + executable="talker", |
| 67 | + output="screen", |
| 68 | + machine=machine1, |
| 69 | + ) |
| 70 | + ld.add_action(talker_node) |
| 71 | + ld.add_action(listener_node) |
| 72 | + return ld |
0 commit comments