Demo entry 6347023

template hamster

   

Submitted by anonymous on Feb 13, 2017 at 11:11
Language: Java. Code size: 2.0 kB.

import com.cogniteam.HamsterAPIClient.Hamster;
import com.cogniteam.HamsterAPICommon.Common.HamsterError;
import com.cogniteam.HamsterAPICommon.Common.Log;
import com.cogniteam.HamsterAPICommon.Messages.GPS;
import com.cogniteam.HamsterAPICommon.Messages.IMU;
import com.cogniteam.HamsterAPICommon.Messages.Image;
import com.cogniteam.HamsterAPICommon.Messages.LidarScan;
import com.cogniteam.HamsterAPICommon.Messages.Pose;
import com.cogniteam.HamsterAPICommon.Parameters.HamsterClientParameters;

public class HamsterAPIClientSensorsExample 
{
	public static void main(String[] args) 
	{
		try
		{
			HamsterClientParameters params = new HamsterClientParameters();
			params.port = 8101;
			Hamster hamster = new Hamster(1,params);
			while(hamster.isConnected())
			{
				try
				{
					GPS gps = hamster.getGPS();
					Log.i("Client",gps.toString());
				}
				catch(HamsterError message_error)
				{
					Log.i("Client", "GPS: " + message_error.what());
				}
				
				try
				{
					IMU imu = hamster.getIMU();
					Log.i("Client",imu.toString());
				}
				catch(HamsterError message_error)
				{
					Log.i("Client", "IMU: " + message_error.what());
				}
				
				try
				{
					LidarScan lidar = hamster.getLidarScan();
					Log.i("Client",lidar.toString());
				}
				catch(HamsterError message_error)
				{
					Log.i("Client", "LidarScan: " + message_error.what());
				}	
				
				try
				{
					Pose pose = hamster.getPose();
					Log.i("Client",pose.toString());
				}
				catch(HamsterError message_error)
				{
					Log.i("Client", "Pose: " + message_error.what());
				}
				
				try
				{
					Image image = hamster.getCameraImage();
					Log.i("Client",image.toString());
				}
				catch(HamsterError message_error)
				{
					Log.i("Client", "Image: " + message_error.what());
				}	
				
			}
		}
		catch(HamsterError connection_error)
		{
			Log.i("Client",connection_error.what());
		}
	}
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).