Why the node's name in the console is different that the one in .launch file? - ubuntu-16.04

I am working with the bebop_driver package and running the bebop_driver_node.
The bebop_node.launch file is like this:
<?xml version="1.0"?>
<launch>
<arg name="namespace" default="bebop" />
<arg name="ip" default="10.202.0.1" />
<arg name="drone_type" default="bebop2" /> <!-- available drone types: bebop1, bebop2 -->
<arg name="config_file" default="$(find bebop_driver)/config/defaults.yaml" />
<arg name="camera_info_url" default="package://bebop_driver/data/$(arg drone_type)_camera_calib.yaml" />
<group ns="$(arg namespace)">
<node pkg="bebop_driver" name="bebop_driver" type="bebop_driver_node" output="screen">
<param name="camera_info_url" value="$(arg camera_info_url)" />
<param name="bebop_ip" value="$(arg ip)" />
<rosparam command="load" file="$(arg config_file)" />
</node>
<include file="$(find bebop_description)/launch/description.launch" />
</group>
</launch>
But when I run rosnode list I receive :
/bebop/bebop_driver
Since I am trying to use the rospy.init_node('node_name') this is a problem because I cant type a namespace.

The namespace and name of your node is defined in the launch file. You can find the documentation at thr ROS wiki: roslaunch/XML.
Namespace:
Since you are using a group, the node will be placed in it's namespace, defined by the ns attribute:
<group ns="$(arg namespace)">
In your case the namespace is defined by the argument namespace which is bebop by default:
<arg name="namespace" default="bebop" />
Note that multiple and nested groups are also possible to create namespaces.
Node name:
The node name is specified by its name attribute:
<node [...] name="bebop_driver" [...]
The result is bebop/bebop_driver what you can see by calling rosnode list.

Related

Default components in install4j

