<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Caioconti</id>
		<title>VeRLab Wiki - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="http://www.verlab.dcc.ufmg.br/mediawiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Caioconti"/>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php/Special:Contributions/Caioconti"/>
		<updated>2026-04-04T03:47:48Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.29.0</generator>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1452</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1452"/>
				<updated>2024-11-22T17:01:56Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* HeRo ROS Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo. To follow along, you must have ROS installed; for this tutorial, we will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/velocity_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalize_angle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalize_angle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalize_angle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities. We create a class to enable the use of subscriber data for online computation of control outputs. Alternatively, global variables could be used, but this method is less structured.&lt;br /&gt;
&lt;br /&gt;
In the main function, we simply instantiate an object of the class we defined and call its run function, where the core functionality is executed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class is initialized with key variables that are accessible throughout its methods, functioning similarly to global variables but within the scope of the class. In our case, these variables include the messages we want to send and receive, as well as the desired final position (x,y) for HeRo.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function first initializes the node, sets up a publisher to send angular and linear velocities to HeRo, and creates a subscriber to retrieve pose information from HeRo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we need HeRo's pose for control, the subscriber callback function is used to retrieve the pose data and store it in a class variable for easy access during computations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuing the &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function, we initiate the variable with the correct message type to send the velocities and set up the rate in which we will send those velocities, in our case, 5 times a second (5 Hz) will be enough.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Preparing message&lt;br /&gt;
msg = Twist()&lt;br /&gt;
&lt;br /&gt;
# Define rate&lt;br /&gt;
rate = rospy.Rate(5)   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we extract information from the &amp;lt;code&amp;gt;self.odom&amp;lt;/code&amp;gt; variable, which the subscriber updates with HeRo's pose data in real time, and store it in local variables for processing. Using these variables, we compute the velocities required to control HeRo and prepare the message to send to the publisher.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
while not rospy.is_shutdown():&lt;br /&gt;
    # Getting information&lt;br /&gt;
    x = self.odom.pose.pose.position.x&lt;br /&gt;
    y = self.odom.pose.pose.position.y&lt;br /&gt;
    w = self.odom.pose.pose.orientation.w&lt;br /&gt;
    rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
    ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
    rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
    # Computing control outputs&lt;br /&gt;
    ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
    vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
    # Preparing message&lt;br /&gt;
    msg.linear.x = vx&lt;br /&gt;
    msg.angular.z = vw&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, after defining our stop condition as reaching within 0.01 units of the goal, we publish the computed velocities in message format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Stop condition&lt;br /&gt;
    if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
        msg.linear.x = 0&lt;br /&gt;
        msg.angular.z = 0&lt;br /&gt;
        rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
    # Publish velocity&lt;br /&gt;
    self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
    rate.sleep()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, set the desired (x,y) coordinates for HeRo to achieve and run the node. Remember to &amp;lt;code&amp;gt;chmod +x tutorial_control.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial_control.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that HeRo's (x,y)=(0,0) corresponds to the position where it was powered on. It's important to note that HeRo lacks precise pose estimation by itself. Ideally, an external camera setup would be used to provide more accurate position feedback. As a result, you might observe HeRo stopping at a location that differs from the expected destination. However, according to HeRo's internal estimation, it may have reached the correct position. To verify HeRo's perception of its position, you can either use the &amp;lt;code&amp;gt;echo&amp;lt;/code&amp;gt; command on the odometry topic or run the subscriber node we created earlier.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1451</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1451"/>
				<updated>2024-11-22T03:02:37Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Create ROS Package for HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/velocity_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalize_angle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalize_angle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalize_angle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities. We create a class to enable the use of subscriber data for online computation of control outputs. Alternatively, global variables could be used, but this method is less structured.&lt;br /&gt;
