Creating a roslaunch file that includes nodes from several packages - ros

In my Ros Workspace (ws), there are 3 packages in src folder. And in each package, there is a node (contained in scripts folder) which is written using python. I need to write a roslaunch file that runs all 3 nodes at once.
Folder structure
ws
-src
-pkg1
-scripts/node1.py
-pkg2
-scripts/node2.py
-pkg3
-scripts/node3.py
-launch *#I want to keep the launch file in here.*
Can someone help me or point me out on how to write the launch file combining multiple packages?

Roslaunch makes this fairly easy as it includes a tag for what package to launch a node from. Take the following example:
<launch>
<node pkg="pkg1" type="node1.py" name="node1">
<param name="some_param1" value="value1">
</node>
<node pkg="pkg2" type="node2.py" name="node2">
<param name="some_param2" value="value2">
</node>
</launch>

I think this could work for you. (assuming you are not using ROS2)
<?xml version="1.0"?>
<launch>
<node pkg="pkg1" type="node1.py" name="node1">
</node>
<node pkg="pkg2" type="node2.py" name="node2">
</node>
<node pkg="pkg3" type="node3.py" name="node3">
</node>
</launch>
If I remember correctly, the launch file can start any node, independent of packages. I usually create an additional package (and name it for example startup) and use it simply for my launch files.
This reference should have everything documented that you need. You'll find the details to launch a node here.

Related

Waiting for service /gazebo/spawn_urdf_model

I am following a tutorial to build a custom robot in Ros. I followed in detail this tutorial: https://www.youtube.com/watch?v=uvPFDQxfm2w&t=70s
I am trying to make my robot called "mrm" spawn in gazebo.
When I launch this spawn.launch file:
<?xml version="1.0" ?>
<launch>
<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mrm_description)/urdf/mrm.xacro'"/>
<arg name="x" default="0"/>
<arg name="y" default="0"/>
<arg name="z" default="0.5"/>
<node name="mybot_spawn" pkg="gazebo_ros" type="spawn_model" output="screen"
args="-param robot_description -urdf -model mrm -x $(arg x) -y $(arg y) -z $(arg z)"/>
</launch>
No error messages are appearing but everything is stuck: the robot doesn't appear and Gazebo is not open. I can only see this message in the terminal:
SUMMARY
========
PARAMETERS
* /robot_description: <?xml version="1....
* /rosdistro: noetic
* /rosversion: 1.15.15
NODES
/
mybot_spawn (gazebo_ros/spawn_model)
auto-starting new master
process[master]: started with pid [35299]
ROS_MASTER_URI=http://localhost:11311
setting /run_id to e34362f0-8a2f-11ed-a9b7-ef7c5e0a5b08
process[rosout-1]: started with pid [35309]
started core service [/rosout]
process[mybot_spawn-2]: started with pid [35312]
[INFO] [1672617380.741138]: Loading model XML from ros parameter robot_description
[INFO] [1672617380.745654]: Waiting for service /gazebo/spawn_urdf_model
It appears it is searching for the model of the robot as reported by:
https://answers.ros.org/question/383910/generic-question-about-the-error-waiting-for-service-gazebospawn_urdf_model/
I found an old similar question:
Error: gazebo_ros_control plugin is waiting for model URDF in parameter
But I do not think it fits my case.
I tried to create a new simplified model and launched it in a different workspace where I am already working with Franka model in gazebo but when I launch my custom robot the same issue appears.
If someone has some hints about how to solve this problem I would be very grateful.
Lorenzo

Set Mavsys Configuration in Roslaunch File

How do you set mavsys in the ros launch file? I want to update the mavros data rate on start up.
Normally l use this terminal command: rosrun mavros mavsys rate --all 10.
My launch file:
<launch>
<include file="$(find mavros)/launch/apm.launch" />
</launch>
Thank you for the help.

Why gmapping package is not run in multiple robot in real robot (not simulation)?

I have run this command from raspberry pi of the robot tb3_0 to run the /tb3_0/turtlebot3_core node
pi#raspberrypi:~ $ ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_bringup turtlebot3_robot.launch
And then I run gmapping package for tb3_0 robot in the pc terminal
amirul#nmy-lab:~$ ROS_NAMESPACE=tb3_0 roslaunch turtlebot3_slam turtlebot3_gmapping.launch set_base_frame:=tb3_0/base_footprint set_odom_frame:=tb3_0/odom set_map_frame:=tb3_0/map
But the gmapping package show a warning message
[ WARN] [1635496431.864557793]: MessageFilter [target=odom ]: Dropped 100.00% of messages so far. Please turn the [ros.gmapping.message_notifier] rosconsole logger to DEBUG for more information.
What I think is I didnt publish the robot_state_publisher node to the /tb3_0/gmapping node. How can I run the robot_state_publisher node in the tb3_0 ROSNAMESPACE? Thank you!
This is the rqt_graph of the running node
It depends on how you're launching robot_state_publisher. If using a launch file you can use the ns attribute to apply a namespace to the node. However, if you want to publish a namespaced transform you should use the tf_prefix param. Take the following example
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher">
<param name="publish_frequency" value="50.0"/>
<param name="tf_prefix" value="tb3_0" />
</node>

