Skip to content

Commit

Permalink
add publisher
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodenstein authored and Bodenstein committed Nov 21, 2024
1 parent 9bf64b7 commit 1c12dab
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions apps/speed_limit_assist/speed_limit_assist.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import ecal.core.core as ecal_core
from ecal.core.subscriber import StringSubscriber
from ecal.core.publisher import StringPublisher

logger = logging.getLogger("speed_limit_assist")
stdout = logging.StreamHandler(stream=sys.stdout)
Expand Down Expand Up @@ -68,8 +69,6 @@ def vehicle_dynamics_callback(topic_name, msg, time):
json_msg = json.loads(msg)
speed = json_msg["signals"]["speed"]
speedLimitAssist.vel_mps = speed
if speedLimitAssist.limit > 0.0:
speedLimitAssist.check_speed_limit()
except json.JSONDecodeError:
logger.error(f"Error: Could not decode message: '{msg}'")
except Exception as e:
Expand Down Expand Up @@ -144,8 +143,16 @@ def traffic_sign_detection_callback(topic_name, msg, time):
tsd_sub.set_callback(traffic_sign_detection_callback)
vd_sub.set_callback(vehicle_dynamics_callback)


sla_pub = StringPublisher("sla_topic")

if speedLimitAssist.limit > 0.0:
exceededSpeed = speedLimitAssist.check_speed_limit()

# Just don't exit
while ecal_core.ok():
if exceededSpeed > 0:
sla_pub("Warning: Youre to fast!")
time.sleep(0.5)

# finalize eCAL API
Expand Down

0 comments on commit 1c12dab

Please sign in to comment.