Flickering in rviz
Hi, I am trying to visualize Baxter Robot while providing joint trajectory in rviz. I am calling rviz from following launch file-
<launch>
<arg name="file" default="$(find kinematics_animation)/demos/baxter/joint_states.csv" />
<param name="robot_description" command="$(find xacro)/xacro.py
--inorder $(find baxter_description)/urdf/baxter.urdf.xacro"/>
<node name="joint_state_publisher" pkg="joint_state_publisher" type="joint_state_publisher" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher"/>
<node pkg="rviz" type="rviz" respawn="false" name="rviz"
args="-d $(find kinematics_animation)/demos/baxter/baxter_rviz_config.rviz" />
<node pkg="kinematics_animation" type="player.py" name="baxter_animation">
<param name="file" value="$(arg file)" />
</node>
</launch>
Below is the snippet from python file-
def __init__(self):
freq = 50
self.rate = 1.0
rospy.loginfo("Publishing frequency = "+str(freq))
fname = rospy.get_param("~file", None)
if fname is None:
rospy.logerr("Must provide private param '~file'")
rospy.signal_shutdown("No CSV file provided")
else:
rospy.loginfo("Animation file = "+fname)
rospy.loginfo("Time scaling = " + str(self.rate))
# load data:
with open(fname, 'r') as f:
fline = f.readline()
self.names = fline.rstrip('\r\n').split(',')
self.names = self.names[1:]
self.dat = np.loadtxt(fname, skiprows=1, delimiter=',')
self._fint = interp1d(1/float(self.rate)*self.dat[:,0], self.dat[:,1:], kind='linear', axis=0)
self.base_time = rospy.Time.now()
# create publisher:
self.state_pub = rospy.Publisher("joint_states", JointState, latch=True, queue_size=3)
# create timer:
self.pbtimer = rospy.Timer(rospy.Duration(1/float(freq)), self.timercb)
return
def timercb(self, time_dat):
t = (rospy.Time.now() - self.base_time).to_sec()
try :
q = self._fint(t)
except ValueError:
q = self._fint.y[-1]
if (t - self._fint.x[-1]) > 2.0:
rospy.loginfo("Resetting animation!")
self.base_time = rospy.Time.now()
js = JointState(name=self.names, position=q)
js.header.stamp = rospy.Time.now()
self.state_pub.publish(js)
return
The problem is that after calling the launch file, rvis starts flickering the Baxter arms. It feels to me that everytime, arms are going back to home position. How can I resolve this problem?