From af2c42c6b10b15f43ff9908265d2cb13ec3f000e Mon Sep 17 00:00:00 2001 From: Mike Danielczuk Date: Thu, 5 May 2022 13:26:19 -0700 Subject: [PATCH] initial turtlesim example (hugo) --- README.md | 21 +++++++++++++- fogros2_examples/launch/turtlesim.launch.py | 31 +++++++++++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 fogros2_examples/launch/turtlesim.launch.py diff --git a/README.md b/README.md index 28ff754..a484162 100644 --- a/README.md +++ b/README.md @@ -175,7 +175,6 @@ ros2 fog delete -a Here are several commands that one may find it useful when developing: ```bash - # starting the second terminal for fogros docker docker exec -it $(docker ps | grep fogros2 | awk '{print $1}') /bin/bash ``` @@ -228,5 +227,25 @@ docker run --net=host --env RMW_IMPLEMENTATION=rmw_cyclonedds_cpp --env CYCLONED ``` in ros workspace. +#### To run turtlesim +``` +ros2 launch fogros2_examples turtlesim.launch.py +``` +Open port 8080 on the ec2 instance's public IPv4 address from the ec2 console to access [FoxGlove Studio](https://foxglove.dev/) and open a connection to rosbridge on port 9090 of the ec2 instance's address. + + + +Select the Plot panel and the Teleop panel. + + + +In the Teleop panel, configure the publish topic to /turtle/cmd_vel. + +In the Plot panel, add /turtle1/pose.x and /turtle1/pose.y as the custom values to plot on the x-axis and y-axis, respectively. + +Use the Teleop panel to navigate the turtle around. The plot's values should change as the turtle’s position changes. + + + #### TODO - Streamline the launch process for client docker images. diff --git a/fogros2_examples/launch/turtlesim.launch.py b/fogros2_examples/launch/turtlesim.launch.py new file mode 100644 index 0000000..7dd9c41 --- /dev/null +++ b/fogros2_examples/launch/turtlesim.launch.py @@ -0,0 +1,31 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from launch import FogROSLaunchDescription +from launch_ros.actions import Node +import fogros2 + +def generate_launch_description(): + ld = FogROSLaunchDescription() + machine1 = fogros2.AWS(region="us-west-1", ec2_instance_type="t2.medium", ami_image="ami-09175f2ca3c3dc67c", launch_foxglove=True) + talker_node = Node( + package="fogros2_examples", executable="listener", output="screen") + listener_node = fogros2.CloudNode( + package="fogros2_examples", executable="talker", output="screen", + machine = machine1) + turtlesim_node = Node( + package="turtlesim", executable="turtlesim_node", output="screen") + + ld.add_action(talker_node) + ld.add_action(listener_node) + ld.add_action(turtlesim_node) + return ld