-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from carnegiemellonracing/controller-arch-deve…
…lopment Controller arch development
- Loading branch information
Showing
191 changed files
with
3,022 additions
and
324,643 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Submodule HesaiLidar_ROS_2.0
updated
from d08974 to 941b3c
Submodule common_interfaces
deleted from
366eea
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
## Conventions | ||
|
||
Conventions for the controls subteam code. | ||
|
||
### Naming | ||
|
||
Use python naming: | ||
|
||
- ``lower_snake_case`` for values (including functions/methods, 150 moment) | ||
- Reason: ``lowerCamelCase`` is just ugly | ||
- ``PascalCase`` for types | ||
- Reason: prevents declaration issues like ``car car;`` | ||
- Namespace-level declarations should have namespae corresponding to their directory | ||
- e.g. a declaration in ``src/mppi`` should belong to namespace ``controls::mppi`` | ||
|
||
|
||
### Code Style | ||
|
||
- Follow the cpp core guidelines, except for anything that uses the GSL. Or is otherwise clearly dumb. | ||
- Misc. notes: | ||
- use uniform initialization (`{...}` constructor syntax) wherever possible. | ||
- Reason: far more | ||
readable than `(...)` in many cases (looks like a function call/declaration) | ||
- `m_` prefix should be used for all private fields | ||
- Reason: disambiguates fields from parameters before it becomes an issue. If you wait until | ||
you notice ambiguity, you're already too late! | ||
- By defualt, prefer immutable data (i.e. `const` lvalues). This also necessitates marking | ||
methonds `const` wherever possible. | ||
- Reason: _especially_ since we're multithreading, this makes code easier to reason about. Also | ||
makes it easier for the compiler to reason about. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include <rclcpp/rclcpp.hpp> | ||
|
||
#include "types.hpp" | ||
|
||
|
||
namespace controls { | ||
|
||
/* ROS moments */ | ||
|
||
constexpr const char *controller_node_name = "controller"; | ||
constexpr const char *control_action_topic_name = "control_action"; | ||
const rclcpp::QoS control_action_qos (rclcpp::KeepLast(10)); | ||
|
||
|
||
// MPPI stuff | ||
|
||
constexpr Device default_device = Device::Cuda; | ||
|
||
/** Controller target frequency, in Hz */ | ||
constexpr double controller_freq = 50.; | ||
|
||
/** Controller target period, in sec */ | ||
constexpr auto controller_period = std::chrono::operator""ms(1000. / controller_freq); | ||
constexpr uint num_samples = 1024; | ||
constexpr uint num_timesteps = 128; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include "cuda_types.cuh" | ||
|
||
namespace controls { | ||
constexpr csize num_spline_interpolations = 512; | ||
constexpr cfloat spline_interpolation_separation = 0.5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
namespace controls { | ||
using cfloat = float; | ||
using csize = unsigned int; | ||
} |
23 changes: 23 additions & 0 deletions
23
driverless_ws/src/controls/src/interface/cpu_environment.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "cpu_environment.hpp" | ||
|
||
namespace controls { | ||
namespace interface { | ||
void CpuEnvironment::update_spline(const SplineMsg& msg) { | ||
} | ||
|
||
void CpuEnvironment::update_slam(const SlamMsg& msg) { | ||
} | ||
|
||
void CpuEnvironment::update_gps(const GpsMsg& msg) { | ||
} | ||
|
||
State CpuEnvironment::get_curv_state() const { | ||
} | ||
|
||
State CpuEnvironment::get_world_state() const { | ||
} | ||
|
||
double CpuEnvironment::get_curvature(double progress_from_current) const { | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
driverless_ws/src/controls/src/interface/cpu_environment.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include <planning/src/planning_codebase/raceline/raceline.hpp> | ||
#include <interfaces/msg/spline_list.hpp> | ||
|
||
#include "interface.hpp" | ||
|
||
|
||
namespace controls { | ||
namespace interface { | ||
class CpuEnvironment : public Environment { | ||
public: | ||
CpuEnvironment() = default; | ||
|
||
void update_spline(const SplineMsg& msg) override; | ||
void update_slam(const SlamMsg& msg) override; | ||
void update_gps(const GpsMsg& msg) override; | ||
|
||
State get_curv_state() const override; | ||
State get_world_state() const override; | ||
double get_curvature(double progress_from_current) const override; | ||
}; | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
driverless_ws/src/controls/src/interface/cuda_environment.cu
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#include <exception> | ||
|
||
#include "cuda_environment.cuh" | ||
|
||
|
||
namespace controls { | ||
namespace interface { | ||
void CudaEnvironment::update_spline(const controls::SplineMsg &msg) { | ||
throw std::runtime_error("cuda spline update not implemented"); | ||
} | ||
|
||
void CudaEnvironment::update_gps(const controls::SplineMsg &msg) { | ||
throw std::runtime_error("cuda spline update not implemented"); | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
driverless_ws/src/controls/src/interface/cuda_environment.cuh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <types.hpp> | ||
#include <cuda_types.cuh> | ||
#include <cuda_constants.cuh> | ||
#include <cuda_types.cuh> | ||
#include <planning/src/planning_codebase/raceline/raceline.hpp> | ||
|
||
#include "interface.hpp" | ||
|
||
|
||
namespace controls { | ||
namespace cuda { | ||
cfloat* d_spline_curvatures; // allocated on first CudaEnvironment construction | ||
} | ||
|
||
namespace interface { | ||
// should be able to be constructed/destructed multiple times without an issue | ||
// but there can only be one at once | ||
class CudaEnvironment : public Environment { | ||
public: | ||
void update_spline(const SplineMsg& msg) override; | ||
void update_slam(const SlamMsg& msg) override; | ||
void update_gps(const GpsMsg& msg) override; | ||
|
||
State get_curv_state() const override; | ||
State get_world_state() const override; | ||
double get_curvature(double progress_from_current) const override; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include "interface.hpp" | ||
|
||
|
||
namespace controls { | ||
namespace interface { | ||
bool Environment::get_valid() const { | ||
return m_valid; | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#ifndef CONTROLS_INTERFACE_HPP | ||
#define CONTROLS_INTERFACE_HPP | ||
|
||
#include <mutex> | ||
#include <condition_variable> | ||
#include <types.hpp> | ||
|
||
namespace controls { | ||
namespace interface { | ||
class Environment { | ||
public: | ||
virtual ~Environment () =0; | ||
|
||
virtual void update_spline(const SplineMsg& msg) =0; | ||
virtual void update_slam(const SlamMsg& msg) =0; | ||
virtual void update_gps(const GpsMsg& msg) =0; | ||
|
||
virtual State get_curv_state() const =0; | ||
virtual State get_world_state() const =0; | ||
virtual double get_curvature(double progress_from_current) const =0; | ||
|
||
bool get_valid() const; | ||
|
||
|
||
std::mutex mutex; | ||
|
||
protected: | ||
bool m_valid {false}; | ||
}; | ||
} | ||
} | ||
|
||
|
||
// included so other classes only need to include one header for all of them | ||
// at bottom to avoid loop | ||
|
||
#include "cpu_environment.hpp" | ||
|
||
#ifndef CONTROLS_NO_CUDA | ||
#include "cuda_environment.cuh" | ||
#endif | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "cpu_mppi.hpp" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
#include <types.hpp> | ||
|
||
#include "mppi.hpp" | ||
|
||
|
||
namespace controls { | ||
namespace mppi { | ||
class CpuMppiController : public MppiController { | ||
public: | ||
Action generate_action(const State& current_state) override; | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#include "cuda_mppi.cuh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#pragma once |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#pragma once | ||
|
||
|
||
namespace controls { | ||
namespace mppi { | ||
class MppiController : public Controller { }; | ||
} | ||
} | ||
|
||
|
||
#include "cpu_mppi.hpp" | ||
|
||
#ifndef CONTROLS_NO_CUDA | ||
#include "cuda_mppi.cuh" | ||
#endif |
Oops, something went wrong.