&lt;br /&gt;
In the main function, we simply instantiate an object of the class we defined and call its run function, where the core functionality is executed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class is initialized with key variables that are accessible throughout its methods, functioning similarly to global variables but within the scope of the class. In our case, these variables include the messages we want to send and receive, as well as the desired final position (x,y) for HeRo.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function first initializes the node, sets up a publisher to send angular and linear velocities to HeRo, and creates a subscriber to retrieve pose information from HeRo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we need HeRo's pose for control, the subscriber callback function is used to retrieve the pose data and store it in a class variable for easy access during computations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuing the &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function, we initiate the variable with the correct message type to send the velocities and set up the rate in which we will send those velocities, in our case, 5 times a second (5 Hz) will be enough.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Preparing message&lt;br /&gt;
msg = Twist()&lt;br /&gt;
&lt;br /&gt;
# Define rate&lt;br /&gt;
rate = rospy.Rate(5)   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we extract information from the &amp;lt;code&amp;gt;self.odom&amp;lt;/code&amp;gt; variable, which the subscriber updates with HeRo's pose data in real time, and store it in local variables for processing. Using these variables, we compute the velocities required to control HeRo and prepare the message to send to the publisher.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
while not rospy.is_shutdown():&lt;br /&gt;
    # Getting information&lt;br /&gt;
    x = self.odom.pose.pose.position.x&lt;br /&gt;
    y = self.odom.pose.pose.position.y&lt;br /&gt;
    w = self.odom.pose.pose.orientation.w&lt;br /&gt;
    rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
    ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
    rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
    # Computing control outputs&lt;br /&gt;
    ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
    vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
    # Preparing message&lt;br /&gt;
    msg.linear.x = vx&lt;br /&gt;
    msg.angular.z = vw&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, after defining our stop condition as reaching within 0.01 units of the goal, we publish the computed velocities in message format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Stop condition&lt;br /&gt;
    if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
        msg.linear.x = 0&lt;br /&gt;
        msg.angular.z = 0&lt;br /&gt;
        rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
    # Publish velocity&lt;br /&gt;
    self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
    rate.sleep()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, set the desired (x,y) coordinates for HeRo to achieve and run the node. Remember to &amp;lt;code&amp;gt;chmod +x tutorial_control.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial_control.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that HeRo's (x,y)=(0,0) corresponds to the position where it was powered on. It's important to note that HeRo lacks precise pose estimation by itself. Ideally, an external camera setup would be used to provide more accurate position feedback. As a result, you might observe HeRo stopping at a location that differs from the expected destination. However, according to HeRo's internal estimation, it may have reached the correct position. To verify HeRo's perception of its position, you can either use the &amp;lt;code&amp;gt;echo&amp;lt;/code&amp;gt; command on the odometry topic or run the subscriber node we created earlier.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1450</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1450"/>
				<updated>2024-11-21T23:13:19Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalize_angle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalize_angle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalize_angle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities. We create a class to enable the use of subscriber data for online computation of control outputs. Alternatively, global variables could be used, but this method is less structured.&lt;br /&gt;
&lt;br /&gt;
In the main function, we simply instantiate an object of the class we defined and call its run function, where the core functionality is executed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class is initialized with key variables that are accessible throughout its methods, functioning similarly to global variables but within the scope of the class. In our case, these variables include the messages we want to send and receive, as well as the desired final position (x,y) for HeRo.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function first initializes the node, sets up a publisher to send angular and linear velocities to HeRo, and creates a subscriber to retrieve pose information from HeRo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we need HeRo's pose for control, the subscriber callback function is used to retrieve the pose data and store it in a class variable for easy access during computations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuing the &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function, we initiate the variable with the correct message type to send the velocities and set up the rate in which we will send those velocities, in our case, 5 times a second (5 Hz) will be enough.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Preparing message&lt;br /&gt;
msg = Twist()&lt;br /&gt;
&lt;br /&gt;
# Define rate&lt;br /&gt;
rate = rospy.Rate(5)   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we extract information from the &amp;lt;code&amp;gt;self.odom&amp;lt;/code&amp;gt; variable, which the subscriber updates with HeRo's pose data in real time, and store it in local variables for processing. Using these variables, we compute the velocities required to control HeRo and prepare the message to send to the publisher.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
while not rospy.is_shutdown():&lt;br /&gt;
    # Getting information&lt;br /&gt;
    x = self.odom.pose.pose.position.x&lt;br /&gt;
    y = self.odom.pose.pose.position.y&lt;br /&gt;
    w = self.odom.pose.pose.orientation.w&lt;br /&gt;
    rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
    ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
    rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
    # Computing control outputs&lt;br /&gt;
    ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
    vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
    # Preparing message&lt;br /&gt;
    msg.linear.x = vx&lt;br /&gt;
    msg.angular.z = vw&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, after defining our stop condition as reaching within 0.01 units of the goal, we publish the computed velocities in message format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Stop condition&lt;br /&gt;
    if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
        msg.linear.x = 0&lt;br /&gt;
        msg.angular.z = 0&lt;br /&gt;
        rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
    # Publish velocity&lt;br /&gt;
    self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
    rate.sleep()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, set the desired (x,y) coordinates for HeRo to achieve and run the node. Remember to &amp;lt;code&amp;gt;chmod +x tutorial_control.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial_control.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that HeRo's (x,y)=(0,0) corresponds to the position where it was powered on. It's important to note that HeRo lacks precise pose estimation by itself. Ideally, an external camera setup would be used to provide more accurate position feedback. As a result, you might observe HeRo stopping at a location that differs from the expected destination. However, according to HeRo's internal estimation, it may have reached the correct position. To verify HeRo's perception of its position, you can either use the &amp;lt;code&amp;gt;echo&amp;lt;/code&amp;gt; command on the odometry topic or run the subscriber node we created earlier.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1449</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1449"/>
				<updated>2024-11-21T23:11:38Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalize_angle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalize_angle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalize_angle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities. We create a class to enable the use of subscriber data for online computation of control outputs. Alternatively, global variables could be used, but this method is less structured.&lt;br /&gt;
