Skip to content

Commit

Permalink
Run cpplint checks
Browse files Browse the repository at this point in the history
  • Loading branch information
NestorDP committed Aug 11, 2023
1 parent 397508a commit 2a04439
Show file tree
Hide file tree
Showing 10 changed files with 182 additions and 196 deletions.
34 changes: 16 additions & 18 deletions littlebot_base/include/littlebot_base/littlebot_hardware.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#ifndef LITTLEBOT_BASE__LITTLEBOT_HARDWARE_HPP_
#define LITTLEBOT_BASE__LITTLEBOT_HARDWARE_HPP_
// @ Copyright 2023 Nestor Neto

#ifndef LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_LITTLEBOT_HARDWARE_HPP_
#define LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_LITTLEBOT_HARDWARE_HPP_

#include <chrono>
#include <memory>
#include <sstream>
#include <string>
Expand All @@ -26,25 +27,23 @@
#include "rclcpp/time.hpp"


using namespace std::chrono_literals;

namespace littlebot_base
{
class LittlebotHardware
: public hardware_interface::BaseInterface<hardware_interface::SystemInterface>
{

public:
namespace littlebot_base {
class LittlebotHardware : public
hardware_interface::BaseInterface<hardware_interface::SystemInterface> {
public:
RCLCPP_SHARED_PTR_DEFINITIONS(LittlebotHardware)

HARDWARE_INTERFACE_PUBLIC
hardware_interface::return_type configure(const hardware_interface::HardwareInfo & info) override;
hardware_interface::return_type
configure(const hardware_interface::HardwareInfo & info) override;

HARDWARE_INTERFACE_PUBLIC
std::vector<hardware_interface::StateInterface> export_state_interfaces() override;
std::vector<hardware_interface::StateInterface>
export_state_interfaces() override;

HARDWARE_INTERFACE_PUBLIC
std::vector<hardware_interface::CommandInterface> export_command_interfaces() override;
std::vector<hardware_interface::CommandInterface>
export_command_interfaces() override;

HARDWARE_INTERFACE_PUBLIC
hardware_interface::return_type start() override;
Expand All @@ -58,7 +57,7 @@ class LittlebotHardware
HARDWARE_INTERFACE_PUBLIC
hardware_interface::return_type write() override;

private:
private:
// Store the command for the simulated robot
double left_command_velocity_ = 0;
double right_command_velocity_ = 0;
Expand All @@ -76,9 +75,8 @@ class LittlebotHardware
// Serial device
serial::Serial serial_device_;
std::string message_protocol_;

};

} // namespace littlebot_base

#endif // LITTLEBOT_BASE__LITTLEBOT_HARDWARE_HPP_
#endif // LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_LITTLEBOT_HARDWARE_HPP_
15 changes: 7 additions & 8 deletions littlebot_base/include/littlebot_base/protocol.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
*
*
*/
#ifndef _BASE__COMMUNICATION_PROTOCOL_HPP_
#define _BASE__COMMUNICATION_PROTOCOL_HPP_
#ifndef LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_PROTOCOL_HPP_
#define LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_PROTOCOL_HPP_

#include <errno.h>
#include <fcntl.h>
Expand All @@ -25,7 +25,7 @@
#include <libserial/serial.hpp>


namespace littlebot{
namespace littlebot {

class Protocol {
public:
Expand All @@ -34,7 +34,7 @@ class Protocol {
* @brief Constructor of the serial class
*
*/
Protocol(std::string port);
explicit Protocol(std::string port);

/**
* @brief Destroyer of the serial class
Expand Down Expand Up @@ -72,16 +72,15 @@ class Protocol {
const int kLengthBuffer_ = 200;

/** Port */
serial::Serial port_ ;
serial::Serial port_;

/** Buffer */
std::string msg_protocol_;

/** */
float velocity_read_[2];
float velocity_write_[2];

};
} // namespace serial
} // namespace littlebot

#endif // _BASE__COMMUNICATION_PROTOCOL_HPP_
#endif // LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_PROTOCOL_HPP_
57 changes: 28 additions & 29 deletions littlebot_base/include/littlebot_base/reader.hpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
// Copyright 2022 Nestor

#ifndef LITTLEBOT_BASE_READER_HPP_
#define LITTLEBOT_BASE_READER_HPP_
#ifndef LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_READER_HPP_
#define LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_READER_HPP_

#include <string>
#include <chrono>
#include <iostream>
#include <memory>
#include <utility>
Expand All @@ -21,29 +20,29 @@
#define LITTLEBOT_BASE_READER_PUBLIC __attribute__((visibility("default")))

namespace littlebot_base {
class Reader : public rclcpp::Node
{
public:
LITTLEBOT_BASE_READER_PUBLIC
explicit Reader(const rclcpp::NodeOptions &options);

LITTLEBOT_BASE_READER_PUBLIC
explicit Reader(const rclcpp::NodeOptions & options, serial::Serial *serial);

protected:
void on_timer();

private:
size_t count_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub1_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub2_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub3_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub4_;
rclcpp::TimerBase::SharedPtr timer_;
std::string message_;
serial::Serial *serial_;
};

} // namespace littlebot_base

#endif // LITTLEBOT_BASE_READER_HPP_

class Reader : public rclcpp::Node {
public:
LITTLEBOT_BASE_READER_PUBLIC
explicit Reader(const rclcpp::NodeOptions &options);

LITTLEBOT_BASE_READER_PUBLIC
explicit Reader(const rclcpp::NodeOptions & options, serial::Serial *serial);

protected:
void on_timer();

private:
size_t count_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub1_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub2_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub3_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub4_;
rclcpp::TimerBase::SharedPtr timer_;
std::string message_;
serial::Serial *serial_;
};

} // namespace littlebot_base

#endif // LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_READER_HPP_
78 changes: 39 additions & 39 deletions littlebot_base/include/littlebot_base/writer.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@

// Copyright Nestor 2022

#ifndef LITTLEBOT_BASE_WRITER_HPP_
#define LITTLEBOT_BASE_WRITER_HPP_
#ifndef LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_WRITER_HPP_
#define LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_WRITER_HPP_

#include <string>
#include <sstream>
#include <chrono>
#include <iostream>
#include <memory>
#include <utility>
Expand All @@ -22,40 +20,42 @@
#define LITTLEBOT_BASE_WRITER_CPP_LOCAL __attribute__ ((visibility("hidden")))

namespace littlebot_base {
class Writer : public rclcpp::Node {
public:
LITTLEBOT_BASE_WRITER_CPP_PUBLIC
explicit Writer(const rclcpp::NodeOptions & options);

LITTLEBOT_BASE_WRITER_CPP_PUBLIC
explicit Writer(const rclcpp::NodeOptions & options, serial::Serial *serial);

protected:
void writerTimer();

private:
/* Command right velocity subscriber*/
rclcpp::Subscription<example_interfaces::msg::Float32>::SharedPtr cmd_right_vel_sub_;
/* Command right velocity subscriber*/
rclcpp::Subscription<example_interfaces::msg::Float32>::SharedPtr cmd_left_vel_sub_;

rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub1_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub2_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub3_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub4_;

std::stringstream msg_protocol_;
std::string send_msg_;

/*Right velocite variable*/
float right_vel_;
/*Left velocite variable*/
float left_vel_;
/*Serial port object*/
serial::Serial *serial_;
/* */
rclcpp::TimerBase::SharedPtr timer_writer_;
};
class Writer : public rclcpp::Node {
public:
LITTLEBOT_BASE_WRITER_CPP_PUBLIC
explicit Writer(const rclcpp::NodeOptions & options);

LITTLEBOT_BASE_WRITER_CPP_PUBLIC
explicit Writer(const rclcpp::NodeOptions & options, serial::Serial *serial);

protected:
void writerTimer();

private:
/* Command right velocity subscriber*/
rclcpp::Subscription<example_interfaces::msg::Float32>::SharedPtr
cmd_right_vel_sub_;
/* Command right velocity subscriber*/
rclcpp::Subscription<example_interfaces::msg::Float32>::SharedPtr
cmd_left_vel_sub_;

rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub1_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub2_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub3_;
rclcpp::Publisher<example_interfaces::msg::Float32>::SharedPtr pub4_;

std::stringstream msg_protocol_;
std::string send_msg_;

/*Right velocite variable*/
float right_vel_;
/*Left velocite variable*/
float left_vel_;
/*Serial port object*/
serial::Serial *serial_;
/* */
rclcpp::TimerBase::SharedPtr timer_writer_;
};
} // namespace littlebot_base

#endif // LITTLEBOT_BASE_WRITER_HPP_
#endif // LITTLEBOT_BASE_INCLUDE_LITTLEBOT_BASE_WRITER_HPP_
19 changes: 3 additions & 16 deletions littlebot_base/src/littlebot_base_composition.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,4 @@
// Copyright 2016 Open Source Robotics Foundation, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// @ Copyright 2023 Nestor Neto

#include <memory>

Expand All @@ -22,8 +10,7 @@

#include <libserial/serial.hpp>

int main(int argc, char * argv[])
{
int main(int argc, char * argv[]) {
setvbuf(stdout, NULL, _IONBF, BUFSIZ);

rclcpp::init(argc, argv);
Expand All @@ -40,7 +27,7 @@ int main(int argc, char * argv[])

// exec.add_node(reader);
exec.add_node(writer);

exec.spin();
rclcpp::shutdown();

Expand Down
Loading

0 comments on commit 2a04439

Please sign in to comment.