Skip to content

Commit

Permalink
Code refactoring
Browse files Browse the repository at this point in the history
- new driver_sim base class added
- driver_sim packages are modified
  - protobuf messages are moved into 'driver_sim' packages
  • Loading branch information
hyunseok-yang committed May 29, 2020
1 parent d7cd529 commit 0aa45bd
Show file tree
Hide file tree
Showing 172 changed files with 850 additions and 946 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ tags


# to ignore generated code
sim_bridge/include/protobuf/*
driver_sim/include/protobuf/*
19 changes: 13 additions & 6 deletions bringup/config/params.sim_devices.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ lidar_driver:
sim:
model: "cloi"
parts: "lidar"
ip_address: "127.0.0.1"
manager_ip: "127.0.0.1"
manager_port: 25554

remapping_list: ['/tf', '/tf_static']
Expand All @@ -28,11 +28,18 @@ micom_driver:
model: "cloi"
parts_tx: "MICOM_INPUT"
parts_rx: "MICOM_SENSOR"
ip_address: "127.0.0.1"
manager_ip: "127.0.0.1"
manager_port: 25554

remapping_list: ['/tf', '/tf_static']

transform:
base: [0.0, 0.0, 0.01, 0.0, 0.0, 0.0]
imu: [0.0, 0.0, 0.19, 0.0, 0.0, 0.0]
wheel:
left: [0.001, 0.225, 0.07, 0.0, 0.0, 0.0]
right: [0.001, -0.225, 0.07, 0.0, 0.0, 0.0]

wheel:
base: 449.0
radius: 95.5
Expand All @@ -43,8 +50,8 @@ camera_driver:
sim:
model: "cloi"
parts: "camera"
ip_address: "127.0.0.1"
manage_port: 25554
manager_ip: "127.0.0.1"
manager_port: 25554

remapping_list: ['/tf', '/tf_static']

Expand All @@ -59,8 +66,8 @@ multi_camera_driver:
sim:
model: "cloi"
parts: "multi_camera"
ip_address: "127.0.0.1"
manage_port: 25554
manager_ip: "127.0.0.1"
manager_port: 25554

remapping_list: ['/tf', '/tf_static']

Expand Down
2 changes: 1 addition & 1 deletion bringup/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>simdevice_bringup</name>
<version>1.0.0</version>
<version>1.1.0</version>
<description>Bringup scripts and configurations for simdevice</description>

<maintainer email="hyunseok7.yang@lge.com">Hyunseok Yang</maintainer>
Expand Down
17 changes: 3 additions & 14 deletions camera_driver_sim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,15 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic -fstack-protector -O2)
endif()

# add_compile_options(-g -O0)

################################################################################
# Find colcon packages and libraries for colcon and system dependencies
################################################################################
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rmw REQUIRED)
find_package(sensor_msgs REQUIRED)
find_package(tf2 REQUIRED)
find_package(tf2_ros REQUIRED)
find_package(image_transport REQUIRED)
find_package(Boost REQUIRED
COMPONENTS
system
thread
)
find_package(sim_bridge REQUIRED)
find_package(driver_sim REQUIRED)

################################################################################
# Build
Expand All @@ -43,12 +34,10 @@ add_executable(${PROJECT_NAME}

ament_target_dependencies(${PROJECT_NAME}
rclcpp
std_msgs
sensor_msgs
tf2
tf2_ros
image_transport
sim_bridge)
sim_bridge
driver_sim)

################################################################################
# Install
Expand Down
47 changes: 12 additions & 35 deletions camera_driver_sim/include/camera_driver_sim/CameraDriverSim.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @author Sungkyu Kang
* @author hyunseok Yang
* @brief
* ROS2 Depth Camera Driver class for simulator
* ROS2 Camera Driver class for simulator
* @remark
* @warning
* LGE Advanced Robotics Laboratory
Expand All @@ -14,57 +14,34 @@
#ifndef _CameraDriverSim_H_
#define _CameraDriverSim_H_

#include <rclcpp/rclcpp.hpp>
// #include <sensor_msgs/msg/image.hpp>
#include "driver_sim/driver_sim.hpp"
#include <image_transport/image_transport.h>
#include <tf2_ros/static_transform_broadcaster.h>
#include <protobuf/image_stamped.pb.h>
#include "sim_bridge/sim_bridge.hpp"

class CameraDriverSim : public rclcpp::Node
class CameraDriverSim : public DriverSim
{
public:
static std::string GetEncondingType(const uint32_t pixel_format);

CameraDriverSim();
virtual ~CameraDriverSim();

private:
void Start();
void Stop();
void ReadProc();
void UpdateImage();
void UpdateStaticTF(const rclcpp::Time timestamp);
virtual void Initialize();
virtual void Deinitialize();

private:
SimBridge *m_pSimBridge;
bool m_bRun;
bool m_bIntensity;

std::string robot_name_;
std::string part_name_;
std::string topic_name_;
std::string frame_name_;
virtual void UpdateData();

geometry_msgs::msg::TransformStamped camera_tf;

std::thread m_thread;
private:
// key for connection
std::string m_hashKeySub;

// buffer from simulation
gazebo::msgs::ImageStamped m_pbBuf;
sensor_msgs::msg::Image msg_img;

rclcpp::Node::SharedPtr node_handle;
rclcpp::Time m_simTime;
// message for ROS2 communictaion
sensor_msgs::msg::Image msg_img;

// Image publisher
image_transport::Publisher pubImage;

// Timer
rclcpp::TimerBase::SharedPtr timer;

// Static TF
std::shared_ptr<tf2_ros::StaticTransformBroadcaster> static_tf_broadcaster_;

};

#endif
12 changes: 4 additions & 8 deletions camera_driver_sim/package.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<package format="3">
<name>camera_driver_sim</name>
<version>1.0.0</version>
<version>1.1.0</version>
<description>virtual camera driver for simulator</description>
<maintainer email="sungkyu.kang@lge.com">Sungkyu Kang</maintainer>
<maintainer email="hyunseok7.yang@lge.com">Hyunseok Yang</maintainer>
Expand All @@ -11,23 +11,19 @@
<buildtool_depend>ament_cmake</buildtool_depend>

<build_depend>rclcpp</build_depend>
<build_depend>rmw</build_depend>
<build_depend>sensor_msgs</build_depend>
<build_depend>image_transport</build_depend>
<build_depend>tf2</build_depend>
<build_depend>tf2_ros</build_depend>
<build_depend>sim_bridge</build_depend>
<build_depend>driver_sim</build_depend>

<exec_depend>launch_ros</exec_depend>
<exec_depend>rclcpp</exec_depend>
<exec_depend>rmw</exec_depend>
<exec_depend>sensor_msgs</exec_depend>
<exec_depend>image_transport</exec_depend>
<exec_depend>tf2</exec_depend>
<exec_depend>tf2_ros</exec_depend>
<exec_depend>sim_bridge</exec_depend>
<exec_depend>driver_sim</exec_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
</package>
</package>
Loading

0 comments on commit 0aa45bd

Please sign in to comment.