&lt;br /&gt;
In the main function, we simply instantiate an object of the class we defined and call its run function, where the core functionality is executed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class is initialized with key variables that are accessible throughout its methods, functioning similarly to global variables but within the scope of the class. In our case, these variables include the messages we want to send and receive, as well as the desired final position (x,y) for HeRo.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function first initializes the node, sets up a publisher to send angular and linear velocities to HeRo, and creates a subscriber to retrieve pose information from HeRo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we need HeRo's pose for control, the subscriber callback function is used to retrieve the pose data and store it in a class variable for easy access during computations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuing the &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function, we initiate the variable with the correct message type to send the velocities and set up the rate in which we will send those velocities, in our case, 5 times a second (5 Hz) will be enough.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Preparing message&lt;br /&gt;
msg = Twist()&lt;br /&gt;
&lt;br /&gt;
# Define rate&lt;br /&gt;
rate = rospy.Rate(5)   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we extract information from the &amp;lt;code&amp;gt;self.odom&amp;lt;/code&amp;gt; variable, which the subscriber updates with HeRo's pose data in real time, and store it in local variables for processing. Using these variables, we compute the velocities required to control HeRo and prepare the message to send to the publisher.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
while not rospy.is_shutdown():&lt;br /&gt;
    # Getting information&lt;br /&gt;
    x = self.odom.pose.pose.position.x&lt;br /&gt;
    y = self.odom.pose.pose.position.y&lt;br /&gt;
    w = self.odom.pose.pose.orientation.w&lt;br /&gt;
    rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
    ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
    rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
    # Computing control outputs&lt;br /&gt;
    ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
    vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
    # Preparing message&lt;br /&gt;
    msg.linear.x = vx&lt;br /&gt;
    msg.angular.z = vw&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, after defining our stop condition as reaching within 0.01 units of the goal, we publish the computed velocities in message format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Stop condition&lt;br /&gt;
    if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
        msg.linear.x = 0&lt;br /&gt;
        msg.angular.z = 0&lt;br /&gt;
        rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
    # Publish velocity&lt;br /&gt;
    self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
    rate.sleep()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, set the desired (x,y) coordinates for HeRo to achieve and run the node. Remember to &amp;lt;code&amp;gt;chmod +x tutorial_control.py&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial_control.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Keep in mind that HeRo's (x,y)=(0,0) corresponds to the position where it was powered on. It's important to note that HeRo lacks precise pose estimation by itself. Ideally, an external camera setup would be used to provide more accurate position feedback. As a result, you might observe HeRo stopping at a location that differs from the expected destination. However, according to HeRo's internal estimation, it may have reached the correct position. To verify HeRo's perception of its position, you can use the &amp;lt;code&amp;gt;echo&amp;lt;/code&amp;gt; command on the odometry topic.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1448</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1448"/>
				<updated>2024-11-21T23:04:15Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalize_angle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalize_angle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalize_angle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities. We create a class to enable the use of subscriber data for online computation of control outputs. Alternatively, global variables could be used, but this method is less structured.&lt;br /&gt;
&lt;br /&gt;
In the main function, we simply instantiate an object of the class we defined and call its run function, where the core functionality is executed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class is initialized with key variables that are accessible throughout its methods, functioning similarly to global variables but within the scope of the class. In our case, these variables include the messages we want to send and receive, as well as the desired final position (x,y) for HeRo.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function first initializes the node, sets up a publisher to send angular and linear velocities to HeRo, and creates a subscriber to retrieve pose information from HeRo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we need HeRo's pose for control, the subscriber callback function is used to retrieve the pose data and store it in a class variable for easy access during computations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuing the &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function, we initiate the variable with the correct message type to send the velocities and set up the rate in which we will send those velocities, in our case, 5 times a second (5 Hz) will be enough.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Preparing message&lt;br /&gt;
msg = Twist()&lt;br /&gt;
&lt;br /&gt;
# Define rate&lt;br /&gt;
rate = rospy.Rate(5)   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Next, we extract information from the &amp;lt;code&amp;gt;self.odom&amp;lt;/code&amp;gt; variable, which the subscriber updates with HeRo's pose data in real time, and store it in local variables for processing. Using these variables, we compute the velocities required to control HeRo and prepare the message to send to the publisher.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
while not rospy.is_shutdown():&lt;br /&gt;
    # Getting information&lt;br /&gt;
    x = self.odom.pose.pose.position.x&lt;br /&gt;
    y = self.odom.pose.pose.position.y&lt;br /&gt;
    w = self.odom.pose.pose.orientation.w&lt;br /&gt;
    rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
    ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
    rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
    # Computing control outputs&lt;br /&gt;
    ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
    vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
    # Preparing message&lt;br /&gt;
    msg.linear.x = vx&lt;br /&gt;
    msg.angular.z = vw&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Finally, after defining our stop condition as reaching within 0.01 units of the goal, we publish the computed velocities in message format.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    # Stop condition&lt;br /&gt;
    if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
        msg.linear.x = 0&lt;br /&gt;
        msg.angular.z = 0&lt;br /&gt;
        rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
    # Publish velocity&lt;br /&gt;
    self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
    rate.sleep()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1447</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1447"/>
				<updated>2024-11-21T22:58:17Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalize_angle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalize_angle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalize_angle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities. We create a class to enable the use of subscriber data for online computation of control outputs. Alternatively, global variables could be used, but this method is less structured.&lt;br /&gt;
