Hello I have found a problem when I try to use gazebo skid_steer_drive_controller. The controller did not publish wheel tf and will not respond when I try to send cmd_vel. Rviz says error where no transform from [link_left_wheel_front] to [odom]. But what is most important that the robot in Gazebo isn't moving. I don't know where it could be problem. Maybe in the plugin setting, but when I was looking and comparing with different codes, it looks ok to me.
Main URDF
The trabot.sensors.urdf.xacro are only cameras and lidar.
<?xml version="1.0"?>
<!-- link has always reference on [0,0,0] you can define visual to it-->
<!-- the joint will move child from parent with entered origin-->
<robot name="my_robot" xmlns:xacro="http://ros.org/wiki/xacro">
<xacro:include filename="$(find trabot_description)/urdf/trabot.sensors.urdf.xacro"/>
<xacro:property name="width" value="0.25"/>
<xacro:property name="bodylen" value="0.38"/>
<xacro:property name="hight" value="0.09"/>
<xacro:property name="wheel_pitch" value="0.175"/>
<xacro:property name="wheel_length" value="0.053975"/>
<xacro:property name="wheel_radius" value="0.0575"/>
<xacro:property name="wheel_separation" value="0.175"/>
<link name="base_link">
<visual>
<geometry>
<mesh filename="package://trabot_description/meshes/base.dae" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 0" xyz="-${width/2} -${bodylen/2} -${hight/2}"/>
</visual>
<collision>
<geometry>
<box size="${width} ${bodylen} ${hight}"/>
</geometry>
</collision>
<inertial>
<mass value="1.204"/>
<inertia ixx="0.01768" ixy="0.0" ixz="-0.0" iyy="0.00949" iyz="-0.0" izz="0.02069"/>
</inertial>
</link>
<xacro:macro name="wheel" params="prefix postfix frontback reflect">
<link name="link_${prefix}_wheel_${postfix}">
<visual>
<geometry>
<mesh filename="package://trabot_description/meshes/wheel.dae" scale="0.001 0.001 0.001"/>
</geometry>
<origin rpy="0 0 ${reflect*pi/2}" xyz="0 0 0"/>
</visual>
<collision>
<geometry>
<cylinder length="${wheel_length}" radius="${wheel_radius}"/>
</geometry>
<origin rpy="0 ${pi/2} 0" xyz="${reflect*(wheel_radius/2)} 0 0"/>
</collision>
<inertial>
<mass value="0.254"/>
<inertia ixx="0.000427228" ixy="0.0" ixz="0.0" iyy="0.0002708487" iyz="0.0" izz="0.0002708487"/>
<origin rpy="0 0 0" xyz="0 0 0"/>
</inertial>
</link>
<joint name="joint_${prefix}_${postfix}_wheel" type="continuous">
<parent link="base_link"/>
<child link="link_${prefix}_wheel_${postfix}"/>
<origin xyz="${(width/2+0.0001)*reflect} ${(wheel_pitch/2)*frontback} -0.0175"/>
<axis xyz="1 0 0"/>
<limit effort="10000" velocity="1000"/>
<joint_properties damping="1.0" friction="1.0"/>
</joint>
<!-- This block provides the simulator (Gazebo) with information on a few additional
physical properties. See http://gazebosim.org/tutorials/?tut=ros_urdf for more-->
<gazebo reference="link_${prefix}_wheel_${postfix}">
<mu1>0.1</mu1>
<mu2>0.1</mu2>
<kp>1000000.0</kp>
<kd>100.0</kd>
<minDepth>0.00</minDepth>
</gazebo>
<transmission name="tran_${prefix}_${postfix}_wheel">
<type>transmission_interface/SimpleTransmission</type>
<actuator name="actuator_${prefix}_${postfix}_wheel">
<mechanicalReduction>1</mechanicalReduction>
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</actuator>
<joint name="joint_${prefix}_${postfix}_wheel">
<hardwareInterface>hardware_interface/VelocityJointInterface</hardwareInterface>
</joint>
</transmission>
</xacro:macro>
<xacro:wheel prefix="left" postfix="front" frontback="1" reflect="1"/>
<xacro:wheel prefix="left" postfix="rear" frontback="-1" reflect="1"/>
<xacro:wheel prefix="right" postfix="front" frontback="1" reflect="-1"/>
<xacro:wheel prefix="right" postfix="rear" frontback="-1" reflect="-1"/>
<gazebo>
<plugin name="skid_steer_drive_controller" filename="libgazebo_ros_skid_steer_drive.so">
<updateRate>100.0</updateRate>
<robotNamespace>/</robotNamespace>
<leftFrontJoint>joint_left_front_wheel</leftFrontJoint>
<rightFrontJoint>joint_right_front_wheel</rightFrontJoint>
<leftRearJoint>joint_left_rear_wheel</leftRearJoint>
<rightRearJoint>joint_right_rear_wheel</rightRearJoint>
<wheelSeparation>0.175</wheelSeparation>
<wheelDiameter>0.115</wheelDiameter>
<robotBaseFrame>base_link</robotBaseFrame>
<torque>200</torque>
<MaxForce>5.0</MaxForce>
<topicName>trabot/cmd_vel</topicName>
<odometryTopic>trabot/odom</odometryTopic>
<odometryFrame>odom</odometryFrame>
<broadcastTF>true</broadcastTF>
</plugin>
</gazebo>
<!-- Gazebo plugin for ROS Control -->
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/</robotNamespace>
</plugin>
</gazebo>
</robot>
Launch file
<?xml version="1.0" encoding="UTF-8" ?>
<launch>
<arg name="gui" default="true"/>
<arg name="pause" default="false"/>
<arg name="world" default="$(find trabot_gazebo)/world/default.world"/>
<arg name="robot_urdf" default="$(find trabot_description)/urdf/trabot.urdf.xacro"/>
<arg name="rviz_config" default="$(find trabot_gazebo)/config/rviz_v.0.2.rviz"/>
<param name="robot_description" command="xacro '$(arg robot_urdf)'" />
<!-- world launch -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(arg world)"/> <!-- Note: the world_name is with respect to GAZEBO_RESOURCE_PATH environmental variable -->
<arg name="paused" value="$(arg pause)"/>
<arg name="use_sim_time" value="true"/>
<arg name="gui" value="$(arg gui)"/>
<arg name="recording" value="false"/>
<arg name="debug" value="false"/>
</include>
<!-- Spawn my robot -->
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-param robot_description -urdf -z 1 -model trabot"/>
<!-- Start tf of robot -->
<!-- Manual control of joints - joint state pub-->
<!--<node pkg="joint_state_publisher_gui" type="joint_state_publisher_gui" name="joint_state_publisher_gui"/>
-->
<!--creates transformation tree from robot_description param-->
<node pkg="robot_state_publisher" type="robot_state_publisher" name="rob_st_pub" />
<!-- rviz -->
<node pkg="rviz" type="rviz" name="rob_rviz" args="-d $(arg rviz_config)" required="true"/>
<node name="rqt_robot_steering" pkg="rqt_robot_steering" type="rqt_robot_steering">
<param name="default_topic" value="/trabot/cmd_vel"/>
</node>
</launch>
So definitely the problem, was in my not understanding in what I was doing. After few days and teaching myself ROS Control properly I found out the problem was in launch file.
Related
I have written a custom launch file for my custom gazebo world. When I roslaunch the .launch file, only an empty world opens. Could you tell me where am I wrong?
This is my launch file
<launch>
<arg name="x_pos" default="-1.0"/>
<arg name="y_pos" default="-1.0"/>
<arg name="z_pos" default="-1.0"/>
<!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
<arg name="model" value="burger" doc="model type [burger, waffle, waffle_pi]"/>
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="~/catkin_ws/src/cse340a3_gazebo/worlds/cse340a3.world"/>
<!-- more default parameters can be changed here -->
</include>
<!-- <param name="robot_description" value="~/catkin_ws/src/cse340a3_description/urdf/turtlebot3_burger.urdf.xacro" /> -->
<!-- <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model turtlebot3 -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description" /> -->
</launch>
This works for some reason (I put in the full path)
<launch>
<arg name="x_pos" default="-1.0"/>
<arg name="y_pos" default="-1.0"/>
<arg name="z_pos" default="-1.0"/>
<!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
<arg name="model" value="burger" doc="model type [burger, waffle, waffle_pi]"/>
<include file="/home/vishwad/catkin_ws/src/cse340a3_gazebo/launch/empty_world.launch">
<arg name="world_name" value="/home/vishwad/catkin_ws/src/cse340a3_gazebo/worlds/cse340a3.world"/>
<!-- more default parameters can be changed here -->
</include>
<!-- <param name="robot_description" value="~/catkin_ws/src/cse340a3_description/urdf/turtlebot3_burger.urdf.xacro" /> -->
<!-- <node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model turtlebot3 -x $(arg x_pos) -y $(arg y_pos) -z $(arg z_pos) -param robot_description" /> -->
</launch>
I am getting this error:
[WARN] [1549645986.850056, 54.996000]: Controller Spawner couldn't find the expected controller_manager ROS interface
while launching a urdf in gazebo. I am using ROS Kinetic and have looked for a solution for this error everywhere but couldn't find it. A similar question is asked here. I have done everything suggested in that link and the libjoint_state_controller.so file is present at opt/ros/kinetic/lib. I have added the gazebo plugin in my .xacro file.
<gazebo>
<plugin name="gazebo_ros_control" filename="libgazebo_ros_control.so">
<robotNamespace>/mushak</robotNamespace>
<robotParam>/mushak/robot_description</robotParam>
</plugin>
</gazebo>
This is the .launch file:
<?xml version="1.0" encoding="UTF-8"?>
<launch>
<group ns="/mushak">
<param name="robot_description" command="$(find xacro)/xacro --inorder '$(find mushak_pkg)/urdf/mushak_model.xacro'" />
<arg name="x" default="0"/>
<arg name="y" default="0"/>
<arg name="z" default="0.2412"/>
<!-- Spawn the robot model -->
<node name="mybot_spawn" pkg="gazebo_ros" type="spawn_model" output="screen"
args="-urdf -param robot_description -model mushak -x $(arg x) -y $(arg y) -z $(arg z)" />
<!-- Load controllers -->
<rosparam command="load" file="$(find mushak_pkg)/config/config.yaml" />
<!-- Controllers -->
<node name="controller_spawner" pkg="controller_manager" type="spawner"
respawn="false" output="screen" ns="/mushak"
args="
joint_state_controller
joint1_position_controller
joint2_position_controller
joint3_position_controller
joint4_position_controller
joint5_position_controller
joint6_position_controller
--timeout 50
">
</node>
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"
respawn="false" output="screen">
<remap from="/joint_states" to="/mushak/joint_states" />
</node>
</group>
</launch>
The model is opening in rviz without any error. The following is the output when I run rospack find joint_state_controller .
/opt/ros/kinetic/share/joint_state_controller
Also, in the terminal in which the Gazebo is running the following error is shown:
[ERROR] [1550681387.800721476, 9.313000000]: GazeboRosControlPlugin missing while using DefaultRobotHWSim, defaults to true.
This setting assumes you have an old package with an old implementation of DefaultRobotHWSim, where the robotNamespace is disregarded and absolute paths are used instead.
If you do not want to fix this issue in an old package just set to true.
I have added the transmissions to all the joints:
<transmission name="trans_${name}">
<type>transmission_interface/SimpleTransmission</type>
<joint name="${name}">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
</joint>
<actuator name="motor_${name}">
<hardwareInterface>hardware_interface/EffortJointInterface</hardwareInterface>
<mechanicalReduction>1</mechanicalReduction>
</actuator>
</transmission>
Can someone help me with this please!
I'm trying to pass values from the launch file to the xacro model, so I can, for example, launch two robots in a single world but using different topic names or material colors. Is there a way to do this?
I've tried this unsuccessfully: https://answers.ros.org/question/38956/pass-parameters-to-xacro-in-launch-file/
It gives an error: xxx.launch requires the 'ns' arg to be set.
I also see this here: http://wiki.ros.org/roslaunch/XML/arg But that only shows how to send parameters from one launch file to another.
Here is my launch file:
<launch>
<!-- these are the arguments you can pass this launch file, for example paused:=true -->
<arg name="paused" default="false"/>
<arg name="use_sim_time" default="true"/>
<arg name="gui" default="true"/>
<arg name="headless" default="false"/>
<arg name="debug" default="false"/>
<arg name="ctopic" default="/stupid/test" />
<!-- Load the URDF into the ROS Parameter Server -->
<param name="robot_description"
command="$(find xacro)/xacro.py '$(find mybot_description)/urdf/mybot.xacro' ctopic:=$(arg ns) "/>
<!-- We resume the logic in empty_world.launch, changing only the name of the world to be launched -->
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(find mybot_gazebo)/worlds/mybot.world"/>
<arg name="debug" value="$(arg debug)" />
<arg name="gui" value="$(arg gui)" />
<arg name="paused" value="$(arg paused)"/>
<arg name="use_sim_time" value="$(arg use_sim_time)"/>
<arg name="headless" value="$(arg headless)"/>
</include>
<!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot -->
<node name="urdf_spawner" pkg="gazebo_ros" type="spawn_model" respawn="false" output="screen"
args="-urdf -model mybot -param robot_description"/>
<!-- Run RVIZ
<node name="$(anon rviz)" pkg="rviz" type="rviz" args="$(find mybot_gazebo)/mybot.rviz" output="screen"/>-->
<!-- ros_control mybot launch file -->
<include file="$(find mybot_control)/launch/mybot_control.launch" />
</launch>
I've tried this in my xacro file:
$(arg ctopic)
and
<xacro:property name="ctopic" value="$(arg ctopic)" />
Thanks
I've started to built a stereo camera system to reconstruct the field of view. I use two Logitech C270 webcameras on a base stand to get the image streams.
For the project it's necessary to hold the camera optics as close as I can, so I've turned one camera vertically. I use video_stream_opencv package to get and rotate the images and also to send them to the other nodes.
Because of the further operations and to save some hardware resources, I thought it's necessary to synchronize the images' and camera info's timestamps before calibration, rectification etc., so I've created a synchronization node which uses approximate synchronization between the image frames and camera info messages, and it also republishes the data with the same timestamps.
I thought that after the synchronization won't be necessary to use the approx_sync, but I think I was wrong.
To test the system I also started to use a static tf publisher.
Unfortunately I couldn't get point cloud from the system, but in the terminal a warning message appears frequently:
[ WARN] [1506963490.361523551]: odometry: Could not get transform from base_link to left (stamp=1506963490.228821) after 0.100000 seconds ("wait_for_transform_duration"=0.100000)! Error=". canTransform returned after 0.102307 timeout was 0.1."
Here is my launch file:
<launch>
<!--*******************************************************************************************-->
<!-- Global parameters ************************************************************************-->
<!--*******************************************************************************************-->
<!-- Camera -->
<arg name="fps" default="25" />
<!-- Synchronization -->
<arg name="syncronizer_namespace" default="/syncronizer" />
<arg name="left_camera_raw" default="$(arg syncronizer_namespace)/left" />
<arg name="right_camera_raw" default="$(arg syncronizer_namespace)/right" />
<arg name="left_camera_info_topic" default="$(arg syncronizer_namespace)/left/camera_info" />
<arg name="right_camera_info_topic" default="$(arg syncronizer_namespace)/right/camera_info" />
<!-- Stereo -->
<arg name="stereo_namespace" default="/stereo_camera" />
<arg name="left_image_topic" default="$(arg stereo_namespace)/left/image_rect" />
<arg name="right_image_topic" default="$(arg stereo_namespace)/right/image_rect" />
<arg name="approx_sync" default="true" />
<arg name="queue_size" default="5" />
<!-- Tranfsorm -->
<arg name="use_static_transform" default="true" />
<!-- Visual SLAM -->
<arg name="frame_id" default="base_link" />
<!-- Fixed frame id, set "base_link" or "base_footprint" if they are published -->
<arg name="rtabmap" default="true" />
<arg name="odometry" default="true" />
<!-- Odometry -->
<arg name="odom_frame_id" default="odom" />
<!-- If set, TF is used to get odometry instead of the topic -->
<arg name="ground_truth_frame_id" default="" />
<!-- e.g., "world" -->
<arg name="ground_truth_base_frame_id" default="" />
<!-- e.g., "tracker", a fake frame matching the frame "frame_id" (but on different TF tree) -->
<arg name="wait_for_transform" default="true" />
<arg name="wait_for_transform_duration" default="0.2" />
<!-- 3D visualization -->
<arg name="rviz" default="false" />
<arg name="rtabmapviz" default="true" />
<arg name="camera_info" default="camera_info" />
<!--*******************************************************************************************-->
<!-- Core functionality ***********************************************************************-->
<!--*******************************************************************************************-->
<!-- Camera -->
<group ns="/camera">
<node pkg="nodelet" type="nodelet" name="stereo_camera_nodelet" args="manager" />
<!-- Left video stream input -->
<include file="$(find video_stream_opencv)/launch/camera.launch">
<arg name="camera_name" value="left" />
<arg name="camera_info_url" value="file:///$(find reconstruction)/config/left.yaml" />
<arg name="video_stream_provider" value="1" />
<arg name="flip_horizontal" value="false" />
<arg name="flip_vertical" value="false" />
<arg name="fps" value="$(arg fps)" />
</include>
<!-- Right video stream input -->
<include file="$(find video_stream_opencv)/launch/camera.launch">
<arg name="camera_name" value="right" />
<arg name="camera_info_url" value="file:///$(find reconstruction)/config/right.yaml" />
<arg name="video_stream_provider" value="2" />
<arg name="flip_horizontal" value="false" />
<arg name="flip_vertical" value="true" />
<arg name="fps" value="$(arg fps)" />
</include>
</group>
<!-- Syncronizer -->
<node name="syncronizer" pkg="reconstruction" type="syncronizer" />
<!-- Stereo processing -->
<group ns="/stereo_camera">
<node pkg="nodelet" type="nodelet" name="stereo_nodelet" args="manager" />
<node pkg="stereo_image_proc" type="stereo_image_proc" name="stereo_image_proc">
<remap from="left/image_raw" to="$(arg left_camera_raw)" />
<remap from="right/image_raw" to="$(arg right_camera_raw)" />
<remap from="left/camera_info" to="$(arg left_camera_info_topic)" />
<remap from="right/camera_info" to="$(arg right_camera_info_topic)" />
<param name="prefilter_size" value="35" />
<param name="prefilter_cap" value="11" />
<param name="correlation_window_size" value="41" />
<param name="min_disparity" value="-15" />
<param name="disparity_range" value="160" />
<param name="uniqueness_ratio" value="0.0" />
<param name="texture_threshold" value="1000" />
<param name="speckle_size" value="500" />
<param name="speckle_range" value="16" />
<param name="approximate_sync" value="true" />
<param name="queue_size" value="5" />
</node>
</group>
<!-- Transform -->
<node if="$(arg use_static_transform)" pkg="tf" type="static_transform_publisher" name="world_to_map" args="0.0 0.0 0.30 0.0 0.0 0.0 /base_link /camera_link 100" />
<group ns="rtabmap">
<!-- Stereo Odometry -->
<node if="$(arg odometry)" pkg="rtabmap_ros" type="stereo_odometry" name="stereo_odometry" output="screen">
<remap from="left/image_rect" to="$(arg left_image_topic)" />
<remap from="right/image_rect" to="$(arg right_image_topic)" />
<remap from="left/camera_info" to="$(arg left_camera_info_topic)" />
<remap from="right/camera_info" to="$(arg right_camera_info_topic)" />
<param name="approx_sync" type="bool" value="$(arg approx_sync)" />
<param name="frame_id" type="string" value="$(arg frame_id)" />
<param name="odom_frame_id" type="string" value="odom" />
<param name="queue_size" type="int" value="5" />
</node>
<!-- Visual SLAM: args: "delete_db_on_start" and "udebug" -->
<node if="$(arg rtabmap)" name="rtabmap" pkg="rtabmap_ros" type="rtabmap" output="screen" args="--delete_db_on_start --udebug">
<remap from="left/image_rect" to="$(arg left_image_topic)" />
<remap from="right/image_rect" to="$(arg right_image_topic)" />
<remap from="left/camera_info" to="$(arg left_camera_info_topic)" />
<remap from="right/camera_info" to="$(arg right_camera_info_topic)" />
<remap from="odom" to="/rtabmap/odom" />
<param name="approx_sync" type="bool" value="$(arg approx_sync)" />
<param name="frame_id" type="string" value="$(arg frame_id)" />
<param name="queue_size" type="int" value="30" />
<param name="subscribe_stereo" type="bool" value="true" />
<param name="subscribe_depth" type="bool" value="false" />
</node>
<!-- Visualisation RTAB-Map -->
<node if="$(arg rtabmapviz)" pkg="rtabmap_ros" type="rtabmapviz" name="rtabmapviz" args="-d $(find rtabmap_ros)/launch/config/rgbd_gui.ini" output="screen">
<remap from="left/image_rect" to="$(arg left_image_topic)" />
<remap from="right/image_rect" to="$(arg right_image_topic)" />
<remap from="left/camera_info" to="$(arg left_camera_info_topic)" />
<remap from="right/camera_info" to="$(arg right_camera_info_topic)" />
<remap from="odom_info" to="/rtabmap/odom_info" />
<remap from="odom" to="/rtabmap/odom" />
<param name="frame_id" type="string" value="$(arg frame_id)" />
<param name="queue_size" type="int" value="10" />
<param name="subscribe_stereo" type="bool" value="true" />
<param name="subscribe_odom_info" type="bool" value="true" />
</node>
</group>
</launch>
I also created a rqt graph to understand the connections between the nodes:
rqt_graph
And it's also helpful if we see the tf frames:
tf frames
I hope I said everything to find out what did I wrong, I'm really disapointed because of this problem.
Ok, we found out what was the problem.
As the error is saying, odometry cannot transform frame left to frame base_link. You may want to add a static transform between camera_link and left as this:
<arg name="pi/2" value="1.5707963267948966" />
<node if="$(arg use_static_transform)" pkg="tf" type="static_transform_publisher" name="camera_optical" args="0 0 0 -$(arg pi/2) 0 -$(arg pi/2) /camera_link /left 100" />
... so you have base_link -> camera_link -> left.
Note that you don't need to pre-synchronize as stereo_odometry and rtabmap nodes can do it directly with approx_sync:=true. But yes, if you pre-syncrhonize and set the same timestamp on all image/camera_info topics, you can use approx_sync:=false for odometry and rtabmap. If you have poor results after that, it may be caused by bad stereo rectification and/or synchronization.
I strongly suggest that you get a real stereo camera that does stereo hardware (not software!) synchronization to get good results when the robot is moving.
cheers,
Mathieu
I have rollover strategy with 2 days, but the files don't get remove. Can you please let know if this log4j2 configuration is valid for rollover strategy?
<?xml version="1.0" encoding="UTF-8"?>
<Configuration>
<Properties>
<Property name="baseDir">/log</Property>
<Property name="fileName">filelog</Property>
</Properties>
<Appenders>
<RollingFile name="LOG" fileName="${baseDir}/${fileName}.log"
filePattern="${baseDir}/${fileName}-%d{yyyy-MM-dd}.log" append="true">
<PatternLayout pattern="%d{yyyy-MM-dd'T'HH:mm:ss.SSSXXX}|%m%n" />
<Policies>
<TimeBasedTriggeringPolicy interval="1"/>
</Policies>
<DefaultRolloverStrategy>
<Delete basePath="${baseDir}" maxDepth="1">
<IfFileName glob="${fileName}-%d{yyyy-MM-dd}.log" />
<IfLastModified age="2d" />
</Delete>
</DefaultRolloverStrategy>
</RollingFile>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="LOG" />
</Root>
</Loggers>
</Configuration>
Change the line of IfFileName to
<IfFileName glob="${fileName}-*.log" />
You can also use IfAccumulatedFileCount if you like
<Delete basePath="${baseDir}">
<IfFileName glob="${fileName}-*.log">
<IfAccumulatedFileCount exceeds="2"/>
</IfFileName>
</Delete>
Actually, I think the latter is better.