Ask Your Question

Revision history [back]

It's possible your indents didn't cut and paste properly because the following should generate an unexpected indent error:

def send_cmd_to_arduino(self, x, angular , drive ,turn):
    message = "{}  {}".format(x,angular)
    print message
    if (abs(drive) > abs(turn)):
        self.ser.write(x )
    else:
        self.ser.write(angular )
            last_time = rospy.Time.now()
            self.Odom(last_time)

But if corrected to

    if (abs(drive) > abs(turn)):
        self.ser.write(x )
    else:
        self.ser.write(angular )
    last_time = rospy.Time.now()
    self.Odom(last_time)

then the odom publisher works.

There might be a couple other indent issues also, I corrected them and tried it out with socat:

socat -d -d pty,raw,b115200,link=$HOME/tmp/ttyUSB0,echo=0 pty,raw,b115200,link=$HOME/tmp/ttyUSB1,echo=0

and hardcoded self.address to tmp/ttyUSB0 to make it run, and the odom publisher worked when I published a Twist to cmd_vel.