&lt;br /&gt;
In the main function, we simply instantiate an object of the class we defined and call its run function, where the core functionality is executed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class is initialized with key variables that are accessible throughout its methods, functioning similarly to global variables but within the scope of the class. In our case, these variables include the messages we want to send and receive, as well as the desired final position (x,y) for HeRo.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function first initializes the node, sets up a publisher to send angular and linear velocities to HeRo, and creates a subscriber to retrieve pose information from HeRo.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Since we need HeRo's pose for control, the subscriber callback function is used to retrieve the pose data and store it in a class variable for easy access during computations.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Continuing the &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function, we initiate the variable with the correct message type to send the velocities and set up the rate in which we will send those velocities, in our case, 5 times a second (5 Hz) will be enough.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Preparing message&lt;br /&gt;
msg = Twist()&lt;br /&gt;
&lt;br /&gt;
# Define rate&lt;br /&gt;
rate = rospy.Rate(5)   &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1446</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1446"/>
				<updated>2024-11-21T22:51:00Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalize_angle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalize_angle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalize_angle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities. We create a class to enable the use of subscriber data for online computation of control outputs. Alternatively, global variables could be used, but this method is less structured.&lt;br /&gt;
&lt;br /&gt;
In the main function, we simply instantiate an object of the class we defined and call its run function, where the core functionality is executed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class is initialized with key variables that are accessible throughout its methods, functioning similarly to global variables but within the scope of the class. In our case, these variables include the messages we want to send and receive, as well as the desired final position (x,y) for HeRo.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; function intiates the node, publisher and subscriber.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We want the subscriber to get the HeRo pose, therefore, we simply return its data to a class variable in the subscriber callback.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1445</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1445"/>
				<updated>2024-11-21T22:47:35Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalize_angle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalize_angle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalize_angle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities. We create a class to enable the use of subscriber data for online computation of control outputs. Alternatively, global variables could be used, but this method is less structured.&lt;br /&gt;
&lt;br /&gt;
In the main function, we simply instantiate an object of the class we defined and call its run function, where the core functionality is executed.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The class is initialized with key variables that are accessible throughout its methods, functioning similarly to global variables but within the scope of the class. In our case, these variables include the messages we want to send and receive, as well as the desired final position (x,y) for HeRo.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
running the &amp;lt;code&amp;gt;run&amp;lt;/run&amp;gt; function, firstly initiates&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1444</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1444"/>
				<updated>2024-11-21T22:35:39Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalize_angle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalize_angle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalize_angle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities. We create a class to enable the use of subscriber data for online computation of control outputs. Alternatively, global variables could be used, but this method is less structured.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1443</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1443"/>
				<updated>2024-11-21T22:31:22Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalizeAngle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalizeAngle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalizeAngle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The function &amp;lt;code&amp;gt;euler_from_quaternion&amp;lt;/code&amp;gt; converts quaternions into Euler angles, while &amp;lt;code&amp;gt;control&amp;lt;/code&amp;gt; is a position proportional controller that calculates linear and angular velocities.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1442</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1442"/>
				<updated>2024-11-21T22:28:04Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalizeAngle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalizeAngle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalizeAngle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        # Initiate node and create publish and subscriber&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)           &lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1441</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1441"/>
				<updated>2024-11-21T22:25:48Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Controlling HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;br /&gt;
It is also possible to implement subscribers and publishers within the same code, use the subscriber data to publish messages according with the data, we provide a control example with HeRo. The full code is below, we will break and explain step-by-step.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python3&lt;br /&gt;
import rospy&lt;br /&gt;
import numpy as np&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def normalizeAngle(angle):&lt;br /&gt;
    return np.mod(angle+np.pi, 2*np.pi) - np.pi&lt;br /&gt;
&lt;br /&gt;
def euler_from_quaternion(x, y, z, w):&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        Convert a quaternion into euler angles (roll, pitch, yaw)&lt;br /&gt;
        roll is rotation around x in radians (counterclockwise)&lt;br /&gt;
        pitch is rotation around y in radians (counterclockwise)&lt;br /&gt;
        yaw is rotation around z in radians (counterclockwise)&lt;br /&gt;
        &amp;quot;&amp;quot;&amp;quot;&lt;br /&gt;
        t0 = +2.0 * (w * x + y * z)&lt;br /&gt;
        t1 = +1.0 - 2.0 * (x * x + y * y)&lt;br /&gt;
        roll_x = np.arctan2(t0, t1)&lt;br /&gt;
     &lt;br /&gt;
        t2 = +2.0 * (w * y - z * x)&lt;br /&gt;
        t2 = +1.0 if t2 &amp;gt; +1.0 else t2&lt;br /&gt;
        t2 = -1.0 if t2 &amp;lt; -1.0 else t2&lt;br /&gt;
        pitch_y = np.arcsin(t2)&lt;br /&gt;
     &lt;br /&gt;
        t3 = +2.0 * (w * z + x * y)&lt;br /&gt;
        t4 = +1.0 - 2.0 * (y * y + z * z)&lt;br /&gt;
        yaw_z = np.arctan2(t3, t4)&lt;br /&gt;
     &lt;br /&gt;
        return roll_x, pitch_y, yaw_z # in radians&lt;br /&gt;
