openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

95 lines
3.3 KiB

#!/usr/bin/env python3
import cereal.messaging as messaging
from opendbc.can.packer import CANPacker
from opendbc.can.parser import CANParser
from openpilot.selfdrive.boardd.boardd_api_impl import can_list_to_can_capnp
from openpilot.selfdrive.car import crc8_pedal
packer = CANPacker("honda_civic_touring_2016_can_generated")
rpacker = CANPacker("acura_ilx_2016_nidec")
def get_car_can_parser():
dbc_f = 'honda_civic_touring_2016_can_generated'
checks = [
(0xe4, 100),
(0x1fa, 50),
(0x200, 50),
]
return CANParser(dbc_f, checks, 0)
cp = get_car_can_parser()
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
5 years ago
def can_function(pm, speed, angle, idx, cruise_button, is_engaged):
msg = []
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
5 years ago
# *** powertrain bus ***
speed = speed * 3.6 # convert m/s to kph
msg.append(packer.make_can_msg("ENGINE_DATA", 0, {"XMISSION_SPEED": speed}))
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
5 years ago
msg.append(packer.make_can_msg("WHEEL_SPEEDS", 0, {
"WHEEL_SPEED_FL": speed,
"WHEEL_SPEED_FR": speed,
"WHEEL_SPEED_RL": speed,
"WHEEL_SPEED_RR": speed
}))
msg.append(packer.make_can_msg("SCM_BUTTONS", 0, {"CRUISE_BUTTONS": cruise_button}))
values = {"COUNTER_PEDAL": idx & 0xF}
checksum = crc8_pedal(packer.make_can_msg("GAS_SENSOR", 0, {"COUNTER_PEDAL": idx & 0xF})[2][:-1])
values["CHECKSUM_PEDAL"] = checksum
msg.append(packer.make_can_msg("GAS_SENSOR", 0, values))
msg.append(packer.make_can_msg("GEARBOX", 0, {"GEAR": 4, "GEAR_SHIFTER": 8}))
msg.append(packer.make_can_msg("GAS_PEDAL_2", 0, {}))
msg.append(packer.make_can_msg("SEATBELT_STATUS", 0, {"SEATBELT_DRIVER_LATCHED": 1}))
msg.append(packer.make_can_msg("STEER_STATUS", 0, {}))
msg.append(packer.make_can_msg("STEERING_SENSORS", 0, {"STEER_ANGLE": angle}))
msg.append(packer.make_can_msg("VSA_STATUS", 0, {}))
msg.append(packer.make_can_msg("STANDSTILL", 0, {"WHEELS_MOVING": 1 if speed >= 1.0 else 0}))
msg.append(packer.make_can_msg("STEER_MOTOR_TORQUE", 0, {}))
msg.append(packer.make_can_msg("EPB_STATUS", 0, {}))
msg.append(packer.make_can_msg("DOORS_STATUS", 0, {}))
msg.append(packer.make_can_msg("CRUISE_PARAMS", 0, {}))
msg.append(packer.make_can_msg("CRUISE", 0, {}))
msg.append(packer.make_can_msg("SCM_FEEDBACK", 0, {"MAIN_ON": 1}))
msg.append(packer.make_can_msg("POWERTRAIN_DATA", 0, {"ACC_STATUS": int(is_engaged)}))
msg.append(packer.make_can_msg("HUD_SETTING", 0, {}))
msg.append(packer.make_can_msg("CAR_SPEED", 0, {}))
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
5 years ago
# *** cam bus ***
msg.append(packer.make_can_msg("STEERING_CONTROL", 2, {}))
msg.append(packer.make_can_msg("ACC_HUD", 2, {}))
msg.append(packer.make_can_msg("LKAS_HUD", 2, {}))
msg.append(packer.make_can_msg("BRAKE_COMMAND", 2, {}))
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
5 years ago
# *** radar bus ***
if idx % 5 == 0:
msg.append(rpacker.make_can_msg("RADAR_DIAGNOSTIC", 1, {"RADAR_STATE": 0x79}))
for i in range(16):
msg.append(rpacker.make_can_msg("TRACK_%d" % i, 1, {"LONG_DIST": 255.5}))
pm.send('can', can_list_to_can_capnp(msg))
def sendcan_function(sendcan):
sc = messaging.drain_sock_raw(sendcan)
cp.update_strings(sc, sendcan=True)
if cp.vl[0x1fa]['COMPUTER_BRAKE_REQUEST']:
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
5 years ago
brake = cp.vl[0x1fa]['COMPUTER_BRAKE'] / 1024.
else:
brake = 0.0
if cp.vl[0x200]['GAS_COMMAND'] > 0:
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
5 years ago
gas = ( cp.vl[0x200]['GAS_COMMAND'] + 83.3 ) / (0.253984064 * 2**16)
else:
gas = 0.0
if cp.vl[0xe4]['STEER_TORQUE_REQUEST']:
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
5 years ago
steer_torque = cp.vl[0xe4]['STEER_TORQUE']/3840
else:
steer_torque = 0.0
dockerize carla + openpilot (#2011) * dockerize carla + openpilot * separate dockerfile * bring back CI dockerfile * cleanup bridge * add op docker build and start script * build container in CI * fix camerad hack * remove most magic numbers from bridge.py * openpilot-sim docker build and run scripts * fix dmonitoring hacks * revert controlsd hacks * clean up build scripts * singular * fix path * fix image name * modify sim readme * sim readme and start script changes * dockerfile with working opengl * working opengl + passing panda build_st in docker * fix bug in sim docker file * bugfix sim docker file * bugfix all op-sim docker issues * modify readme + run script * IT DRIVES * clean this up * more cleanup * cleanup docker stuff * more cleanup * start with openpilot-base * install carla python package * Script is not in lib * chmod * everything should be running in docker now, the code may not be nice though * works locally... * rhdChecked is deprecated * Checkout using git lfs when building sim container * try to pass the tests * pull latest docker * gps should not throw an error on openpilot launch in bridge.py * fixed a coding style error * Only start ubloxd in car * fixed more style problems * revert typo * Use enviromental variable to prevent errors in a simulator * Remove unused import * Attempt to fix missing enviromental variable * fix typo * less work for users, auto tmux engagement * less work for users, auto tmux engagement * fix check for nvidia * clean up nvidia check * remove typo, shorted dockerfile Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com> Co-authored-by: Willem Melching <willem.melching@gmail.com> Co-authored-by: Bruce Wayne <batman@workstation-eu-gregor.eu.local> Co-authored-by: Gregor Kikelj <gregor1234567890@gmail.com> old-commit-hash: c5dfbe7a72c6f31a0aa3a32b6df3f81409b40faf
5 years ago
return gas, brake, steer_torque