예제 #1
0
def mb1swing(msg):
    if mode !=2:
        send = CAN()
        send.stdId = 0x122
        send.extId = -1
        send.data = struct.pack('f', msg.data)
        pub.publish( send )
예제 #2
0
def autoSwingCallback(msg):
    if mode == 2:
        send = CAN()
        send.stdId = 0x122
        send.extId = -1
        send.data = struct.pack('f', msg.data)
        pub.publish(send)
예제 #3
0
def autoSwingCallback(msg):
    if mode ==2:
        send = CAN()
        send.stdId = 0x122
        send.extId = -1
        send.data = struct.pack('f', msg.data)
        pub.publish( send )
예제 #4
0
def mb1swing(msg):
    if mode != 2:
        send = CAN()
        send.stdId = 0x122
        send.extId = -1
        send.data = struct.pack('f', msg.data)
        pub.publish(send)
예제 #5
0
def handCallback(msg):
    send = CAN()
    send.stdId = 0x150
    send.extId = -1
    if msg.data:
        send.data = [0xff]
    else:
        send.data = [0x00]
    pub.publish( send )
def mb1swing(msg):
    if mode !=2:
        send = CAN()
    	send.stdId = 0x150
    	send.extId = -1
    	if msg.data:
        	send.data = [0xff]
    	else:
        	send.data = [0x00]
        pub.publish( send )
예제 #7
0
def talker():
    pub = rospy.Publisher('cantx', CAN, queue_size=100)
    rospy.init_node('canusb_test', anonymous=True)
    r = rospy.Rate(10)  # 10Hz
    count = 0
    while not rospy.is_shutdown():
        msg = CAN()
        msg.stdId = 1
        msg.extId = -1
        msg.data = struct.pack('B', count % 256) + 'ABCDE'
        pub.publish(msg)

        msg = CAN()
        msg.stdId = 100
        msg.extId = 25
        msg.data = struct.pack('i', count)
        pub.publish(msg)

        count += 1

        r.sleep()
예제 #8
0
 def analyze(self, str):
     command = str[:1]
     if command == 't':
         self.msg = CAN()
         self.dlc = int(str[4:5],16)
         self.msg.timestamp = rospy.get_rostime()
         self.msg.stdId = int(str[1:4],16)
         self.msg.extId = -1
         for i in range(0, self.dlc):
             self.msg.data +=  struct.pack('B', int(str[5+i*2:7+i*2],16))
         return self.msg
     elif command == 'T':
         self.msg = CAN()
         self.dlc = int(str[9:10],16)
         self.msg.timestamp = rospy.get_rostime()
         self.msg.stdId = int(str[1:9],16)%0x400
         self.msg.extId = int(str[1:9],16)/0x400
         for i in range(0, self.dlc):
             self.msg.data +=  struct.pack('B', int(str[10+i*2:12+i*2],16))
         return self.msg
     else:
         return 0
예제 #9
0
def handCallback(msg):
    send = CAN()
    send.stdId = 0x150
    send.extId = -1
    if msg.data:
        send.data = [0xff]
    else:
        send.data = [0x00]
    pub.publish(send)
예제 #10
0
def autoSwingCallback(msg):
    if mode == 2:
        send = CAN()
        send.stdId = 0x150
        send.extId = -1
        if msg.data:
            if isright == True:
                send.data = [0xfb]
            else:
                send.data = [0xfe]
        else:
            send.data = [0x00]
        pub.publish(send)
예제 #11
0
def mb1swing(msg):
    if mode != 2:
        send = CAN()
        send.stdId = 0x150
        send.extId = -1
        if msg.data:
            send.data = [0xff]
        else:
            send.data = [0x00]
        pub.publish(send)
예제 #12
0
def autoSwingCallback(msg):
    if mode ==2:
        send = CAN()
    	send.stdId = 0x150
    	send.extId = -1
    	if msg.data:
            if isright == True:
                send.data = [0xfb]
            else:
                send.data = [0xfe]
    	else:
        	send.data = [0x00]
        pub.publish( send )
예제 #13
0
def mb1motor2(msg):
    send = CAN()
    send.stdId = 0x121
    send.extId = -1
    send.data = struct.pack('f', msg.data)
    pub.publish(send)
예제 #14
0
def omni3(msg):
    send = CAN()
    send.stdId = 0x112
    send.extId = -1
    send.data = struct.pack('f', msg.data)
    pub.publish(send)
예제 #15
0
def mb1motor2(msg):
    send = CAN()
    send.stdId = 0x121
    send.extId = -1
    send.data = struct.pack('f', msg.data)
    pub.publish( send )
예제 #16
0
def omni3(msg):
    send = CAN()
    send.stdId = 0x112
    send.extId = -1
    send.data = struct.pack('f', msg.data)
    pub.publish( send )