Multiple Robot Simulation in Gazebo Using ROS2 and ROS2 Control

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in most of the common raws examples there is only one robot used but in some use cases robots are interacting or cooperating with each other so being able to simulate several robots using raws and raws 2 controls should be useful in this tutorial we will do a simulation using multiple robots here I will describe several tricks that should be implemented in order to do this let's see the code download the multiple robots zip file and extracted to the home directory in this project we have two packages in the robot control package we calculate and publish velocities for each joint of each robot the robot simulation package consists of two packages the robot description package in which robot configuration related files are stored and robot gazebo package in which we have multiple launch files and the world file for gazebo simulation the program begins from the main launch XML file in this line we are launching our gazebo world to launch a gazebo world we are using the start World launch P script every python launch file must provide a function within the module called generate launch description this function is called after loading the module to get a single launch description class from it in this function firstly we are reading the share directory of the packages this operation can easily be done by using the get package share directory function of the AMT index python Library get package prefix return the installation prefix directory of the given package in these lines we are setting gazebo model path this is required not only for gazebo to be able to find model path but also to load controllers properly include launch description is an action that includes a launch description source and yields its entities when visited python launch description Source encapsulates a python launch file which can be loaded during launch launch description argument describes launch able system the description is expressed by a collection of entities which represent system Architects intentions the description may also have arguments which are declared by declare launch argument note that declaring a launch argument has to be in a part of the launch description that is describable without launching the procedure of using these functions is common to every launch file so we will use this structure in all other python written launch files now let's see the spawn with control launch file here we Define arguments note that robot name argument is used in every launch file F this is to distinguish topic names joint names and other parameters of the robots we will launch in these lines robot State publisher is launched as every other python launch file this file has generate launch description function we are calling launch setup function using opaque function this is an action that executes a python function note that executed python function should have these three arguments as described in this document the perform function of the launch configuration class performs the substitution by retrieving the launch configuration as a string here we are setting names for topics and a robot State publisher name this is required to operate each robot independently in these lines we are creating robot description in this tutorial we are using a zacro file mapping argument is used to adding arguments while parsing a zacro file note that in case of using a zacro file we are creating robot description with the robot name we previously defined in these lines we are defining a robot State publisher at startup robot State publisher is supplied with urdf and it publishes the state of the robot to TF2 an important thing to notice is that we are remapping robot description topic and Joint States topic to distinguish topics of different robots now let's see the spawn in gazebo launch file the file structure is the same as in the robot State publisher launch file we saw previously the arguments we set in the main launch XML file are passed all way through to launch setup function in used in spawn entity Pi script this script is used to spawn an entity in gazebo gazebo must be started with gazebo RWS in it gazebo Raw ra Factory and gazebo raw state for all functionalities to work gazebo raws in it initializes raws with the system arguments passed to gazebo it also publishes the latest simulation time to clock topic gazebo RW Factory factorial ises RW with the system arguments passed to gazebo and provides services to spawn and delete entities from the world gazebo raw state provides services and topics to query and set the state of entities in simulation such as position and velocity we also can set initial position and orientation of the robot next let's take a look at static Odum to World launch P script here we are executing static transform publisher it publishes a static coordinate transformation to TF2 the first six arguments represent x y z offset in meters and yaw pitch roll and radians the second and third arguments represent frame ID and child frame ID respectively the final launch file is a Start Control launch file here we are executing joint State broadcaster and forward velocity controller joint State broadcaster reads all state interfaces and reports them on the joint State's topic and the dynamic joint States topic the controller manager provides the infrastructure to load unload start and stop controllers when loading a controller the controller manager will use the controller name as a root for all controller specific parameters forward velocity vity controller controls velocity of each wheel of the robot these were all launch files required to launch multiple robots in gazebo now let's see files that describe the robot robot description is done using a zacro file writing every property of the robot in one file will result in a very big file and will cause maintainability issues so there are separate files for each part of the robot all these parts are come together in the robot zacro file in this file firstly we are importing zacro files for each part note that robot name we defined in the main launch XML file is also used here it will be passed to every macro of separate parts in used in a joint and Link name parent parameter represents the name of the part to which this link will be attached the origin parameter represents translational and rotational offset of this part from the parent Parts origin the units are meters and radians respectively here we are setting gazebo related properties controllers related file is particularly important here we are setting raws to control properties gazebo system initialize the system interface parameters the command interfaces describe values in which this joint can be controlled for example position velocity or effort the state interfaces are considered readon feedback interfaces here names of the joints which states gazebo will publish are defined in these lines lib gazebo raws two control plugin is added the parameters tag defines Yong file with the configuration of the controllers robot Pam node tag defines name of the node where the robot parameter is located in the config folder controller configuration Yama file is located note that we have to make a separate file for each robot let's see how we publish Commands to control robots open the robot control script in the commander class we Define a nonp array with size of number of joints we are going to control note that the order of joints will be the order we defined in the controller yam file here we Define a publisher for each joint note that message type should be float 64 multiarray before executing the simulation make sure that you have installed the shown packages to open gazebo World execute the main launch XML file then run the robot control Pi script that
Info
Channel: robot mania
Views: 747
Rating: undefined out of 5
Keywords: robotics, python, ROS, Gazebo, simulation
Id: 76cEpo0pFYU
Channel Id: undefined
Length: 12min 13sec (733 seconds)
Published: Sun Jan 14 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.