You need to normalize the raw point cloud data so that points are measured above ground level rather than above sea level. Your current filter lasfilter(las, Z > 10 & Z < 40) is not being applied to your point cloud data which has the following elevation values:
names : mean, max
min values : 132.1497, 140.6000
max values : 225....