-
Notifications
You must be signed in to change notification settings - Fork 8
Workshop 2 ‐ Introspecting your robot
The goal of this workshop is to make you familiar with the LIMO robot platform, which will be used throughout all remaining workshop sessions. Moreover, you will start using ROS tools for inspecting your robot sensor data, and you will write a simple controller for navigating your robot around.
If you are not familiar yet, please refer to Workshop 1 to start your robot and establish a connection to it.
-
Inspect the robot's nodes and topics by using the
ros2 nodeandros2 topiccommands (in a new terminal). When you type the command without any additional arguments, you should see all available options. Display and compare the format of the following topics/odom,/scan,/tfand/camera/color/image_raw. You might want to also refer to the official node and topic tutorials. -
Now, let us use the graphical visualiser RVIZ to look at the robot and its sensor topics. Start by typing
rviz2 -d /opt/ros/lcas/install/limo_description/share/limo_description/model_sensors_real.rvizwhich uses a pre-defined configuration file, and you should see the interface with a robot model and its sensor data displayed in the robot's touch screen (and your VNC screen too!). To get familiar with the interface, adjust the laser scan visualisation options and see how these affect the output. Try to add new visualisation for sensors not included in the provided configuration (e.g. odometry).
-
Teleoperation. Leave the RVIZ running. In a new terminal, start the keyboard teleoperation node
ros2 run teleop_twist_keyboard teleop_twist_keyboardand drive the robot around using the keyboard. Have fun, but pay attention to other robots and your human fellows, though!
-
Let's now send some basic robot control commands using ROS topics. The robot's speed can be controlled by the
/cmd_veltopic. Use theros2 topic pubfunctionality to send a singleTwistmessage (linear and angular velocity command) as in this example:ros2 topic pub --once /cmd_vel geometry_msgs/msg/Twist "{linear: {x: 0.0, y: 0.0, z: 0.0}, angular: {x: 0.0, y: 0.0, z: 0.5}}"Now, adjust the linear components of the
Twistmessage and see the resulting trajectory. -
Using your knowledge of the topic publishing, issue a series of commands that will drive the robot:
- in a circle with a radius of 0.5 m;
- in a 1 m square.
Try using as few commands as possible.
You can control your LIMO robot autonomously by writing a small controller in Python that publishes velocity commands on a dedicated topic. To do so, you can modify the publisher.py script seen during the lecture in order to reflect the command used at point 4) of the Section #2 above.
In order to do so, remember you need to change the topic on which to publish from topic to cmd_vel, the published message from String to geometry_msgs/msg/Twist and correctly populate the message's fields.
import rclpy
from rclpy.node import Node
from std_msgs.msg import String
class MinimalPublisher(Node):
def __init__(self):
super().__init__('minimal_publisher')
self.publisher_ = self.create_publisher(String, 'topic', 10)
timer_period = 0.5 # seconds
self.timer = self.create_timer(timer_period, self.timer_callback)
self.i = 0
def timer_callback(self):
msg = String()
msg.data = 'Hello World: %d' % self.i
self.publisher_.publish(msg)
self.get_logger().info('Publishing: "%s"' % msg.data)
self.i += 1
def main(args=None):
rclpy.init(args=args)
minimal_publisher = MinimalPublisher()
rclpy.spin(minimal_publisher)
# Destroy the node explicitly
# (optional - otherwise it will be done automatically
# when the garbage collector destroys the node object)
minimal_publisher.destroy_node()
rclpy.shutdown()
if __name__ == '__main__':
main()For the time being, since we don't have our own ROS package, save your move_circle.py file in the src folder of your workspace, and then run it as a simple Python script python3 move_circle.py.