Skip to content

Commit

Permalink
Able to get Lidar Device from Daemon
Browse files Browse the repository at this point in the history
  • Loading branch information
Chi-EEE committed Apr 16, 2024
1 parent cf3378e commit cc138e0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
1 change: 0 additions & 1 deletion app/rpi/common/src/car/system/CarSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ namespace car::system
output_json.Accept(writer);

std::string output_json_string = buffer.GetString();
spdlog::info("Sending message: {}", output_json_string);
this->messaging_system_->sendMessage(output_json_string);
}

Expand Down
7 changes: 6 additions & 1 deletion app/rpi/daemon/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ class rpi_daemon : public daemon
dlog::info(fmt::format("Started daemon with host: {}", host));
configuration->host = host;

const std::string lidar_port = reader.GetString("RaspberryPi", "lidar_port", "");
#ifdef __linux
const std::string default_lidar_port = "/dev/ttyUSB0";
#else
const std::string default_lidar_port = "COM3";
#endif
const std::string lidar_port = reader.GetString("RaspberryPi", "lidar_port", default_lidar_port);
dlog::info(fmt::format("Using lidar port: {}", lidar_port));
configuration->lidar_port = lidar_port;

Expand Down
9 changes: 4 additions & 5 deletions app/rpi/tui/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ using namespace car::display::console;
using namespace car::configuration;
using namespace car::plugin;

std::unique_ptr<LidarDevice> getLidarDevice();
std::unique_ptr<LidarDevice> getLidarDevice(std::shared_ptr<Configuration> configuration);
std::unique_ptr<AbstractMovementController> getMovementController();

int main(int argc, char* argv[])
Expand All @@ -73,7 +73,7 @@ int main(int argc, char* argv[])
}

std::unique_ptr<CameraDevice> camera_device = std::move(maybe_camera_device.value());
std::unique_ptr<LidarDevice> lidar_device = getLidarDevice();
std::unique_ptr<LidarDevice> lidar_device = getLidarDevice(configuration);

std::unique_ptr<DeviceManager> device_manager = std::make_unique<DeviceManager>(std::move(camera_device), std::move(lidar_device));

Expand Down Expand Up @@ -107,10 +107,9 @@ int main(int argc, char* argv[])
return EXIT_SUCCESS;
}

std::unique_ptr<lidar::LidarDevice> getLidarDevice()
std::unique_ptr<lidar::LidarDevice> getLidarDevice(std::shared_ptr<Configuration> configuration)
{
Configuration configuration;
auto maybe_scanner = LidarScanner::create(std::make_shared<Configuration>(configuration));
auto maybe_scanner = LidarScanner::create(configuration);
if (maybe_scanner.has_value())
{
spdlog::info("Found and using Lidar Scanner\n");
Expand Down

0 comments on commit cc138e0

Please sign in to comment.