&lt;br /&gt;
def control(x,y,x_end,y_end,theta):&lt;br /&gt;
    maxv = 0.07&lt;br /&gt;
    maxw = 0.1&lt;br /&gt;
&lt;br /&gt;
    dx = x_end - x&lt;br /&gt;
    dy = y_end - y&lt;br /&gt;
&lt;br /&gt;
    kr = 4 / 20&lt;br /&gt;
    ka = 8 / 20&lt;br /&gt;
&lt;br /&gt;
    rho = np.sqrt(dx**2 + dy**2)&lt;br /&gt;
    alpha = normalizeAngle(-theta + np.arctan2(dy,dx))&lt;br /&gt;
    &lt;br /&gt;
    if abs(alpha) &amp;gt; np.pi/2:&lt;br /&gt;
         kr = -kr&lt;br /&gt;
         alpha = normalizeAngle(alpha - np.pi)&lt;br /&gt;
&lt;br /&gt;
    v = kr*rho&lt;br /&gt;
    w = ka*alpha&lt;br /&gt;
&lt;br /&gt;
    v = max(min(v, maxv), -maxv)&lt;br /&gt;
    w = max(min(w, maxw), -maxw)&lt;br /&gt;
&lt;br /&gt;
    return v,w&lt;br /&gt;
&lt;br /&gt;
class ControlHero(object):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
          self.cmd_vel = Twist()&lt;br /&gt;
          self.odom = Odometry()&lt;br /&gt;
          self.x_end = 0.15&lt;br /&gt;
          self.y_end = 0.00&lt;br /&gt;
&lt;br /&gt;
    def callback(self, data):&lt;br /&gt;
        self.odom = data&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        rospy.init_node('hero_control')&lt;br /&gt;
&lt;br /&gt;
        # Creating publisher and subscriber&lt;br /&gt;
        rospy.Subscriber('hero_3/odom', Odometry, self.callback)&lt;br /&gt;
        self.pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
&lt;br /&gt;
        # Preparing message&lt;br /&gt;
        msg = Twist()&lt;br /&gt;
&lt;br /&gt;
        # Define rate&lt;br /&gt;
        rate = rospy.Rate(5)           &lt;br /&gt;
&lt;br /&gt;
        while not rospy.is_shutdown():&lt;br /&gt;
            # Getting information&lt;br /&gt;
            x = self.odom.pose.pose.position.x&lt;br /&gt;
            y = self.odom.pose.pose.position.y&lt;br /&gt;
            w = self.odom.pose.pose.orientation.w&lt;br /&gt;
            rx = self.odom.pose.pose.orientation.x&lt;br /&gt;
            ry = self.odom.pose.pose.orientation.y&lt;br /&gt;
            rz = self.odom.pose.pose.orientation.z&lt;br /&gt;
&lt;br /&gt;
            # Computing control outputs&lt;br /&gt;
            ex, ey, ez = euler_from_quaternion(rx,ry,rz,w)&lt;br /&gt;
            vx, vw = control(x,y,self.x_end,self.y_end,ez)&lt;br /&gt;
&lt;br /&gt;
            # Preparing message&lt;br /&gt;
            msg.linear.x = vx&lt;br /&gt;
            msg.angular.z = vw&lt;br /&gt;
&lt;br /&gt;
            #rospy.loginfo(&amp;quot;Velocidade em x: [%s]&amp;quot;, vx)&lt;br /&gt;
            #rospy.loginfo(&amp;quot;Velocidade em angulo: [%s]&amp;quot;, vw)&lt;br /&gt;
&lt;br /&gt;
            # Stop condition&lt;br /&gt;
            if (np.linalg.norm(np.array((x,y)) - np.array((self.x_end,self.y_end)))) &amp;lt; 0.01:&lt;br /&gt;
                msg.linear.x = 0&lt;br /&gt;
                msg.angular.z = 0&lt;br /&gt;
                rospy.loginfo_once(&amp;quot;Chegou&amp;quot;)&lt;br /&gt;
                &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
            # Publish velocity&lt;br /&gt;
            self.pub.publish(msg)&lt;br /&gt;
&lt;br /&gt;
            rate.sleep&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    obj = ControlHero()&lt;br /&gt;
    obj.run()&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1440</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1440"/>
				<updated>2024-11-19T20:18:03Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Subscribing and Publishing on HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The subscriber node needs a callback function to be defined, in which, we get the pose and print it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
from nav_msgs.msg import Odometry&lt;br /&gt;
&lt;br /&gt;
def callback(msg):&lt;br /&gt;
    x = msg.pose.pose.position.x&lt;br /&gt;
    y = msg.pose.pose.position.y&lt;br /&gt;
    rz = msg.pose.pose.orientation.z&lt;br /&gt;
    message = '\nPose X: ' + str(x) + '\nPose Y: ' + str(y) + '\nRotation Z: ' + str(rz)&lt;br /&gt;
    rospy.loginfo(rospy.get_caller_id() + &amp;quot;%s&amp;quot;, message)&lt;br /&gt;