When my "installation components" screen runs (I'm in console mode, if it matters), I get the list of components to install, as expected. However, the "default" response is to accept 2 of the components, even though their "Initially Selected for installation" option is false.
I want the user to be able to NOT select any of the optional components, and this isn't possible when it's defaulting to have some of them "Selected".
As far as I can tell, there are no varfiles being loaded.
Snippet from my install4j file:
<component name="A" id="527" customizedId="a" displayDescription="false" hideHelpButton="false" selected="false" changeable="true" downloadable="false" hidden="false">
<description />
<include all="false">
<entry location=".i4j_external_314/a" fileType="regular" />
<entry location=".i4j_external_2366/a" fileType="regular" />
<entry location=".i4j_external_316/a" fileType="regular" />
<entry location=".i4j_external_8155/a" fileType="regular" />
<entry location=".i4j_external_318/a" fileType="regular" />
</include>
<dependencies />
</component>
<component name="B" id="528" customizedId="b" displayDescription="false" hideHelpButton="false" selected="false" changeable="true" downloadable="false" hidden="false">
<description />
<include all="false">
<entry location=".i4j_external_316/b" fileType="regular" />
<entry location=".i4j_external_8155/b" fileType="regular" />
<entry location=".i4j_external_318/b" fileType="regular" />
</include>
<dependencies />
</component>
<component name="C" id="69" customizedId="c" displayDescription="false" hideHelpButton="false" selected="false" changeable="true" downloadable="false" hidden="false">
<description />
<include all="false">
<entry location=".i4j_external_316/c" fileType="regular" />
<entry location=".i4j_external_8155/c" fileType="regular" />
<entry location=".i4j_external_318/c" fileType="regular" />
</include>
<dependencies />
Notice that in all 3 components, "selected" is false, and "changeable" is true.
When the installer runs, though, here is how it is presented:
Which components should be installed?
*: D
*: E
1: A
2: B
3: C
Please enter a comma-separated list of the selected values or [Enter] for the default selection:
[1,2]
(D and E are fine - they're set to "selected" and "not user changeable")
So, even though A and B are not "selected", they show up as a default. Also notice that "C" is configured the same way as "A" and "B", yet doesn't show up in the default.
This is problematic, because I have no way to select "none" of the optional components. I have to select at least 1 in order to not accept the default.
Thanks for any info - if you need more detail, I'd be happy to provide it.

Using xmlpeek in Nant script gives odd error

As part of a CI process I am trying to create a buildlabel which consists of the content of an xml element within an xml structure. For this purpose I am using nant and xmlpeek. My problem is that I get an odd error stating:
"Nodeindex '0' is out of range"
This is only the case if the xml file I am xmlpeeking contains a namespace definition in the root node.
Removing the namespace from the xml file gives me the output I expect.
The nant target that generates the error can be boild down to:
<target name="TDSLabel">
<property name="element" value=""/>
<echo message="Getting element" />
<xmlpeek file="C:\xxx\test1.xml" xpath="//Project/PropertyGroup/ProductVersion" property="element"/>
<echo message="The found element value was: ${element}" />
</target>
and the test1.xml file looks like this:
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProductVersion>9.0.21022</ProductVersion>
</PropertyGroup>
</Project>
You already gave the right hint yourself. It's about the namespace. This should fix it:
<target name="TDSLabel">
<property name="element" value=""/>
<echo message="Getting element" />
<xmlpeek
file="C:\xxx\test1.xml"
xpath="//x:Project/x:PropertyGroup/x:ProductVersion"
property="element"
verbose="true">
<namespaces>
<namespace prefix="x" uri="http://schemas.microsoft.com/developer/msbuild/2003" />
</namespaces>
</xmlpeek>
<echo message="The found element value was: ${element}" />
</target>
Found a similar problem and the anwser to my problem here: XmlPoke and unique nodes. The problem was that I did not include the namespace definition within the xmlpeek element and afterwards omitted the necessary reference to the namespace in my xpath statement:
<xmlpeek file="C:\xxx\test1.xml" xpath="//x:Project/x:PropertyGroup/x:ProductVersion" property="element">
<namespaces>
<namespace prefix="x" uri="http://schemas.microsoft.com/developer/msbuild/2003" />
</namespaces>
</xmlpeek>

Setting multiple Phing properties from command line

<?xml version="1.0" ?>
<project name="first" basedir="." default="build-skeleton">
<property name="dirName" value="module" />
<property name="fileName" value="config" />
<target name="build-skeleton" description="Making folders">
<mkdir dir="./${dirName}/Block" />
<touch file="./${dirName}/etc/${fileName}.xml" />
</target>
</project>
phing -f mage_module.xml -DdirName=moduleX,fileName=config
phing -f mage_module.xml -DdirName=moduleX fileName=config
Both throw an error - no surprise there.
Is it possible to set multiple properties in Phing via command line?
Just repeating the -D parameter should work:
phing -f mage_module.xml -DdirName=moduleX -DfileName=config

Nant: Find file by pattern

What I am trying to do, is to find a file with NAnt. This file could by anywhere in a directory structure of a given folder.
I tried to this with the NAnt-foreach task (this works) but I am not quite convinced of that:
<target name="find-file">
<fail message="Property param.dir must be set" unless="${property::exists('param.dir')}" />
<fail message="Property param.pattern must be set" unless="${property::exists('param.pattern')}" />
<property name="return.file" value="" />
<foreach item="File" property="iterator.file">
<in>
<items>
<include name="${param.dir}\**\${param.pattern}" />
</items>
</in>
<do>
<property name="return.file" value="${iterator.file}" if="${string::get-length(return.file) == 0}" />
</do>
</foreach>
</target>
Is there anybody aware of a better approach? If not how can I accomplish to exit the foreach-loop after the first element is found?
This nantcontrib function will put the matching filenames into a delimited string..
If you know that only one matching file will exist then it may get you what you want. If there are several then you could use the nant substring function to just get the first match by taking the substring up to the first delimiter.
The following nant script:
<?xml version="1.0" encoding="utf-8"?>
<project default="find-file2">
<property name="NantContrib.dir" value="C:\Program Files\nantcontrib-0.85\" readonly="true" />
<target name="LoadNantContrib">
<loadtasks assembly="${NantContrib.dir}bin\NAnt.Contrib.Tasks.dll" />
</target>
<target name="find-file2" depends="LoadNantContrib">
<fileset id="find.set">
<include name="${param.dir}\**\${param.pattern}" />
</fileset>
<property name="return.file" value="${fileset::to-string('find.set', ' | ')}" />
<echo message="return.file=${return.file}"/>
<echo message="Found ${fileset::get-file-count('find.set')} files"/>
</target>
</project>
...and the following folder structure:
\---folderroot
+---folder1
| dontfindme.txt
| findme.txt
|
+---folder2
| dontfindme.txt
|
\---folderempty
...works as expected. Searching for findme.txt finds one file. Searching for dontfindme.txt finds two files. Searching for *.txt finds three files.
Example call:
nant -D:param.dir=folderroot -D:param.pattern=findme.txt
Example output:
find-file2:
[echo] return.file=C:\Documents and Settings\rbaker\My Documents\nantfindfile\folderroot\folder1\findme.txt
[echo] Found 1 files
BUILD SUCCEEDED

nant: expanding properties in a string

Summary:
How do I expand a property with value "download\${bulidmode}\project\setup.msi" to "download\Debug\project\setup.msi" if the property buildmode contained debug so I can use it as the file="" part of < copy >
Detail:
I have a bit of a requirement to be able to expand properties within a string in nant.
For example I have a target that is copying file A to B. A and B both come from a simple two field CSV file which I'm iterating through using
<foreach item="Line" in="filelist.csv" delim="," property="source.file,target.file">
<property name="sourcefile" value="${path::combine(source.dir,source)}" />
<property name="targetfile" value="${path::combine(download.dir,destination)}" />
<echo message="Copy ${sourcefile} to ${targetfile}" />
<copy file="${sourcefile" tofile="${destination}" />
</foreach>
and the filelist.csv will be
build\manifest.xml
solutiondirectory\setup-proj-directory\Release\setupproj.msi,ProductA\ProductA.msi
solutiondirectory\another-proj-dir\Release\setupproj.msi,ProductB\ProductB.msi
(The reason we split these out is that we write multi-tiered applications and deploy by MSI to each tier - so one product has multiple msi's all built with the same version numbers)
Anyway - I want to change this to that I no longer have "Release" in the filelist.csv file but something like ${build.mode}. I would wrap the above code with a
<foreach item="String" in="Release,Debug" delim="," property="build.mode">
....as above
</foreach>
and the property embedded within the string in the file gets expanded.
I've been beating my head against a brick wall for a few hours, but just can't figure it out.
Thanks
It is possible with a custom function :
<?xml version="1.0"?>
<project>
<script language="C#" prefix="vbfox" >
<code>
<![CDATA[
[Function("expand")]
public string ExpandString(string str)
{
return Project.Properties.ExpandProperties(str, Location.UnknownLocation);
}
]]>
</code>
</script>
<property name="hello" value="{path::combine('_hello_', '_world_')}" />
<property name="hello" value="${'$' + hello}" />
<echo message="${hello}" />
<echo message="${vbfox::expand(hello)}" />
</project>