def on_message_received(self, msg):
     outmsg = CanMessage()
     outmsg.interface = CanMessage.CANTYPE_RADAR
     outmsg.id = msg.arbitration_id
     outmsg.can_timestamp = msg.timestamp
     outmsg.data = list(msg.data)
     outmsg.is_extended = msg.is_extended_id
     outmsg.is_error = msg.is_error_frame
     self.on_can_message(outmsg)
Пример #2
0
    def on_message_received(self, msg):
        outmsg = CanMessage()
        self.match_canbus_to_logical(msg)
        if self.can_type:
            outmsg.interface = self.can_type
        else:
            outmsg.interface = self.can_interface

        outmsg.id = msg.arbitration_id
        outmsg.can_timestamp = msg.timestamp
        outmsg.data = list(msg.data)
        outmsg.is_extended = msg.is_extended_id
        outmsg.is_error = msg.is_error_frame
        self.pub.publish(outmsg)
Пример #3
0
 def power_on_radar(self):
     for (addr, ecu, cars, bus, fr_step, vl) in STATIC_MSGS:
         if self.frame % fr_step == 0:
             tosend = bytearray()
             tosend.extend(map(ord, vl))
             # XXX This might be incorrect... interface might need to use the 'bus' variable
             message = CanMessage(id=addr, interface=CanMessage.CANTYPE_RADAR, data=tosend)
             self.can_pub.publish(message)
     self.frame += 1.
Пример #4
0
    def on_brake_cmd(self, msg):
        if not self.enabled:
            return

        brake_oscc_msg = self.oscc_db.get_message_by_name("BRAKE_COMMAND")
        self.can_pub.publish(CanMessage(id=brake_oscc_msg.frame_id,
                                        interface=CanMessage.CANTYPE_CONTROL,
                                        data=brake_oscc_msg.encode({
                                            'brake_command_magic': OSCC_MAGIC_NUMBER,
                                            'brake_command_pedal_request': msg.data,
                                            'brake_command_reserved': 0
                                        })))
Пример #5
0
    def on_throttle_cmd(self, msg):
        if not self.enabled:
            return


        throttle_oscc_msg = self.oscc_db.get_message_by_name("THROTTLE_COMMAND")
        encoded_msg = throttle_oscc_msg.encode({
            'throttle_command_magic': OSCC_MAGIC_NUMBER,
            'throttle_command_pedal_request': msg.data,
            'throttle_command_reserved' : 0
        })
        self.can_pub.publish(CanMessage(id=throttle_oscc_msg.frame_id,
                                        interface=CanMessage.CANTYPE_CONTROL,
                                        data=encoded_msg))
Пример #6
0
    def on_steering_cmd(self, msg):
        if not self.enabled:
            return

        brake_oscc_msg = self.oscc_db.get_message_by_name("STEERING_COMMAND")
        self.can_pub.publish(
            CanMessage(id=0x84,
                       interface=CanMessage.CANTYPE_CONTROL,
                       data=brake_oscc_msg.encode({
                           'steering_command_magic':
                           OSCC_MAGIC_NUMBER,
                           'steering_command_torque_request':
                           msg.data,
                           'steering_command_reserved':
                           0
                       })))
Пример #7
0
    def oscc_enabled(self, enable):
        msgs = None
        if enable:
            msgs = [
                ("BRAKE_ENABLE", {
                    'brake_enable_magic': 0xcc05,
                    'brake_enable_reserved': 0
                }),
                ("THROTTLE_ENABLE", {
                    'throttle_enable_magic': OSCC_MAGIC_NUMBER,
                    'throttle_enable_reserved': 0
                }),
                # ("STEERING_ENABLE", {
                #     'steering_enable_magic': OSCC_MAGIC_NUMBER,
                #     'steering_enable_reserved': 0
                # }),
            ]
        else:
            msgs = [
                ("BRAKE_DISABLE", {
                    'brake_disable_magic': OSCC_MAGIC_NUMBER,
                    'brake_disable_reserved': 0
                }),
                ("THROTTLE_DISABLE", {
                    'throttle_disable_magic': OSCC_MAGIC_NUMBER,
                    'throttle_disable_reserved': 0
                }),
                ("STEERING_DISABLE", {
                    'steering_disable_magic': OSCC_MAGIC_NUMBER,
                    'steering_disable_reserved': 0
                })
            ]

        for name, data in msgs:
            msg = self.oscc_db.get_message_by_name(name)
            self.can_pub.publish(CanMessage(id=msg.frame_id,
                                        interface=CanMessage.CANTYPE_CONTROL,
                                        data=msg.encode(data)))