This example shows how to access a HOKUYO laser scanner and retrieve scans. It makes use of the class hwdrivers::CHokuyoURG, which is in the mrpt-hwdrivers library.
This class works for both versions of the device, URG-04 and UTM-30LX (starting at version MRPT 0.6.0). It will automatically detects the version of the device, then adapts to query the correct amount of scan points.
Basically, the required steps are (refer to the sample code):
turnOn() .doProces() or doProcesSimple(), which processes incoming bytes, builds frames according to the required format, and returns scan data.There are some options that can be loaded before calling "turnOn()":
{syntaxhighlighter brush: plain}
[supplied_section_name]
COM_port_WIN = COM3
COM_port_LIN = ttyS0
pose_x=0.21 ; Laser range scaner 3D position in the robot (meters)
pose_y=0
pose_z=0.34
pose_yaw=0 ; Angles in degrees
pose_pitch=0
pose_roll=0
HOKUYO_motorSpeed_rpm=600 ; (Optional)
{/syntaxhighlighter}
Check also the ready-to-use application rawlog-grabber, which allows gathering data in rawlog format from any number of devices simultaneously.
Screenshot of the example (on Windows)
This example can be found under {MRPT}/samples/HOKUYO_laser_test/
Also available online: http://mrpt.googlecode.com/svn/trunk/samples/HOKUYO_laser_test/