Link ROS release: cloud theme visualization and logging support the translation of ROS1Melodic and ROS2Dashing

Posted by oocuz on Wed, 09 Mar 2022 11:40:59 +0100

More and more ROS contents are mixed in the cloud and fully support ROS2. The following suggestions are made on the ROS official website:

For projects that support ROS1 and ROS2, when is it appropriate to move the default branch of GitHub from ROS1 to ROS2. Considering that Noetic will be released soon and the last version of ROS1 will be released soon, now is a good time to consider migrating all default behaviors to ROS2. This is not only for practical reasons, because most new development may be carried out in ROS2, but also to highlight the great work done by early friends in moving packages to ROS2. Releasing the default branch as an LTS distribution of ROS2 is a signal that this project can work in ROS2. If many projects do this, they will think it is a sport, and that is the case. Therefore, it is suggested that for all ros - * warehouses or larger projects, instead of changing the default branch from melody devel - > noetic devel to FOXY devel, it is better to migrate them to FOXY devel. For some time, I've asked all my non ros - * projects to do this, but now it seems that it's time for foxy to migrate all projects to foxy.

About naming:

As the release date of ROS 2 fox Fitzroy is getting closer, it is necessary to start brainstorming the release name of ROS 2 G turtle.

Existing ROS 2 name and code:

  • Ardent Apalone - ardent
  • Bouncy Bolson - bouncy
  • Crystal Clemmys - crystal
  • Dashing Diademata - dashing LTS recommended study
  • Eloquent Elusor - eloquent
  • Foxy Fitzroy - foxy LTS coming soon

Existing ROS 1 name and code:

  • Boxturtle - boxturtle
  • C Turtle - cturtle
  • Diamondback - diamondback
  • Electric Emys - electric
  • Fuerte - fuerte
  • Groovy Galapagos - groovy
  • Hydro Medusa - hydro
  • Indigo Igloo - indigo LTS
  • Jade Turtle - jade
  • Kinetic Kame - kinetic LTS
  • Lunar Loggerhead - lunar
  • Melodic Morenia - melodic LTS recommended Learning
  • Noetic Ninjemys - noetic LTS coming soon

ROS2 is suitable for business, and many charging items are great!!! For example:

Link ROS, which can be connected through any network anywhere in the world (firewall, mobile phone connection, WiFI, login screen,...) View data from ROS and tools to control the robot. Just launched on Product Hunt, using the promotion code PRODUCTHUNT, give a robot free of charge for one year.

Previously, when working as a large 11DOF cleaning service robot, I worked in places with poor WiFi connection. Experience the kind of sitting next to the on-site robot, holding the screen, keyboard and mouse inserted on the robot, trying to reproduce the BUG that has occurred several times. How difficult it is to know first-hand information.

  • Get a stable ssh connection and even set it up, especially at the deployment site.
  • Get the right data in your packet, share it with another computer, and visualize it.
  • When your robot has problems, remotely control your robot.

I have seen these problems solved again and again, but few people can solve them correctly. The goal is to solve this problem once and for all. Support ROS out of the box and single line installation. Have all the data. There is a front-end application, but do the API first, so you can also hang your application on it.

  • Installation document - single line installation
  • Log settings document - monitoring tutorial
  • Bandwidth adjustment - adjust to low-speed connection or Gigabit Ethernet operation

ROS connection

ROS 1 and 2 need zero code!

Now that you have installed the agent, the ROS Shadow node opens every time you run ROS and start uploading data to Freedom.

ROS 1 and ROS 2

Freedom supports both ROS 1 and ROS 2. When installing the agent on the device, open the ADVANCED menu and select the appropriate ROS version before running the installation script.

If you want to use the startup script, play the ROS package or run the ROS node, you don't need to do anything else. Your data will automatically start uploading to the cloud! Here, we'll show you more about how it works with a minimal example.

No ROS?

If you want to test the example of ROS and do not have ROS installed (or use Mac), run the following command to access the free dock amusement park: docker run -it frdmrobotics/playground bash. You need apt get install nano (or your favorite editor).

Start uploading data

Freedom automatically rotates a node (named link_ros) to reflect on topics published using ROS. Launch some content and start publishing for inspection - ROS bags can also work!

The data will be displayed in the STREAM In the Freedom App of the dashboard.

ROS2:

