This constructor sets the variables to the following values: :param str config_file_path = "/home/pi/Dexter/gpg3_config.json": Path to JSON config file that stores the wheel diameter and wheel base width for the GoPiGo3. :param bool use_mutex = False: When using multiple th
(self, config_file_path="/home/pi/Dexter/gpg3_config.json", use_mutex=False)
| 95 | """ |
| 96 | |
| 97 | def __init__(self, config_file_path="/home/pi/Dexter/gpg3_config.json", use_mutex=False): |
| 98 | """ |
| 99 | This constructor sets the variables to the following values: |
| 100 | |
| 101 | :param str config_file_path = "/home/pi/Dexter/gpg3_config.json": Path to JSON config file that stores the wheel diameter and wheel base width for the GoPiGo3. |
| 102 | :param bool use_mutex = False: When using multiple threads/processes that access the same resource/device, mutex has to be enabled. |
| 103 | :var int speed = 300: The speed of the motors should go between **0-1000** DPS. |
| 104 | :var tuple(int,int,int) left_eye_color = (0,255,255): Set Dex's left eye color to **turqoise**. |
| 105 | :var tuple(int,int,int) right_eye_color = (0,255,255): Set Dex's right eye color to **turqoise**. |
| 106 | :var int DEFAULT_SPEED = 300: Starting speed value: not too fast, not too slow. |
| 107 | :raises IOError: When the GoPiGo3 is not detected. It also debugs a message in the terminal. |
| 108 | :raises gopigo3.FirmwareVersionError: If the GoPiGo3 firmware needs to be updated. It also debugs a message in the terminal. |
| 109 | :raises Exception: For any other kind of exceptions. |
| 110 | |
| 111 | The ``config_file_path`` parameter represents the path to a JSON file. The presence of this configuration file is optional and is only required in cases where |
| 112 | the GoPiGo3 has a skewed trajectory due to minor differences in these two constants: the **wheel diameter** and the **wheel base width**. In most cases, this won't be the case. |
| 113 | |
| 114 | By-default, the constructor tries to read the ``config_file_path`` file and silently fails if something goes wrong: wrong permissions, non-existent file, improper key values and so on. |
| 115 | To set custom values to these 2 constants, use :py:meth:`~easygopigo3.EasyGoPiGo3.set_robot_constants` method and for saving the constants to a file call |
| 116 | :py:meth:`~easygopigo3.EasyGoPiGo3.save_robot_constants` method. |
| 117 | |
| 118 | """ |
| 119 | try: |
| 120 | super(self.__class__, self).__init__() |
| 121 | except IOError as e: |
| 122 | print("FATAL ERROR:\nGoPiGo3 is not detected.") |
| 123 | raise e |
| 124 | except gopigo3.FirmwareVersionError as e: |
| 125 | print("FATAL ERROR:\nTo update the firmware on Raspbian for Robots you need to run DI Software Update and choose Update Robot") |
| 126 | raise e |
| 127 | except Exception as e: |
| 128 | raise e |
| 129 | |
| 130 | # load wheel diameter & wheel base width |
| 131 | # should there be a problem doing that then save the current default configuration |
| 132 | try: |
| 133 | self.load_robot_constants() |
| 134 | except Exception: |
| 135 | pass |
| 136 | |
| 137 | self.sensor_1 = None |
| 138 | self.sensor_2 = None |
| 139 | self.DEFAULT_SPEED = 300 |
| 140 | self.NO_LIMIT_SPEED = 1000 |
| 141 | self.set_speed(self.DEFAULT_SPEED) |
| 142 | self.left_eye_color = (0, 255, 255) |
| 143 | self.right_eye_color = (0, 255, 255) |
| 144 | self.use_mutex = use_mutex |
| 145 | |
| 146 | def load_robot_constants(self, config_file_path="/home/pi/Dexter/gpg3_config.json"): |
| 147 | """ |
nothing calls this directly
no test coverage detected