CARLA
 
载入中...
搜索中...
未找到
pytorch.h
浏览该文件的文档.
1// Copyright (c) 2022 Computer Vision Center (CVC) at the Universitat Autonoma de Barcelona (UAB).
2// This work is licensed under the terms of the MIT license.
3// For a copy, see <https://opensource.org/licenses/MIT>.
4
5#pragma once
6#define _GLIBCXX_USE_CXX11_ABI 0
7
8#include <memory>
9#include <vector> // 包含标准库中的智能指针和向量容器
10
11namespace carla {
12namespace learning {
13
14 void test_learning(); // 测试学习功能的函数
15
16 struct NeuralModelImpl; // 神经网络模型的实现细节
17
18 struct WheelInput { // 车轮输入数据结构
19 public:
20 int num_particles = 0; // 粒子数量
21 float* particles_positions; // 粒子位置数组
22 float* particles_velocities; // 粒子速度数组
23 float* wheel_positions; // 车轮位置数组
24 float* wheel_oritentation; // 车轮方向数组
25 float* wheel_linear_velocity; // 车轮线速度数组
26 float* wheel_angular_velocity; // 车轮角速度数组
27 };
28
29 struct Inputs { // 输入数据结构
30 public:
34 WheelInput wheel3; // 四个车轮的输入数据
35 float steering = 0;
36 float throttle = 0;
37 float braking = 0; // 转向、油门和刹车的输入值
38 int terrain_type = 0; // 地形类型
39 bool verbose = false; // 是否输出详细信息
40 };
41
42 struct WheelOutput { // 车轮输出数据结构
43 public:
44 float wheel_forces_x = 0;
45 float wheel_forces_y = 0;
46 float wheel_forces_z = 0;
47 float wheel_torque_x = 0;
48 float wheel_torque_y = 0;
49 float wheel_torque_z = 0; // 车轮的力和扭矩
50 std::vector<float> _particle_forces; // 粒子受力数组
51 };
52 struct Outputs {
53 public:
57 WheelOutput wheel3; // 四个车轮的输出数据
58 };
59
60 // 与PyTorch实现的接口
62 public:
63
64 NeuralModel(); // 构造函数
65 void LoadModel(char* filename, int device); // 加载模型
66
67 void SetInputs(Inputs input); // 设置输入数据
68 void Forward(); // 执行前向传播
69 void ForwardDynamic(); // 执行动态前向传播
70 void ForwardCUDATensors(); // 使用CUDA张量执行前向传播
71 Outputs& GetOutputs(); // 获取输出数据
72
73 ~NeuralModel(); // 析构函数
74
75 private:
76 std::unique_ptr<NeuralModelImpl> Model; // 模型的私有实现
78 Outputs _output; // 输入和输出数据
79 };
80
81}
82}
void LoadModel(char *filename, int device)
Definition pytorch.cpp:191
std::unique_ptr< NeuralModelImpl > Model
Definition pytorch.h:76
void SetInputs(Inputs input)
Definition pytorch.cpp:214
void test_learning()
Definition pytorch.cpp:27
CARLA模拟器的主命名空间。
Definition Carla.cpp:139
std::vector< float > _particle_forces
Definition pytorch.h:50