# Launch your own nodes and the Agent will automatically
# start a node (link_ros) that listens to what is published.
# Make sure to source your ROS workspace before launching. 

ros2 launch my_package my_launch.launch

ROS2 Bag:

# Not many good quality ROS2 bags exist yet - here we show a
# workaround with a ROS1 bag run in ROS2

# Make sure you have installed ros2 bag packages
apt-get update
sudo apt-get install ros-dashing-ros2bag-* ros-dashing-rosbag2*

# Source ROS1 workspace first
source /opt/ros/melodic/setup.bash

# Now source ROS2 workspace
source /opt/ros/dashing/setup.bash

# Download a ROS bag to play, saving it as rosbag-example.bag
curl -L -o rosbag-example.bag https://bit.ly/freedom-rosbag-example-car

# Play the ROS bag and the Agent will listen to the topics it publishes
ros2 bag play -s rosbag_v2 rosbag-example.bag

Send and receive messages

We will use an example to demonstrate how ROS nodes can send messages to Freedom and respond to commands sent from Freedom API.

Set a node

Create a file named demo_node.py and copy the following code.

ROS2:

#!/usr/bin/env python

# Please note that there are no references to Freedom in this ROS node.
# The ROS Shadow node will automatically interact with this node and 
# stream the data.

import time
import rclpy
import rclpy.logging
from std_msgs.msg import String
from sensor_msgs.msg import NavSatFix

logger = rclpy.logging.get_logger('node_logger')

# Create a callback to handle this topic
def callback(data):
    logger.info("I heard {}".format(data.data))
    if data.data == "mission":
        logger.info("Running mission...")
    elif data.data == "shutdown":
        logger.info("Received shutdown command")
        rclpy.shutdown()
        
# There is nothing you need to do. The ROS Shadow node        
# will automatically start when this starts
if __name__ == '__main__':
    rclpy.init()

    node = rclpy.create_node('node_name')

    subscription = node.create_subscription(String, 'commands', callback, 10)

    # Create our satellite GPS location topic
    pub_nav = node.create_publisher(NavSatFix, 'location', 10)
    nav_msg = NavSatFix(latitude=37.778454, longitude=-122.389171)

    rclpy.spin(node)

    while rclpy.ok():
        pub_nav.publish(nav_msg)
        time.sleep(1)

    # Destroy the node explicitly
    # (optional - otherwise it will be done automatically
    # when the garbage collector destroys the node object)
    node.destroy_node()
    rclpy.shutdown()

Start the node using the following command.

# Source ROS2 workspace
source /opt/ros/dashing/setup.bash

# Execute created script with python3 (mandatory for ROS2)
python3 demo_node.py

Your robot is now reporting its position and waiting patiently for remote commands! You can STREAM View its location on the map of the dashboard.

This example is designed to show you the basics of connecting with Freedom using ROS. In general, you should build an ROS package, compile it with Catkin or Colcon, and use ros2 run or ros2 launch instead of running the ROS node independently as described above.

Test callback

To check whether the callback is valid, we will use Freedom's REST API Send commands to your device.

First, select the DEVICE in Freedom App, and then navigate to SETTINGS → DEVICE. In the interface section, select ROS (for ROS1) or ROS2.

Next, if you are not already logged in, click "login" in the upper right corner of this page so that in this example, we can fill in the values of your token, password, account and device. After logging in, run the following command:

ROS2:

TOKEN="MY_TOKEN"
SECRET="MY_SECRET"
ACCOUNT="MY_ACCOUNT"
DEVICE="MY_DEVICE"
HEADERS="-H content-type:application/json -H mc_token:$TOKEN -H mc_secret:$SECRET"
DATA="[{
    \"platform\": \"ros\", 
    \"utc_time\": `date +%s`,
    \"topic\": \"/commands\",
    \"type\": \"std_msgs/msg/String\",
    \"expiration_secs\": 10,
    \"message\": {\"data\":\"mission\"}
}]"

curl -v $HEADERS -d "$DATA" -X PUT "https://api.freedomrobotics.ai/accounts/$ACCOUNT/devices/$DEVICE/commands"

The message will be received in the callback you set. Once your robot receives this command, it will log Running mission.

Change the mission to shutdown and send a new command. Your application will now shut down remotely.

success! You now know how to use Freedom to upload data through the cloud and communicate with your robot.