&lt;br /&gt;
def printOdom():&lt;br /&gt;
    rospy.Subscriber('hero_3/odom', Odometry, callback)&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        #rospy.login(&amp;quot;Print Pose&amp;quot;)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_sub_odometry')&lt;br /&gt;
    printOdom()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Controlling HeRo ====&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1439</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1439"/>
				<updated>2024-11-19T20:15:21Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Subscribing and Publishing on HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Subscribing and Publishing on HeRo ====&lt;br /&gt;
Now, lets get HeRo informations, specifically, the odometry. Lets create a node that subscribes and print HeRo information. The robot sends its pose information in the topic &amp;lt;code&amp;gt;/odom&amp;lt;/code&amp;gt;.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1438</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1438"/>
				<updated>2024-11-19T18:19:46Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Create ROS Package for HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Subscribing and Publishing on HeRo ==&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1437</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1437"/>
				<updated>2024-11-19T18:10:20Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Create ROS Package for HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg hero_tutorial std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/hero_tutorial&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def sendVel():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    sendVel()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, build and run the node, be careful as the HeRo will walk until you stop the node with &amp;lt;code&amp;gt;ctrl+c&amp;lt;/code&amp;gt;. Remember to source.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
rosrun hero_tutorial tutorial.py&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1436</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1436"/>
				<updated>2024-11-19T18:04:55Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Create ROS Package for HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg tutorial_hero std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/tutorial_hero&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you might need to do &amp;lt;code&amp;gt;chmod +x tutorial.py&amp;lt;/code&amp;gt;. Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the &amp;lt;code&amp;gt;vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic to send velocity commands to the robot. First, lets import rospy, create our main function and initialize our new node &amp;lt;code&amp;gt;hero_walk&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
import rospy&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, we create a new function with a publisher, to publish constantly a velocity of 0.01 in the x direction. We want to publish in the &amp;lt;code&amp;gt;/hero_i/vellocity_controller/cmd_vel&amp;lt;/code&amp;gt; topic, changing &amp;quot;i&amp;quot; with the number of your HeRo. To publish in a topic, it is needed to create the type of message expected, to see which message type the topic expects:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rostopic info /hero_i/position_controller/cmd_vel&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And to see how this type of message is structured:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;rosmsg show geometry_msgs/Twist&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can build our code, importing the correct message type and we will publish one time every second, or 1 Hz.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/usr/bin/env python&lt;br /&gt;
&lt;br /&gt;
import rospy&lt;br /&gt;
from geometry_msgs.msg import Twist&lt;br /&gt;
&lt;br /&gt;
def mandaVelocidade():&lt;br /&gt;
    pub = rospy.Publisher('hero_3/velocity_controller/cmd_vel', Twist, queue_size=1)&lt;br /&gt;
    msg = Twist()&lt;br /&gt;
    rate = rospy.Rate(1)&lt;br /&gt;
&lt;br /&gt;
    while not rospy.is_shutdown():&lt;br /&gt;
        msg.linear.x = 0.01&lt;br /&gt;
        msg.angular.z = 0.0  &lt;br /&gt;
        pub.publish(msg)&lt;br /&gt;
        rate.sleep()&lt;br /&gt;
&lt;br /&gt;
if __name__ == '__main__':&lt;br /&gt;
    rospy.init_node('hero_walk')&lt;br /&gt;
    mandaVelocidade()&lt;br /&gt;
    &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1433</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1433"/>
				<updated>2024-11-13T18:29:19Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Create ROS Package for HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg tutorial_hero std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/tutorial_hero&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you might need to do:&lt;br /&gt;
&amp;lt;pre&amp;gt;chmod +x tutorial.py&amp;lt;\pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Use rostopic list for a ideia to which topics you want to change. In our case, we want to move the robot, therefore, we will use the cmd_vel topic to send velocity commands to the robot. &lt;br /&gt;
&lt;br /&gt;
First, lets import rospy and create our main function&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1432</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1432"/>
				<updated>2024-11-13T18:18:02Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Create ROS Package for HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg tutorial_hero std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;/code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/tutorial_hero&lt;br /&gt;
mkdir scripts&lt;br /&gt;
cd scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, create a python file to start writing our node, we will call it tutorial.py, you might need to do:&lt;br /&gt;
&amp;lt;pre&amp;gt;chmod +x tutorial.py&amp;lt;\pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1431</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1431"/>
				<updated>2024-11-13T18:03:48Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* New ROS Node for HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Create ROS Package for HeRo ===&lt;br /&gt;
