pyCreate2.robot package

Submodules

pyCreate2.robot.create2_driver module

pyCreate2.robot.gpio module

Module to use ODROID’s GPIOs.

class pyCreate2.robot.gpio.Gpio(number)[source]

Bases: object

Class to use general purpose input/output (GPIO) pins.

This class specifically targets the standard linux support for GPIO as provided by ODROID. More details can be found here: http://odroid.com/dokuwiki/doku.php?id=en:c1_hardware_pwm. The sysfs interface is described here: https://www.kernel.org/doc/Documentation/gpio/sysfs.txt. It supports setting the value and waiting for a hardware interrupt.

set_direction(direction)[source]

Set the direction (input/output) of the pin.

Parameters:direction (string) – One of “in”, “out”, “low”, “high”.
set_edge(edge)[source]

Set the edge trigger for HW interrupt support. Use wait_for_interrupt to wait for an interrupt afterwards.

Parameters:edge (string) – One of “none”, “rising”, “falling”, “both”
set_value(value)[source]

Set the current value of the pin (only valid if configured as output.)

Parameters:value (integer) – 0 or 1.
wait_for_interrupt(timeout_in_ms=1000)[source]

Waits until timeout or interrupt occurs.

Parameters:timeout_in_ms (integer) – maximum time to wait for an interrupt
Returns:None if timeout occurred or the current value of the pin in case the interrupt was triggered.

pyCreate2.robot.pwm module

Module to use ODROID’s HW PWM.

class pyCreate2.robot.pwm.Pwm(number=0)[source]

Bases: object

Class to use general pulse-width-modulation.

This class specifically targets the standard linux support for PWM as provided by ODROID. More details can be found here: http://odroid.com/dokuwiki/doku.php?id=en:c1_hardware_pwm. The sysfs interface is described here: https://www.kernel.org/doc/Documentation/pwm.txt. It supports setting the value and waiting for a hardware interrupt.

disable()[source]

Disables PWM.

enable()[source]

Enables PWM.

set_duty_cycle(duty_in_percent)[source]

Set the duty cycle of the pulse width

Parameters:duty_in_percent (float) – duty signal in percent (i.e. 0.0 to 100.0)
set_frequency(frequency_in_hertz)[source]

Set the frequency of the pulse width

Parameters:frequency_in_hertz (integer) – frequency in Hertz.

pyCreate2.robot.servo module

pyCreate2.robot.sonar module

Module to interface a PING Sonar connected via GPIO

class pyCreate2.robot.sonar.Sonar(pin)[source]

Bases: object

Class to use the PING Sonar

This class assumes that the PING sonar is connected using a GPIO pin. It implements the protocol specified in https://www.parallax.com/sites/default/files/downloads/28015-PING-Documentation-v1.6.pdf using hardware interrupts.

Parameters:pin – GPIO pin number where the sonar is connected to.
get_distance()[source]

Queries the current distance from the sonar.

Starts a new measurement cycle (which takes up to 19 ms) and returns the measured distance in m.

Returns:Distance in m. If there was an error, it returns 3.3 m.

Module contents