Skip to content

Commit 6b59ff5

Browse files
authored
Merge pull request #20 from AutoModality/AM-213/vb_util_lib
Am 213/vb util lib
2 parents b88451f + 380a32c commit 6b59ff5

File tree

122 files changed

+19348
-57
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+19348
-57
lines changed

.github/workflows/package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v2
1616
- name: Package
1717
id: package
18-
uses: AutoModality/action-package-debian-ros@v3.0.0
18+
uses: AutoModality/action-package-debian-ros@v3-perception
1919
with:
2020
branch: ${{ github.event.pull_request.head.ref }}
2121
pull-request-number: ${{ github.event.number }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
- name: Package if published
6666
if: steps.published.outputs.value == 'true'
6767
id: package
68-
uses: AutoModality/action-package-debian-ros@v3.0.0
68+
uses: AutoModality/action-package-debian-ros@v3-perception
6969
with:
7070
version: ${{ steps.version.outputs.value }}
7171
release-repo-entitlement: ${{ secrets.CLOUDSMITH_READ_RELEASE_ENTITLEMENT }}

.github/workflows/story.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
steps:
1111
- uses: actions/checkout@v2
1212
- name: Package
13-
uses: AutoModality/action-package-debian-ros@v3.0.0
13+
uses: AutoModality/action-package-debian-ros@v3-perception
1414
with:
1515
dev-repo-entitlement: ${{ secrets.CLOUDSMITH_READ_DEV_ENTITLEMENT }}
1616
release-repo-entitlement: ${{ secrets.CLOUDSMITH_READ_RELEASE_ENTITLEMENT }}

CMakeLists.txt

Lines changed: 99 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,123 @@
11
cmake_minimum_required(VERSION 2.8.3)
22
project(am_utils)
33

4+
add_compile_options(-std=c++11)
5+
46
find_package(catkin REQUIRED COMPONENTS
7+
brain_box_msgs
8+
control_toolbox
9+
dji_sdk
10+
image_transport
11+
genmsg
512
geometry_msgs
613
nav_msgs
7-
genmsg
8-
std_msgs
9-
sensor_msgs
1014
rosconsole
15+
roscpp
16+
rosbag
1117
rostime
12-
brain_box_msgs
18+
sensor_msgs
19+
std_msgs
20+
tf2
21+
tf2_ros
1322
)
1423

15-
generate_messages( DEPENDENCIES std_msgs nav_msgs geometry_msgs sensor_msgs)
16-
17-
set(CMAKE_CXX_FLAGS "-std=c++0x ${CMAKE_CXX_FLAGS}")
24+
find_package(OpenCV REQUIRED)
25+
find_package(Eigen3 REQUIRED)
1826

1927
catkin_package(
20-
INCLUDE_DIRS include include/am_utils
28+
INCLUDE_DIRS include include/am_utils include/vb_util_lib
2129
LIBRARIES am_utils
2230
CATKIN_DEPENDS
23-
geometry_msgs
24-
nav_msgs
25-
std_msgs
26-
sensor_msgs
27-
brain_box_msgs
31+
brain_box_msgs
32+
control_toolbox
33+
dji_sdk
34+
image_transport
35+
genmsg
36+
geometry_msgs
37+
nav_msgs
38+
rosconsole
39+
roscpp
40+
rosbag
41+
rostime
42+
sensor_msgs
43+
std_msgs
44+
tf2
45+
tf2_ros
2846
)
2947

48+
# TODO: why is the explicit eigen3 include
3049
include_directories(
3150
include
3251
${catkin_INCLUDE_DIRS}
52+
${Eigen3_INCLUDE_DIRS}
53+
/usr/include/eigen3
3354
)
3455

35-
install(DIRECTORY include/${PROJECT_NAME}/
36-
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
37-
3856
add_library(am_utils
39-
src/am_bag_utils.cpp
40-
src/am_network_utils.cpp
41-
src/am_onlinestatistics.cpp
42-
src/am_operator_utils.cpp
43-
src/am_statistics.cpp
44-
src/cansocket.cpp
45-
src/fcu_mode_type.cpp
46-
src/flightplan_type.cpp
47-
src/latency_wrapper.cpp
48-
src/message_util.cpp
49-
src/mission_cmd_type.cpp
50-
src/operator_msg_type.cpp
51-
src/topics.cpp
52-
)
53-
54-
target_link_libraries(am_utils ${catkin_LIBRARIES})
55-
56-
add_dependencies(am_utils brain_box_msgs_generate_messages_cpp)
57-
58-
install(TARGETS am_utils
57+
src/am_utils/am_bag_utils.cpp
58+
src/am_utils/am_network_utils.cpp
59+
src/am_utils/am_onlinestatistics.cpp
60+
src/am_utils/am_operator_utils.cpp
61+
src/am_utils/am_statistics.cpp
62+
src/am_utils/cansocket.cpp
63+
src/am_utils/fcu_mode_type.cpp
64+
src/am_utils/flightplan_type.cpp
65+
src/am_utils/latency_wrapper.cpp
66+
src/am_utils/message_util.cpp
67+
src/am_utils/mission_cmd_type.cpp
68+
src/am_utils/operator_msg_type.cpp
69+
src/vb_util_lib/control_util.cpp
70+
src/vb_util_lib/object_state.cpp
71+
src/vb_util_lib/kinematics.cpp
72+
src/vb_util_lib/kinematics_list.cpp
73+
src/vb_util_lib/current_enu_kinematics.cpp
74+
src/vb_util_lib/am_param.cpp
75+
src/vb_util_lib/gis_entity.cpp
76+
src/vb_util_lib/gis_util.cpp
77+
src/vb_util_lib/jsoncpp.cpp
78+
src/vb_util_lib/json_utils.cpp
79+
src/vb_util_lib/gs_json_utils.cpp
80+
src/vb_util_lib/am_util.cpp
81+
src/vb_util_lib/key_value_stamped.cpp
82+
src/vb_util_lib/param_update.cpp
83+
src/vb_util_lib/gps_util.cpp
84+
src/vb_util_lib/location_source.cpp
85+
src/vb_util_lib/am_geometry.cpp
86+
src/vb_util_lib/topics.cpp
87+
src/vb_util_lib/task_trigger.cpp
88+
src/vb_util_lib/time_util.cpp
89+
src/vb_util_lib/ftp_request.cpp
90+
src/vb_util_lib/ftp_response.cpp
91+
src/vb_util_lib/file_spec.cpp
92+
src/vb_util_lib/message.cpp
93+
src/vb_util_lib/msg_head.cpp
94+
src/vb_util_lib/msg_data.cpp
95+
src/vb_util_lib/dji_challenge_util.cpp
96+
src/vb_util_lib/am_histogram.cpp
97+
src/vb_util_lib/row_marker.cpp
98+
src/vb_util_lib/rc_controls.cpp
99+
src/vb_util_lib/i2c.cpp
100+
src/vb_util_lib/circ_list.cpp
101+
src/vb_util_lib/time_synchronizer.cpp
102+
src/vb_util_lib/GeometryPoseExtractor.cpp
103+
src/vb_util_lib/trajectory_data.cpp
104+
src/vb_util_lib/transformer.cpp
105+
src/vb_util_lib/rotate.cpp
106+
src/vb_util_lib/imu_class.cpp
107+
src/vb_util_lib/am_heartbeat.cpp
108+
src/vb_util_lib/vb_main.cpp
109+
src/vb_util_lib/bag_logger.cpp)
110+
111+
target_link_libraries(am_utils ${catkin_LIBRARIES} ${OpenCV_LIBRARIES})
112+
113+
install(TARGETS am_utils
59114
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
60115
)
116+
117+
install(DIRECTORY include/am_utils/
118+
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
119+
120+
install(DIRECTORY include/vb_util_lib/
121+
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
122+
123+

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
A common library for sharing core code.
44

5-
65
| Github Action | Kinetic Package | Melodic Package |
76
| ------------- | ------------- | ------------- |
87
| [![Story Development](https://github.com/AutoModality/am-utils/workflows/Story%20Development/badge.svg)](https://github.com/AutoModality/am-utils/actions?query=workflow%3A%22Story+Development%22) | -- |

debian/control

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ Section: misc
33
Priority: extra
44
Maintainer: info <info@automodality.com>
55
Build-Depends: debhelper (>= 9.0.0),
6+
ros-melodic-am-control-toolbox,
7+
ros-melodic-am-osdk-ros,
8+
ros-melodic-image-transport,
69
ros-melodic-am-msgs,
710
ros-melodic-catkin,
811
ros-melodic-geometry-msgs,
@@ -14,12 +17,20 @@ Build-Depends: debhelper (>= 9.0.0),
1417
ros-melodic-sensor-msgs,
1518
ros-melodic-std-msgs,
1619
ros-melodic-uuid-msgs,
20+
ros-melodic-tf2,
21+
ros-melodic-tf2-ros,
22+
ros-melodic-tf2-sensor-msgs,
23+
ros-melodic-cv-bridge,
24+
ros-melodic-mavros-msgs,
25+
1726
Homepage: https://github.com/AutoModality/am-utils
1827
Standards-Version: 3.9.2
19-
2028
Package: ros-melodic-am-utils
2129
Architecture: any
2230
Depends: ${shlibs:Depends}, ${misc:Depends},
31+
ros-melodic-am-control-toolbox,
32+
ros-melodic-am-osdk-ros,
33+
ros-melodic-image-transport,
2334
ros-melodic-am-msgs,
2435
ros-melodic-geometry-msgs,
2536
ros-melodic-message-runtime,
@@ -30,4 +41,9 @@ Depends: ${shlibs:Depends}, ${misc:Depends},
3041
ros-melodic-sensor-msgs,
3142
ros-melodic-std-msgs,
3243
ros-melodic-uuid-msgs,
44+
ros-melodic-tf2,
45+
ros-melodic-tf2-ros,
46+
ros-melodic-tf2-sensor-msgs,
47+
ros-melodic-cv-bridge,
48+
ros-melodic-mavros-msgs,
3349
Description: Common code to assist with AutoModality libraries found in separate repositories.

include/vb_util_lib/BagReader.h

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* bag_reader.h
3+
*
4+
* Created on: Apr 12, 2018
5+
* Author: Alireza Janani
6+
*/
7+
8+
#ifndef VISBOX_PACKAGES_COMMON_UTILS_UTIL_LIB_INCLUDE_VB_UTIL_LIB_BAGREADER_H_
9+
#define VISBOX_PACKAGES_COMMON_UTILS_UTIL_LIB_INCLUDE_VB_UTIL_LIB_BAGREADER_H_
10+
11+
#include<rosbag/bag.h>
12+
#include<rosbag/view.h>
13+
#include<vb_util_lib/console_color.h>
14+
#include<vector>
15+
#include<string>
16+
#include<ros/ros.h>
17+
#include<iostream>
18+
#include<fstream>
19+
20+
template<typename T>
21+
class BagReader : public T
22+
{
23+
public:
24+
BagReader()
25+
{
26+
bag_file_location = "";
27+
topic = "";
28+
bag = new rosbag::Bag();
29+
}
30+
BagReader(const std::string &bag_file_location_, const std::string &topic_)
31+
{
32+
bag_file_location = bag_file_location_;
33+
topic = topic_;
34+
bag = new rosbag::Bag();
35+
readBagFile();
36+
}
37+
~BagReader()
38+
{
39+
bag->close();
40+
delete bag;
41+
}
42+
void setBagLocation(const std::string &bag_file_location_)
43+
{
44+
bag_file_location = bag_file_location_;
45+
readBagFile();
46+
}
47+
std::vector<T> &getMessages()
48+
{
49+
return msgs;
50+
}
51+
52+
static inline bool exists(const std::string &str)
53+
{
54+
std::ifstream f(str.c_str());
55+
return f.good();
56+
}
57+
private:
58+
rosbag::Bag *bag;
59+
std::string bag_file_location;
60+
std::string topic;
61+
std::vector<T> msgs;
62+
63+
bool bagIsOpen = false;
64+
65+
66+
void readBagFile()
67+
{
68+
if(!BagReader::exists(bag_file_location))
69+
{
70+
ROS_ERROR(RED "The file does not exist." COLOR_RESET);
71+
return;
72+
}
73+
ROS_INFO("Opening bag file at %s ...", bag_file_location.c_str());
74+
bag->open(bag_file_location, rosbag::bagmode::Read);
75+
/*if (bag->isOpen())
76+
{
77+
ROS_INFO("Opening %s is completed, Reading %s topic",bag_file_location.c_str(), topic.c_str());
78+
}*/
79+
ROS_INFO("Opening %s is completed, Reading %s topic",bag_file_location.c_str(), topic.c_str());
80+
rosbag::View view(*bag, rosbag::TopicQuery(topic));
81+
long cnt = 0;
82+
for(rosbag::MessageInstance const m : view)
83+
{
84+
cnt++;
85+
msgs.push_back(*m.instantiate<T>());
86+
}
87+
ROS_INFO("Operation is completed, entries processed [%ld]", cnt);
88+
bag->close();
89+
}
90+
91+
92+
};
93+
94+
95+
#endif /* VISBOX_PACKAGES_COMMON_UTILS_UTIL_LIB_INCLUDE_VB_UTIL_LIB_BAGREADER_H_ */
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* GeometryPoseExtractor.h
3+
*
4+
* Created on: Apr 16, 2018
5+
* Author: ubuntu
6+
*/
7+
8+
#ifndef VISBOX_PACKAGES_COMMON_UTILS_UTIL_LIB_INCLUDE_VB_UTIL_LIB_GEOMETRYPOSEEXTRACTOR_H_
9+
#define VISBOX_PACKAGES_COMMON_UTILS_UTIL_LIB_INCLUDE_VB_UTIL_LIB_GEOMETRYPOSEEXTRACTOR_H_
10+
11+
#include<geometry_msgs/PoseStamped.h>
12+
#include<geometry_msgs/PoseWithCovarianceStamped.h>
13+
#include<nav_msgs/Odometry.h>
14+
#include<string>
15+
#include<vector>
16+
17+
18+
19+
class GeometryPoseExtractor
20+
{
21+
public:
22+
23+
GeometryPoseExtractor(std::vector<geometry_msgs::PoseStamped> &msgs);
24+
GeometryPoseExtractor(std::vector<geometry_msgs::PoseWithCovarianceStamped> &msgs);
25+
GeometryPoseExtractor(std::vector<nav_msgs::Odometry> &msgs);
26+
27+
GeometryPoseExtractor();
28+
~GeometryPoseExtractor();
29+
std::vector<geometry_msgs::PoseStamped> &getPoses();
30+
31+
private:
32+
std::vector<geometry_msgs::PoseStamped> poses;
33+
};
34+
35+
36+
37+
#endif /* VISBOX_PACKAGES_COMMON_UTILS_UTIL_LIB_INCLUDE_VB_UTIL_LIB_GEOMETRYPOSEEXTRACTOR_H_ */

0 commit comments

Comments
 (0)