In this tutorial, we will create a package with one node. We will replicate the random walk, HeRo will randomly move and deviate from obstacles, already implemented in the HeRo package. The ROS main page also provides a step-by-step guide in how to create packages [http://wiki.ros.org/ROS/Tutorials/CreatingPackage Create ROS Package].&lt;br /&gt;
&lt;br /&gt;
You may want to create a new package or node for HeRo. To create a node quickly, navigate to &amp;lt;code&amp;gt;/ws_hero/src/hero_common/hero_examples/scripts/&amp;lt;/code&amp;gt;, copy an example script similar to what you want to achieve, modify it as needed, and save it with a new name. Once saved, you can call your node, and it should function properly. To keep your custom work separate from the original package, consider creating an entirely new package for your nodes. This approach keeps your workspace organized and makes it easier to manage changes independently of the original package.&lt;br /&gt;
&lt;br /&gt;
Create a new package&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src&lt;br /&gt;
catkin_create_pkg tutorial_hero std_msgs rospy roscpp&lt;br /&gt;
cd ..&lt;br /&gt;
catkin_build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Alternatively you can also create a new package inside the &amp;lt;code&amp;gt;hero_common&amp;lt;\code&amp;gt;. Those commands will create a new src folder inside your new &amp;lt;code&amp;gt;tutorial_hero&amp;lt;/code&amp;gt;, you can create your new scripts inside this folder or create a new folder called &amp;lt;code&amp;gt;scripts&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd src/tutorial_hero&lt;br /&gt;
mkdir scripts&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1430</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1430"/>
				<updated>2024-11-13T16:55:34Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* HeRo Teleoperation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== New ROS Node for HeRo ===&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1429</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1429"/>
				<updated>2024-11-13T16:54:19Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* HeRo Teleoperation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== New ROS Node for HeRo ===&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1428</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1428"/>
				<updated>2024-11-13T16:34:37Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* HeRo Teleoperation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
Once the HeRo is connected to the network, you can launch the bringup and check the list of topics to ensure everything is configured correctly.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
rostopic list&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If the topics appear as expected, you can proceed to launch teleoperation mode and begin controlling HeRo directly. Make sure to adjust the &amp;lt;code&amp;gt;id&amp;lt;/code&amp;gt; to match your HeRo’s ID.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_teleop.launch id:=0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1427</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1427"/>
				<updated>2024-11-13T16:29:46Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Connect with HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;br /&gt;
&lt;br /&gt;
=== HeRo Teleoperation ===&lt;br /&gt;
With the HeRo connected to the network. Launch the bringup and teleop to start sending velocity commands to the hero on your desk!&lt;br /&gt;
&lt;br /&gt;
&amp;lt;&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1426</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1426"/>
				<updated>2024-11-13T16:27:38Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Set up ROS Workspace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
You can exit the terminal.&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1425</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1425"/>
				<updated>2024-11-13T16:27:17Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Connect with HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it is connected to the network, otherwise it will keep blink in red.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1424</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1424"/>
				<updated>2024-11-13T16:25:35Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Connect with HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired, by default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
*** mode: access point;&lt;br /&gt;
*** band: automatic;&lt;br /&gt;
*** wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
*** ipv4 shared to other computers;&lt;br /&gt;
*** ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network'''&lt;br /&gt;
** Turn on HeRo in configuration mode: cover all sensors and flip the switch to turn it on. HeRo will blink in purple;&lt;br /&gt;
** Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss;&lt;br /&gt;
** Open in a browser 192.168.4.1 to open the HeRo configuration page;&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network;&lt;br /&gt;
** Save and turn-off HeRo.&lt;br /&gt;
&lt;br /&gt;
Now turn it on the HeRo, it should connect automatically in the network. The robot will blink blue for 2 seconds if it connected to the network, otherwise it will keep blink in red.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1423</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1423"/>
				<updated>2024-11-13T16:20:12Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Connect with HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;br /&gt;
The [https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide] on the main HeRo page provides detailed instructions on connecting your computer to the robot. We summarize the main steps below for quick reference.&lt;br /&gt;
&lt;br /&gt;
* '''Create a network Hotspot on your PC'''&lt;br /&gt;
** Set SSID and Password as desired. By default HeRo should connect in a network with SSID = rezeck, password = s3cr3tp4ss. You can adjust these setting if needed.&lt;br /&gt;
** If necessary, set these other Hotspot informations:&lt;br /&gt;
***mode: access point;&lt;br /&gt;
***band: automatic;&lt;br /&gt;
***wifi-security: WPA/WPA2 Personal - store password for all users (not encrypted);&lt;br /&gt;
***ipv4 shared to other computers;&lt;br /&gt;
***ipv6 automatic.&lt;br /&gt;
&lt;br /&gt;
* '''Configure HeRo network if needed'''&lt;br /&gt;
**Turn on HeRo in configuration mode (cover all sensors), hero will blink in purple.&lt;br /&gt;
**Connect any device to the HeRo wi-fi network, password should be s3cr3tp4ss.&lt;br /&gt;
**Open in a browser 192.168.4.1 to open the HeRo configuration page.&lt;br /&gt;
** Set the SSID and Password that you gave to your Hotspot, HeRo will try to connect to this network.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1421</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1421"/>
				<updated>2024-11-13T15:51:15Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Set up ROS Workspace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1420</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1420"/>
				<updated>2024-11-13T15:50:59Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Set up ROS Workspace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven’t configured the HeRo robot yet, it will currently search for TCP connections without successfully connecting. However, the launch process itself should still succeed. If everything was set up correctly, you should see the following output in the terminal:&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;br /&gt;
&lt;br /&gt;
===Connect with HeRo===&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1419</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1419"/>
				<updated>2024-11-13T15:48:25Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Set up ROS Workspace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven't set the HeRo, it will just search for TCP connections and we will not be able to do anything, but the launch will be succesfull. If everything was set up correctly the following result should appear in the terminal&lt;br /&gt;
[[File:first_roslaunch.png]]&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1418</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1418"/>
				<updated>2024-11-13T15:47:51Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* Set up ROS Workspace */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven't set the HeRo, it will just search for TCP connections and we will not be able to do anything, but the launch will be succesfull. If everything was set up correctly the following result should appear in the terminal&lt;br /&gt;
[[File:first_roslaunch.jpg]]&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=File:First_roslaunch.png&amp;diff=1417</id>
		<title>File:First roslaunch.png</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=File:First_roslaunch.png&amp;diff=1417"/>
				<updated>2024-11-13T15:42:28Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: Result of the first roslaunch for the HeRo Tutorial.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Result of the first roslaunch for the HeRo Tutorial.&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1416</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1416"/>
				<updated>2024-11-13T15:40:33Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* HeRo ROS Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit]. To test if the package is correctly installed, try launch the bringup:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
roslaunch hero_bringup hero_bringup.launch&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Because we haven't set the HeRo, it will just search for TCP connections and we will not be able to do anything, but the launch will be succesfull. If everything was set up correctly the following result should appear in the terminal&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1415</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1415"/>
				<updated>2024-11-13T15:26:53Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* HeRo ROS Tutorial */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
===Set up ROS Workspace===&lt;br /&gt;
Create a new ROS workspace. Notice you can use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands, choose one.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Download the package to &amp;lt;code&amp;gt;ws_hero/src&amp;lt;/code&amp;gt; and build it from source. This is common to do for installing ROS packages.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
cd ~/ws_hero/src&lt;br /&gt;
git clone https://github.com/verlab/hero_common.git&lt;br /&gt;
cd ..&lt;br /&gt;
rosdep install --from-paths src/hero_common --ignore-src -r -y&lt;br /&gt;
catkin build&lt;br /&gt;
source devel/setup.bash&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If you encounter issues in later steps, you may need to select the repository branch of your ROS distribution, see [https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]. You also may need to install [https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html the NVIDIA Container Toolkit].&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1414</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1414"/>
				<updated>2024-11-13T14:37:05Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: /* HeRo */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
&lt;br /&gt;
== HeRo ROS Tutorial ==&lt;br /&gt;
In this tutorial, we will create a new script to navigate the HeRo and utilize its sensors to avoid obstacles. To follow along, you must have ROS installed; for this tutorial, I will be using ROS Noetic.&lt;br /&gt;
&lt;br /&gt;
The HeRo main page already has excellent tutorials for setting up the HeRo. You can follow the steps here:&lt;br /&gt;
*[https://verlab.github.io/hero_common/installation/ HeRo Installation Guide]&lt;br /&gt;
*[https://verlab.github.io/hero_common/ros/ HeRo ROS Setup Guide]&lt;br /&gt;
&lt;br /&gt;
Alternatively, you can follow this tutorial, which will focus primarily on the ROS setup and development aspects. For the purposes of this tutorial, we will configure HeRo as we would with any other ROS package&lt;br /&gt;
&lt;br /&gt;
Step 1:&lt;br /&gt;
Create a new ROS workspace. Notice ones could use &amp;lt;code&amp;gt;catkin build&amp;lt;/code&amp;gt; or &amp;lt;code&amp;gt;catkin_make&amp;lt;/code&amp;gt; commands.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
mkdir -p ~ ws_hero/src&lt;br /&gt;
cd ws_hero&lt;br /&gt;
catkin build&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1239</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1239"/>
				<updated>2023-09-05T16:05:42Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
Main Page:&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;br /&gt;
&lt;br /&gt;
GitHub:&lt;br /&gt;
https://github.com/verlab/hero_common/&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	<entry>
		<id>http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1238</id>
		<title>HeRo</title>
		<link rel="alternate" type="text/html" href="http://www.verlab.dcc.ufmg.br/mediawiki/index.php?title=HeRo&amp;diff=1238"/>
				<updated>2023-09-05T16:02:27Z</updated>
		
		<summary type="html">&lt;p&gt;Caioconti: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== HeRo ==&lt;br /&gt;
This project contributes to an open source ROS-based framework for swarm robotics. We propose an low cost, high availability swarm system that could be printed and assembled multiple times without special knowledge or hardware skills. &lt;br /&gt;
&lt;br /&gt;
[[File:Hero.png|300px]]&lt;br /&gt;
&lt;br /&gt;
For more details: &lt;br /&gt;
https://github.com/verlab/hero_common/&lt;br /&gt;
https://verlab.github.io/hero_common/ros/&lt;/div&gt;</summary>
		<author><name>Caioconti</name></author>	</entry>

	</feed>