
#Service to provide sample interface to the iRobot Create
#This example is for the original iRobot Create using the serial Open Interface (OI) protocol
service experimental.create3

stdver 0.10

enum CreateStateFlags
	unknown = 0,
	bump_right = 0x1,
	bump_left = 0x2,
	wheel_drop_right = 0x4,
	wheel_drop_left = 0x8,
	wheel_drop_caster = 0x10,
	wall_sensor = 0x20,
	cliff_left = 0x40,
	cliff_front_left = 0x80,
	cliff_front_right = 0x100,
	cliff_right = 0x200,
	virtual_wall = 0x400,
	play_button = 0x800,
	advance_button = 0x1000,
	error = 0x800000
end

struct CreateState
	field double time
	field uint32 create_state_flags
	field double velocity
	field double radius
	field double right_wheel_velocity
	field double left_wheel_velocity
	field double distance_traveled
	field double angle_traveled
	field double battery_charge
	field double battery_capacity
end

object Create
	constant double DRIVE_STRAIGHT 32.767
	constant double SPIN_CLOCKWISE -1e-3
	constant double SPIN_COUNTERCLOCKWISE 1e-3

	function void drive(double velocity, double radius)
	function void drive_direct(double right_wheel_velocity, double left_wheel_velocity)
	function void stop()
	function void setf_leds(bool play, bool advance)

	property double distance_traveled [readonly]
	property double angle_traveled [readonly]
	property uint8 bumpers [readonly]

	event bump()

	wire CreateState create_state [readonly]

	# Callback to be called when the play button is pressed
	# claim_play_callback() will assign the current client as the target for the callback
	# Practical implementations will likely want to use a more sophisticated mechanism to assign the callback
	function void claim_play_callback()
	callback uint8[] play_callback(double distance_traveled, double angle_traveled)
end
