Can I run gopigo2 with gopigo3 code

I have a gopigo2 which is running with the gopigo2 code. Is there a way of upgrading to run the gopigo2 with the gopigo3 code.

No way to “upgrade”, but you could try creating a custom file that maps all gopigo3 constants, classes and methods to the appropriate code. contains (from /home/pi/Dexter/GoPiGo/Software/Python/

**def** set_bus(bus):

**def** write_i2c_block(command, block):

**def** writeNumber(value):

**def** readByte():

**def** motor1(direction,speed):

**def** motor2(direction,speed):

**def** fwd(dist=0): #distance is in cm

**def** motor_fwd():

**def** bwd(dist=0):

**def** motor_bwd():

**def** left():

**def** left_rot():

**def** right():

**def** right_rot():

**def** turn_right(degrees):

**def** turn_right_wait_for_completion(degrees):

**def** turn_left(degrees):

**def** turn_left_wait_for_completion(degrees):

**def** stop():

**def** increase_speed():

**def** decrease_speed():

**def** trim_test(value):

**def** trim_read():

**def** trim_write(value):

**def** digitalRead(pin):

**def** digitalWrite(pin, value):

**def** pinMode(pin, mode):

**def** analogRead(pin):

**def** analogWrite(pin, value):

**def** volt():

**def** brd_rev():

**def** us_dist(pin):

**def** corrected_us_dist(pin):

**def** read_motor_speed():

**def** led_on(l_id):

**def** led_off(l_id):

**def** servo(position):

**def** enc_tgt(m1,m2,target):

**def** enc_read(motor):

**def** fw_ver():

**def** enable_encoders():

**def** disable_encoders():

**def** enable_servo():

**def** disable_servo():

**def** set_left_speed(speed):

**def** set_right_speed(speed):

**def** set_speed(speed):

**def** enable_com_timeout(timeout):

**def** disable_com_timeout():

**def** read_status():

**def** read_enc_status():

**def** read_timeout_status():

**def** ir_read_signal():

**def** ir_recv_pin(pin):

**def** cpu_speed():

**def** dht(sensor_type=0):

**def** check_version(): 

and gopigo3 contains:

class Enumeration(object):
class FirmwareVersionError(Exception):
class SensorError(Exception):
class I2CError(Exception):
class ValueError(Exception):
class GoPiGo3(object):


    def __init__(self, names):  # or *names, with no .split()
    def __init__(self, addr = 8, detect = True):
    def spi_transfer_array(self, data_out):
    def spi_read_8(self, MessageType):
    def spi_read_16(self, MessageType):
    def spi_read_32(self, MessageType):
    def spi_write_32(self, MessageType, Value):
    def get_manufacturer(self):
    def get_board(self):
    def get_version_hardware(self):
    def get_version_firmware(self):
    def get_id(self):
    def set_led(self, led, red, green = 0, blue = 0):
    def get_voltage_5v(self):
    def get_voltage_battery(self):
    def set_servo(self, servo, us):
    def set_motor_power(self, port, power):
    def set_motor_position(self, port, position):
    def set_motor_dps(self, port, dps):
    def set_motor_limits(self, port, power = 0, dps = 0):
    def get_motor_status(self, port):
    def get_motor_encoder(self, port):
    def offset_motor_encoder(self, port, offset):
    def reset_motor_encoder(self, port):
    def set_grove_type(self, port, type):
    def set_grove_mode(self, pin, mode):
    def set_grove_state(self, pin, state):
    def set_grove_pwm_duty(self, pin, duty):
    def set_grove_pwm_frequency(self, port, freq = 24000):
    def grove_i2c_transfer(self, port, addr, outArr, inBytes = 0):
    def grove_i2c_start(self, port, addr, outArr, inBytes = 0):
    def get_grove_value(self, port):
    def get_grove_state(self, pin):
    def get_grove_voltage(self, pin):
    def get_grove_analog(self, pin):
    def reset_all(self):

example custom

import gopigo
class GoPiGo3(object):
   def set_motor_dps(self, port, dps):
        # analyze port value passed for which motor or both to drive
        # analyze dps positive or negative for choosing direction
        if port_has_motor1: gopigo.motor1( dps>=0, abs(dps))
        if port_has_motor2: gopigo.motor2( dps>=0, abs(dps))

It will be a bit of work to map the gopigo3 functionality to gopigo2 methods, but once you have built your custom, some of the “three” examples will be possible simply by copying your custom into the folder with the “three” example.

Some of the “three” code depends on the EasyGoPiGo3 class in, and for those examples you would need to copy /home/pi/Dexter/GoPiGo3/Software/Python/ into the example folder along with your custom file. I think most of the EasyGoPiGo3 class is built upon the gopigo3 class, which you will offer in your custom file, so it should require a lot less work (if any) than the investment to create the custom

You could start by having every method in your custom file print out “method_xyz: not implemented” and just return. Then implement the first “not implemented” method, try it again until a gopigo3 example works.

It will not be easy, but it is possible. Before I bought a GoPiGo3, I created a custom interface for the robot I had that implemented basic drive commands and servo control, so I know it will be possible for you to map some of the gopigo3 functionality to your gopigo2.

You might end up hating yourself for investing the time to write the software, instead of plunking down the $99 for a GoPiGo3, but you will have learned so much more about Python, and your robot, that you will have much to be proud of if you choose to go that route.