Skip to content

Commit

Permalink
Compile littlebot_base package with protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
NestorDP committed Jan 22, 2025
1 parent 4b5d8ec commit dc30467
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 38 deletions.
24 changes: 12 additions & 12 deletions littlebot_base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@ find_package(Protobuf REQUIRED)

include_directories(include)

# Print some protobuf info (optional)
# Print some protobuf info
message(STATUS "Using Protocol Buffers: ${Protobuf_VERSION}")
message(STATUS "Protobuf include directory: ${Protobuf_INCLUDE_DIRS}")
message(STATUS "Protobuf libraries: ${Protobuf_LIBRARIES}")

# Add your proto file
# set(PROTO_FILES
# src/littlebot_protocol.proto
# )
set(PROTO_FILES
src/littlebot_protocol.proto
)

# Generate sources and headers from .proto
# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS ${PROTO_FILES})

# Add include directories
# include_directories(
# ${Protobuf_INCLUDE_DIRS}
# ${CMAKE_CURRENT_BINARY_DIR} # This is where generated files will be
# )
include_directories(
${Protobuf_INCLUDE_DIRS}
${CMAKE_CURRENT_BINARY_DIR} # This is where generated files will be
)

# create ament index resource which references the libraries in the binary dir
set(node_plugins "")

# Hardware interface
add_library(littlebot_hardware_component SHARED
src/littlebot_hardware_component.cpp
src/littlebot_hardware_communication.cpp
# ${PROTO_SRCS}
# ${PROTO_HDRS}
src/littlebot_serial_communication.cpp
${PROTO_SRCS}
${PROTO_HDRS}
)

ament_target_dependencies(littlebot_hardware_component
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
namespace littlebot_base
{

class HardwareCommunication{
class LittlebotCommunicationInterface{
public:
/**
* @brief Deconstructor for the HardwareCommunication class
* @brief Deconstructor for the LittlebotCommunicationInterface class
*
*/
virtual ~HardwareCommunication() = default;
virtual ~LittlebotCommunicationInterface() = default;

/**
* @brief Set the command velocities
Expand All @@ -33,9 +33,9 @@ class HardwareCommunication{

protected:
/**
* @brief Constructor for the LittlebotHardwareCommunication class
* @brief Constructor for the LittlebotLittlebotCommunicationInterface class
*/
HardwareCommunication() = default;
LittlebotCommunicationInterface() = default;

private:
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@

#include <libserial/serial.hpp>

#include "littlebot_base/hardware_communication.hpp"
#include "littlebot_base/littlebot_communication_interface.hpp"

namespace littlebot_base
{

class LittlebotHardwareCommunication : public HardwareCommunication
class LittlebotSerialCommunication : public LittlebotCommunicationInterface
{
public:
/**
* @brief Constructor for the LittlebotLittlebotHardwareCommunication class
* @brief Constructor for the LittlebotSerialCommunication class
*/
LittlebotHardwareCommunication(const std::string serial_port);
LittlebotSerialCommunication(const std::string serial_port);

/**
* @brief Deconstructor for the LittlebotHardwareCommunication class
* @brief Deconstructor for the LittlebotSerialCommunication class
*/
~LittlebotHardwareCommunication();
~LittlebotSerialCommunication();

/**
* @brief Set the command velocities
Expand Down
30 changes: 15 additions & 15 deletions littlebot_base/src/littlebot_serial_communication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,49 @@
#include <string>
#include <vector>

#include "littlebot_base/littlebot_hardware_comunication.hpp"
#include "littlebot_base/littlebot_serial_communication.hpp"

namespace littlebot_base
{
LittlebotHardwareCommunication::LittlebotHardwareCommunication(const std::string serial_port)
LittlebotSerialCommunication::LittlebotSerialCommunication(const std::string serial_port)
{
std::cout << "LittlebotHardwareCommunication constructor" << serial_port << std::endl;
std::cout << "LittlebotSerialCommunication constructor" << serial_port << std::endl;

serial_ = std::make_shared<serial::Serial>();
serial_->open(serial_port);
}

LittlebotHardwareCommunication::~LittlebotHardwareCommunication()
LittlebotSerialCommunication::~LittlebotSerialCommunication()
{
std::cout << "LittlebotHardwareCommunication deconstructor" << std::endl;
std::cout << "LittlebotSerialCommunication deconstructor" << std::endl;
}

void LittlebotHardwareCommunication::setCommandVelocities([[maybe_unused]] std::vector<float> velocities)
void LittlebotSerialCommunication::setCommandVelocities([[maybe_unused]] std::vector<float> velocities)
{
std::cout << "LittlebotHardwareCommunication setCommandVelocities" << std::endl;
std::cout << "LittlebotSerialCommunication setCommandVelocities" << std::endl;
}

std::vector<float> LittlebotHardwareCommunication::getStatusVelocities() const
std::vector<float> LittlebotSerialCommunication::getStatusVelocities() const
{
std::cout << "LittlebotHardwareCommunication getStatusVelocities" << std::endl;
std::cout << "LittlebotSerialCommunication getStatusVelocities" << std::endl;
return std::vector<float>{1.2, 3.4};
}

std::vector<float> LittlebotHardwareCommunication::getStatusPositionsStatus() const
std::vector<float> LittlebotSerialCommunication::getStatusPositionsStatus() const
{
std::cout << "LittlebotHardwareCommunication getStatusPositionsStatus" << std::endl;
std::cout << "LittlebotSerialCommunication getStatusPositionsStatus" << std::endl;
return std::vector<float>{1.2, 3.4};
}

bool LittlebotHardwareCommunication::receive()
bool LittlebotSerialCommunication::receive()
{
std::cout << "LittlebotHardwareCommunication receive" << std::endl;
std::cout << "LittlebotSerialCommunication receive" << std::endl;
return true;
}

bool LittlebotHardwareCommunication::send()
bool LittlebotSerialCommunication::send()
{
std::cout << "LittlebotHardwareCommunication send" << std::endl;
std::cout << "LittlebotSerialCommunication send" << std::endl;
return true;
}

Expand Down

0 comments on commit dc30467

Please sign in to comment.