What is the meaning of this line in the launch file (ROS)

what this line means? And could explain it? Thanks!
<arg unless="$(arg debug)" name="launch-prefix" value=" "/>
<arg if="$(arg debug)" name="launch-prefix" value="gdb -ex run --args"/>
If you pass the argument debug to your launch file roslaunch test.launch debug:=true within your launch file $(launch-prefix) will evaluate to gdb -ex run --args,
otherwise it gets a string with one space inside " ".
I'll break down these two lines and explain every part of it.
Where to find the sources of my answers?
A launch file in general will launch nodes thats defined in it. It includes other launch files to start a specific part of the system. If you need more information you can check out this source: http://wiki.ros.org/roslaunch/XML Here you find a decent explanation about all possibilities in launch files.
What is the <arg /> tag in ROS launch files for?
For a better reusablility of launch files you can react to command line parameters, which are passed from command line while running roslaunch.
For example:
example_launch_file.launch
<launch>
<arg name="test" />
<node name="[NODE_NAME]" pkg="[PACKAGE_NAME]" type="[EXECUTABLE_NAME]">
<param name="test_arg_in_node" value="$(arg test)" />
</node>
</launch>
This example launch file will take a test argument and passes this argument into parameters for the example node.
If you have created the launch file above, you are able to run roslaunch and pass the parameter. Run the following command:
roslaunch example_launch_file.launch test:=TestArgumentValue
Thus within the node a parameter named test_arg_in_node is valued with TestArgumentValue
First line
<arg unless="$(arg debug)" name="launch-prefix" value=" "/>
unless is the only attribute which is not mentioned above. This attribute declares the argument as conditioned. So if you pass debug as true or 1 the argument launch-prefix will be NOT set.
Otherwise if debug is false or 0, launch-prefix evaluates to " ".
My source for this part of the answer is this page http://wiki.ros.org/roslaunch/XML again and especially chapter 3. if and unless attributes
Second line
<arg if="$(arg debug)" name="launch-prefix" value="gdb -ex run --args"/>
if is opposite to unless which means that if $(arg debug) is true or 1, argument launch-prefix will BE set to "gdb -ex run --args".
Additional information
Both if and unless expecting one value of this set [true, 1, false, 0] all other values will lead to an error. This is mentioned on this page as well: http://wiki.ros.org/roslaunch/XML
This line gdb -ex run --args will bring up the c++ debugging tool gdb if you pass it to a node. In my view this is a topic of its own but in the following link you will get a good starting point:
http://wiki.ros.org/roslaunch/Tutorials/Roslaunch%20Nodes%20in%20Valgrind%20or%20GDB
https://www.gnu.org/software/gdb/

Neo4J + GraphAware framework logging & debugging

So I've been developing a GraphAware Runtime module to extend Neo4J functionality.
According to GraphAware, in order to enable logging I need to add a slf4j provided dependency to my module and add an entry to custom-logback.xml file.
That unfortunately doesn't seem to work. Specifying custom log levels doesn't seem to affect what is being printed in the console, and adding a new appender (file) doesn't seem to take any effect, i.e. no files are created.
Did anyone have a go at adding logs to graphaware runtime modules?
Also, how would one debug such a module, if you have to deploy it to neo4j, and it's being run by the neo4j itself?
UPDATE 1:
So I'm using Neo4J 2.3.2 and the custom-logback.xml file didn't exist orignally in the package, and I had to create it.
I just checked and downloaded 2.2.8 version, and that file seems to exist in that package. Did anything change in the 2.3 version of Neo4J in terms of logging?
Turns out adding a logback.xml file to your conf directory with contents along these lines seems to work perfectly. I'll update the docs, please let me know if that worked. Cheers!
<configuration>
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSSZ} %-5level %msg%n</pattern>
</encoder>
</appender>
<logger name="com.graphaware" level="INFO"/>
<root level="DEBUG">
<appender-ref ref="STDOUT"/>
</root>
</configuration>

Resources