The pointcloud message doesn't encode a concept of 'in front'. The message header has a frame_id
field that should correspond to a link element that exists within your robot description. If your robot is properly set up, you should be able to translate points from the stated reference frame (usually velodyne
) to a frame that helps define the orientation of your whole robot (usually called base_link
and defined with the convention REP 103).
You may want to check out this answer that has a bit of discussion and (potentially old) links for converting point clouds to x,y,z arrays.
To directly answer your question, you should check out VoxelGrid filtering. Given the REP 103 convention, you would want to use the filter to only output points that originated from in front (+x) of the robot. But this gets tricky if by 'in front' you mean (eg) the column of space from +x that's limited in the y dimension by the wheel dimensions: here you could do a pipeline of filters cutting off the x and then y dimensions. If 'in front' means a cone of space originating from the robot (say, to match the view of an on-board camera) then this simple filter won't be adequate.
You could also convert your pointcloud to one of the many mapping modules provided by the community. For instance, octomap encodes pointcloud packets into positioned voxels that are more easily queried for occupancy. This really depends on what your overall application is and what you actually need to do with your pointcloud.