I have a file that has lines like this.
(function($, _) {
.....
})(jQuery, jQuery.ZOF);
now I want to remove the first and last line of the file and then concat this file to another file , How could it be possible with ant?
loadfile can be used as follows:
<loadfile srcfile="test.xml" property="file.first.and.last.line.removed">
<filterchain>
<filterreader classname="org.apache.tools.ant.filters.HeadFilter">
<param name="lines" value="-1"/>
<param name="skip" value="1"/>
</filterreader>
<filterreader classname="org.apache.tools.ant.filters.TailFilter">
<param name="lines" value="-1"/>
<param name="skip" value="1"/>
</filterreader>
</filterchain>
</loadfile>
<echo message="${file.first.and.last.line.removed}" file="output.txt" append="true" />
First we use a HeadFilter to read everything but skipping the first line, then we "tail" the result with a TailFilter skipping the last line.
The last line appends the content to another file.
Related
We are running RTAB map with two web cameras with the following launch file.
<launch>
<!-- Choose visualization -->
<arg name="rviz" default="true" />
<!-- Run the ROS package stereo_image_proc for image rectification and disparity computation -->
<group ns="stereo">
<node pkg="stereo_image_proc" type="stereo_image_proc" name="stereo_image_proc">
<remap from="left/image_raw" to="left/image_raw"/>
<remap from="left/camera_info" to="left/camera_info"/>
<remap from="right/image_raw" to="right/image_raw"/>
<remap from="right/camera_info" to="right/camera_info"/>
<param name="disparity_range" value="128"/>
<param name="approximate_sync" type="bool" value="True"/>
<param name="queue_size" type="int" value="10"/>
</node>
<!-- Disparity to depth -->
<node pkg="nodelet" type="nodelet" name="disparity2depth" args="standalone rtabmap_ros/disparity_to_depth">
<param name="disparity_range" value="128"/>
<param name="approx_sync" type="bool" value="true"/>
<param name="queue_size" type="int" value="100"/>
</node>
</group>
<group ns="rtabmap">
<node pkg="rtabmap_ros" type="stereo_odometry" name="stereo_odometry" output="screen">
<remap from="left/image_rect" to="/stereo/left/image_rect_color"/>
<remap from="right/image_rect" to="/stereo/right/image_rect_color"/>
<remap from="left/camera_info" to="/stereo/left/camera_info"/>
<remap from="right/camera_info" to="/stereo/right/camera_info"/>
<param name="subscribe_rgbd" type="bool" value="false"/>
<!-- <remap from="rgbd_image" to="/stereo/rgbd_image"/> -->
<!-- Published topic odom is converted into stereo_odometry -->
<remap from="odom" to="/stereo_odometry"/>
<param name="approx_sync" type="bool" value="true"/>
<param name="frame_id" type="string" value="base_link"/>
<param name="odom_frame_id" type="string" value="odom"/>
<param name="publish_tf" type="bool" value="true"/>
<param name="wait_for_transform" type="string" value="true"/>
<param name="queue_size" type="int" value="100"/>
<param name="Odom/Strategy" type="string" value="0"/> <!-- 0=Frame-to-Map, 1=Frame=to=Frame -->
<param name="Vis/EstimationType" type="string" value="1"/> <!-- 0=3D->3D 1=3D->2D (PnP) -->
<param name="Vis/CorType" value="0"/> <!-- Correspondences: 0=Features Matching, 1=Optical Flow -->
<!-- maximum features map size, default 2000 -->
<param name="OdomF2M/MaxSize" type="string" value="1000"/>
<!-- maximum features extracted by image, default 1000 -->
<param name="Vis/MaxFeatures" type="string" value="600"/>
<param name="Vis/MinInliers" type="string" value="5"/>
<param name="Stereo/MaxDisparity" type="string" value="128"/>
<param name="Stereo/OpticalFlow" type="string" value="false"/>
</node>
<!-- Visual SLAM -->
<node name="rtabmap" pkg="rtabmap_ros" type="rtabmap" output="screen" args="--delete_db_on_start">
<param name="subscribe_depth" type="bool" value="true"/>
<param name="subscribe_rgbd" type="bool" value="false"/>
<param name="subscribe_scan" type="bool" value="false"/>
<remap from="rgb/image" to="/stereo/left/image_rect_color"/>
<remap from="rgb/camera_info" to="/stereo/left/camera_info"/>
<remap from="depth/image" to="/stereo/depth"/>
<remap from="odom" to="/stereo_odometry"/>
<param name="frame_id" type="string" value="/base_link"/>
<param name="queue_size" type="int" value="2000"/>
<param name="approx_sync" type="bool" value="true"/>
<param name="Vis/MinInliers" type="string" value="12"/>
</node>
</group>
<!-- Visualisation RVIZ -->
<node if="$(arg rviz)" pkg="rviz" type="rviz" name="rviz" args="-d $(find rtabmap_ros)/launch/config/demo_stereo_outdoor.rviz"/>
</launch>
Our TF transform tree has base_link -> stereo/left, base_link -> stereo/right, odom -> base_link
After running rostopic hz stereo/depth stereo/left/image_rect_color stereo/left/camera_info we get the following output as well.
We are new to using rtab map. If someone can offer a help it would be much appreciated.
We finally found the issue. For any of those who are having rtab map odometry or mapping issues with stereo or RGBD sensors like Kinect 360 build RTAB Map from the source.The same launch file worked after the build from source.
Reason for this could be older binaries in the servers.
Guide to manually build rtabmap - Click Here to Build RTAB Map yourself
BTW you can use two USB web cams (YOU DON'T EVEN NEED BRANDED ONES LIKE LOGITECH OURS WERE UNBRANDED CHINESE ONES) as a stereo sensor. You can either sync them using a small code or you can use approx_sync parameter to true. How ever keep in mind that you have to configure TF transformations from base_link to camera_link and camera_link to individual cameras (left and right) as well to make it work. AND BEWARE Sometimes stereo setup like this may not give you a highly accurate map or odometry.
You can also try with a kinect 360 which is really cheap these days.
I am copying a file while doing search and replace tokens in ant using replaceregex tag
tokens exist in a separate text file specified in the propertiesfile
token1=SDF234\n1sdfad
token2=FooBarBaz\nBar
the config.ini file has replacement values as : ${token1}
Some tokens have \n in them and the replaceregex adds a new line
I tried to add : byline="true" without success
I also added flags="m" to the replaceregex tag, it didn't work
sample token:
QWpVsL2Ti\njWhT\n
the code replaces it like:
QWpVsL2Ti
jWhT
the desired replacement should be in the same line ignoring the \n
ant task:
<copy file="../../config.ini" tofile="./Package/config.ini">
<filterchain>
<replaceregex pattern="\$\{" replace="{" byline="true"/>
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile" value="properties_${build_target}.ini"/>
<param type="tokenchar" name="begintoken" value="{"/>
<param type="tokenchar" name="endtoken" value="}"/>
</filterreader>
</filterchain>
</copy>
I have a property which contained a string and now want to change it to be a comma separated list to test lines in a file.
Currently with one value the following works:
<loadfile property="contents" srcFile="output.log">
<filterchain>
<linecontains>
<contains value="${findvalue}"></contains>
</linecontains>
</filterchain>
</loadfile>
So if a line in a file contains:
Hello World!
And value of findvalue = 'World' it would find the line. Now we want to find all lines that may match multiple words. So if lines of a file contain:
Hello World!
Bye Everyone!
We want to set the property findvalue = World,Everyone and pickup both lines of the file. Hopefully I am making sense on this, little hard for me to fully explain. Any ideas on how to best accomplish this?
One way is to use a linecontainsregexp filter to get lines that match a certain regular expression. The trick is to convert the comma-separated list of values into a single regex.
If the property findvalue is World,Everyone, the regex could simply be World|Everyone, which means the line contains either World or Everyone.
<property name="findvalue" value="World,Everyone" />
<loadresource property="findvalueRegex">
<propertyresource name="findvalue"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from="," to="|" />
</tokenfilter>
</filterchain>
</loadresource>
Then pass the findvalueRegex property containing this regex to the linecontainsregexp filter:
<loadfile property="contents" srcFile="output.log">
<filterchain>
<linecontainsregexp>
<regexp pattern="${findvalueRegex}" />
</linecontainsregexp>
</filterchain>
</loadfile>
linecontains takes multiple contains.
<loadfile property="contents" srcFile="output.log">
<filterchain>
<linecontains>
<contains value="${findvalue1}"/>
<contains value="${findvalue2}"/>
.
.
.. and so on..
</linecontains>
</filterchain>
</loadfile>
This would be helpful only when you have a defined list of tokens to be searched and you don't want them to be fetched dynamically.
I know it's too late to answer but it might help someone else like me. :)
I´m trying to get the value of node in the xml file. I observed that value is wrong. I´m belive that problem is the encoding. Someaone can help me ? below is my code:
In xml File:
<?xml version="1.0" encoding="UTF-8" ?>
<projects>
<project>
<application>Padrão</application> <!-- The problem is the character ~ -->
<name>padrao</name>
<icon>c:\buffer</icon>
<market>br.com.tls.test</market>
</project>
</projects>
My ant code
<xmltask source="config.xml" encoding="UTF-8">
<call path="//project">
<param name="name" path="name/text()" />
<param name="market" path="market/text()" />
<param name="icon" path="icon/text()" />
<param name="application" path="application/text()" />
<actions>
<echo message="#{application}" />
<init-release name="#{name}" market="#{market}" icon="#{icon}" application="#{application}"/>
</actions>
</call>
</xmltask>
Result
[echo]: padr#o
expected
[echo]: padrão
Solution
I changing the file to UTF-8 and I´d sucess in the replace.
I haven't used xmltask, but echo task also has encoding property, have you tried setting that as well?
e.g. <echo message="#{application}" encoding="UTF-8" />
i would like to replace tokens in source files with Ant:
some test ${foo} other text ...
Tokens are contained in a properties file eg.:
foo=1
Actually this is easy if tokens in source files were like '##foo##' or 'foo' but i'm not able to replace whole token : ${foo}
I've succeed years ago but this time i've failed ...
Thanks
This is somewhat similar to these.
Properties are loaded from the file properties.txt.
The weakness here is that all occurrences of ${ in your input text are converted to { before the token substitution - which may well break things if that string appears elsewhere in the text. If that is a problem, it still aught to be possible to adapt this solution.
<copy file="input.txt" tofile="output.txt">
<filterchain>
<replaceregex pattern="\$\{" replace="{" />
<filterreader classname="org.apache.tools.ant.filters.ReplaceTokens">
<param type="propertiesfile" value="properties.txt"/>
<param type="tokenchar" name="begintoken" value="{"/>
<param type="tokenchar" name="endtoken" value="}"/>
</filterreader>
</filterchain>
</copy>