Robotics at Compile Time: Optimizing Robotics Algorithms With C++'s Compile-Time Features - CppCon23

Sdílet
Vložit
  • čas přidán 9. 06. 2024
  • cppcon.org/
    ---
    Robotics at Compile Time: Optimizing Robotics Algorithms With C++'s Compile-Time Features - Stephen Brawner - CppCon 2023
    github.com/CppCon/CppCon2023
    Development of real-time software for robots allows for strategic use of compile-time programming techniques to optimize performance, latency, and memory usage. The speaker will present how template metaprogramming, the constexpr family of features, concepts and std::enable_if can benefit robotics algorithms and code through concrete examples. Beyond optimization, the speaker will discuss how these features can also enable many safety-critical checks before run-time. The speaker's goal of this talk is for attendees both in robotics and outside to learn how they may be able to move more of their software's evaluation to the compiler.
    The speaker's examples will include common robotics programming tasks like kinematics, collision checking, and cartesian control. Historically, robot-agnostic software for these tasks was written to be compiled once and deployed across numerous robotics platforms. This necessitated hardware description files to be ingested on startup and then verified before operating the robot. These approaches require dynamic memory allocation, run-time polymorphism and other approaches that prevent compiler optimizations, static analysis and are not compatible with real-time operation. For many applications in robotics, however, the requirements of the robotics platform are known well in advance and can be leveraged to generate software heavily optimized by the compiler.
    ---
    Stephen Brawner
    As a lifelong maker of innovative mixed hardware-software artifacts, Dr. Stephen Brawner is experienced in engineering and computer science with a passion for robotics and automation. He has designed, built and programmed a variety of robotics platforms in many industries including solar, surgical robotics, and construction robotics. Currently, Stephen works as a software development consultant in robotics.
    ---
    Videos Filmed & Edited by Bash Films: www.BashFilms.com
    CZcams Channel Managed by Digital Medium Ltd: events.digital-medium.co.uk
    ---
    Registration for CppCon: cppcon.org/registration/
    #cppcon #cppprogramming #cpp #robotics
  • Věda a technologie

Komentáře • 11

  • @Roibarkan
    @Roibarkan Před 4 měsíci +3

    33:17 I’d try to make use of std::integer_sequence for the iteration over the tuples, and check get(shapes) for collision with get(shapes) only if (i

  • @SpltJule
    @SpltJule Před 4 měsíci +5

    I have heard that we should avoid dynamic allocation in real-time applications. Some people also claim that it was specified in safety standards. However, I found that ROS relies on dynamic allocation a lot, although ROS is a robotics framework. Why is that?

    • @martinwudenka5668
      @martinwudenka5668 Před 3 měsíci +1

      Because only a tiny fraction of the robots software stack needs to be hard realtime capable. For this there is microROS.
      E.g. in ASIL there is also the possibility to lower the needed safety level with another component. So the existence of an emergency brake system (highest safety level) may lower the safety level of obstacle avoidance.

  • @tahsincankose
    @tahsincankose Před 3 měsíci +2

    It would be nicer if there was a quantitative comparison between run-time vs compile-time collision checking. Besides the poses of meshes/geometries differ in run-time, so I don't think it can be fully optimized through TMP tricks. It should be also noted that such TMP would incur significant compile-time, which is certainly not desirable for CI systems where you have a big chunk of robotics software with possibly hundreds of packages, i.e. you cannot say that "compile-time is unimportant". My point is that if the run-time gain is not dramatic, then TMP can bring more trouble than it is worth. I didn't even mention the totally devastated code readability due to TMP.

  • @2kilhun
    @2kilhun Před 4 měsíci

    thank you

  • @Roibarkan
    @Roibarkan Před 4 měsíci

    11:39 David Stone’s talk: czcams.com/video/I8QJLGI0GOE/video.html

  • @sirhenrystalwart8303
    @sirhenrystalwart8303 Před 4 měsíci

    It's unfortunate that constexpr is allowed to allocate now. That is a pretty big step backwards.

    • @drinductor8150
      @drinductor8150 Před 3 měsíci +1

      The allocation cannot pass the compile-time=>runtime boundary though. It's actually very useful since you can now use std::vector and std::string inside constexpr lambdas/functions

  • @peregrin71
    @peregrin71 Před 3 měsíci

    39:20 If you have the enum class for your strategy, you can remove a lot of indirections. Add a `constexpr if` inside the original push_back of your ring buffer to instantiate the selected behavior.

    • @StephenBrawner-uk8xy
      @StephenBrawner-uk8xy Před 2 měsíci

      The great thing about these compile-time features is that there are several ways to write them but get the same benefits. The compiled binary will look the same regardless of your preferred compile-time techniques. If you like 'constexpr if' over a type trait selection like I show, then it's truly a matter of preference. Hopefully I was able to show off a couple of different techniques of how to achieve these optimizations.