Skip to content

Commit

Permalink
SE-2391: Add more verbose logging to debug customers AI model uploads (
Browse files Browse the repository at this point in the history
…#21)

* More verbose FTP model upload handling for client debugging
* lint support
  • Loading branch information
treideme committed Feb 27, 2024
1 parent 684f1ca commit afce4ef
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 20 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/ci.yml
Expand Up @@ -63,7 +63,7 @@ jobs:
source install/local_setup.sh
source /opt/pleora/ebus_sdk/Ubuntu-22.04-x86_64/bin/set_puregev_env.sh
cd driver
colcon test
colcon test --event-handlers console_direct+
colcon test-result
cd ..
Expand Down Expand Up @@ -181,7 +181,7 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install -y build-essential libopencv-dev locales \
software-properties-common curl libcurl4-openssl-dev
software-properties-common curl libcurl4-openssl-dev python3-venv python3-pip
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
Expand Down Expand Up @@ -219,6 +219,7 @@ jobs:
- name: Build ros2 driver for foxy
run: |
cd driver
pip install -r test_requirements.txt
source /opt/ros/foxy/setup.sh
rosdep update --include-eol-distros
rosdep install -i --from-path . --rosdistro foxy -y
Expand All @@ -234,7 +235,7 @@ jobs:
export _colcon_cd_root=$(pwd)
source install/local_setup.sh
source /opt/pleora/ebus_sdk/Ubuntu-20.04-x86_64/bin/set_puregev_env.sh
colcon test
colcon test --event-handlers console_direct+ --packages-select bottlenose_camera_driver --ctest-args -R cpplint_test --rerun-failed --output-on-failure
colcon test-result
cd ..
- name: Evaluate test results
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Expand Up @@ -120,6 +120,13 @@ install(DIRECTORY
DESTINATION share/${PROJECT_NAME}
)

# Lint
find_program(CPPLINT cpplint)
if(CPPLINT)
add_test(NAME cpplint_test COMMAND ${CPPLINT} --verbose=0 --recursive src include)
set_tests_properties(cpplint_test PROPERTIES WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
endif()

#if(BUILD_TESTING)
# find_package(ament_lint_auto REQUIRED)
# # the following line skips the linter which checks for copyrights
Expand Down
37 changes: 37 additions & 0 deletions CPPLINT.cfg
@@ -0,0 +1,37 @@
filter=+build/class
filter=-build/c++17
filter=+build/deprecated
filter=+build/forward_decl
filter=+build/include_order
filter=+build/printf_format
filter=+build/storage_class
filter=+legal/copyright
filter=+readability/boost
filter=+readability/braces
#filter=+readability/casting (disabled, makes atomic type casts look rediculous)
filter=+readability/constructors
filter=+readability/fn_size
filter=+readability/function
filter=+readability/multiline_comment
filter=+readability/multiline_string
filter=+readability/streams
filter=+readability/utf8
filter=+runtime/arrays
filter=+runtime/casting
filter=+runtime/deprecated_fn
filter=+runtime/explicit
filter=+runtime/int
filter=+runtime/memset
filter=+runtime/mutex
filter=+runtime/nonconf
filter=+runtime/printf
filter=+runtime/printf_format
#filter=+runtime/references (disabled, we're not google)
filter=+runtime/rtti
filter=+runtime/sizeof
filter=+runtime/string
filter=+runtime/virtual
filter=+runtime/vlog
# cpplint.py enables these filters in reversed order.
filter=-
linelength=120
10 changes: 6 additions & 4 deletions include/bottlenose_camera_driver.hpp
Expand Up @@ -24,6 +24,10 @@
#include <cstdio>
#include <iostream>
#include <variant>
#include <thread>
#include <mutex>
#include <condition_variable>

#include "rclcpp/rclcpp.hpp"

#include "std_msgs/msg/string.hpp"
Expand All @@ -39,11 +43,9 @@
#include <camera_info_manager/camera_info_manager.hpp>
#include <image_transport/image_transport.hpp>

#include "opencv2/highgui/highgui.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <thread>
#include <mutex>
#include <condition_variable>

#include <PvBuffer.h>
#include <PvDeviceGEV.h>
#include <PvStreamGEV.h>
Expand Down
4 changes: 2 additions & 2 deletions include/bottlenose_chunk_parser.hpp
Expand Up @@ -20,9 +20,9 @@
#ifndef __BOTTLENOSE_CHUNK_PARSER_HPP__
#define __BOTTLENOSE_CHUNK_PARSER_HPP__

#include <PvBuffer.h>
#include <vector>
#include <stdint.h>
#include <cstdint>
#include <PvBuffer.h>

#define MAX_KEYPOINTS 0xFFFF
#define MAX_BBOXES (100)
Expand Down
23 changes: 12 additions & 11 deletions src/bottlenose_camera_driver.cpp
Expand Up @@ -19,31 +19,31 @@
G. M. Tchamgoue <martin@labforge.ca>
*/

#include <arpa/inet.h> // For inet_ntoa
#include <netinet/in.h> // For struct in_addr
#include <sys/stat.h>
#include <unistd.h>
#include <curl/curl.h>
#include <chrono>
#include <memory>
#include <utility>
#include <string>
#include <cassert>
#include <list>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <arpa/inet.h> // For inet_ntoa
#include <netinet/in.h> // For struct in_addr

#include <PvDevice.h>
#include <PvStream.h>
#include <PvSystem.h>
#include <PvBuffer.h>
#include <opencv2/opencv.hpp>
#include <curl/curl.h>


#include "bottlenose_camera_driver.hpp"
#include "bottlenose_parameters.hpp"
#include "bottlenose_chunk_parser.hpp"
#include <ament_index_cpp/get_package_share_directory.hpp>
#include <sys/stat.h>

#define BUFFER_COUNT ( 16 )
#define BUFFER_SIZE ( 3840 * 2160 * 3 ) // 4K UHD, YUV422 + ~1 image plane to account for chunk data
Expand Down Expand Up @@ -1375,13 +1375,16 @@ bool CameraDriver::configure_ai_model() {
WAIT_PROPAGATE();
}
if(trials == 0) {
RCLCPP_ERROR(get_logger(), "Could not file transfer");
RCLCPP_ERROR(get_logger(), "Could not file transfer, last device status %s", modelStatus.GetAscii());
return false;
}
RCLCPP_DEBUG(get_logger(), "Model transfer initiated, last device status %s", modelStatus.GetAscii());
filesystem::path fsPath(get_parameter("ai_model").as_string());
string basename = fsPath.filename().string();
string target = string("ftp://anonymous:@") + ipAddress + "/" + basename;
RCLCPP_DEBUG(get_logger(), "Transferring model to %s", target.c_str());
if(!ftp_upload(target, get_parameter("ai_model").as_string())) {
RCLCPP_ERROR_STREAM(get_logger(), "Model transfer failed, for file " << get_parameter("ai_model").as_string() << " file exists: " << filesystem::path(basename));
return false;
}
trials = 10;
Expand All @@ -1398,7 +1401,7 @@ bool CameraDriver::configure_ai_model() {
usleep(100000);
}
if(trials == 0) {
RCLCPP_ERROR(get_logger(), "Could not initialize model");
RCLCPP_ERROR(get_logger(), "Could not initialize model, last status %s", modelStatus.GetAscii());
return false;
} else {
RCLCPP_DEBUG(get_logger(), "Model loaded, last status %s", modelStatus.GetAscii());
Expand Down Expand Up @@ -1460,8 +1463,7 @@ bool CameraDriver::load_calibration(uint32_t sid, std::string cname){

if(this->get_parameter(param).as_string().length() > 0) {
kfile_param = this->get_parameter(param).as_string();
}
else{
} else {
std::string default_url = prefix + ament_index_cpp::get_package_share_directory(this->get_name()) + "/config/" + cname + ".yaml";
this->set_parameter(rclcpp::Parameter(param, default_url));
kfile_param = this->get_parameter(param).as_string();
Expand Down Expand Up @@ -1739,8 +1741,7 @@ bool CameraDriver::set_calibration(){
return false;
}
RCLCPP_DEBUG(get_logger(), "Rectification & undistortion disabled");
}
else if(num_sensors == 2) {
} else if(num_sensors == 2) {
m_calibrated = set_register("Undistortion", true);
if(!m_calibrated){
RCLCPP_ERROR(get_logger(), "Failed to trigger Undistortion mode on camera.");
Expand Down
1 change: 1 addition & 0 deletions test_requirements.txt
@@ -0,0 +1 @@
cpplint==1.6.1

0 comments on commit afce4ef

Please sign in to comment.