Skip to content

Commit cb0c985

Browse files
committed
Fix first round of merge conflicts
1 parent 9e8965d commit cb0c985

36 files changed

Lines changed: 835 additions & 338 deletions

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ FIND_PACKAGE(crossguid REQUIRED)
99

1010
# CMakeLists
1111
find_package(OpenCV REQUIRED)
12+
include_directories(${OpenCV_INCLUDE_DIRS})
1213

1314
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/run)
1415

@@ -29,7 +30,7 @@ if(ret EQUAL "1")
2930
endif()
3031

3132
set(CMAKE_CXX_COMPILER "g++-7")
32-
set(CMAKE_CXX_FLAGS "--std=c++17 -g -O1 -fno-omit-frame-pointer -Wall -Wno-deprecated-declarations ${CMAKE_CXX_FLAGS}")
33+
set(CMAKE_CXX_FLAGS "--std=c++17 -g -O1 -fno-omit-frame-pointer -Wall -Wno-deprecated-declarations -Wno-psabi ${CMAKE_CXX_FLAGS}")
3334

3435

3536
# Wait! Don't edit this file! Use pymake of updating this cmake.

config/fiducial_map/read_fiducial_map.cc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33

44
namespace jet {
55

6-
7-
fiducial_pose get_fiducial_pose() {
6+
FiducialDescription get_fiducial_pose() {
87
YAML::Node config = YAML::LoadFile("/jet/config/fiducial_map/fiducial_map.yaml");
98
auto const node = config["fiducial_5x5"];
109

11-
fiducial_pose result;
10+
FiducialDescription result;
1211
const auto log_translation_tag_from_world = node["log_translation_tag_from_world"].as<std::vector<double>>();
13-
const auto log_rotation_tag_from_world = node["log_rotation_tag_from_world"].as<std::vector<double>>();
12+
const auto log_rotation_tag_from_world = node["log_rotation_tag_from_world"].as<std::vector<double>>();
1413

1514
result.tag_from_world =
1615
SE3(SO3::exp(jcc::Vec3(
@@ -24,18 +23,18 @@ fiducial_pose get_fiducial_pose() {
2423
return result;
2524
}
2625

27-
28-
camera_extrinsics_struct get_camera_extrinsics() {
26+
CameraExtrinsics get_camera_extrinsics() {
2927
YAML::Node node = YAML::LoadFile("/jet/config/camera_extrinsics.yaml");
3028

31-
camera_extrinsics_struct result;
29+
CameraExtrinsics result;
3230
const auto log_translation_camera_from_frame = node["log_translation_camera_from_frame"].as<std::vector<double>>();
33-
const auto log_rotation_camera_from_frame = node["log_rotation_camera_from_frame"].as<std::vector<double>>();
31+
const auto log_rotation_camera_from_frame = node["log_rotation_camera_from_frame"].as<std::vector<double>>();
3432
result.camera_from_frame =
3533
SE3(SO3::exp(jcc::Vec3(
3634
log_rotation_camera_from_frame[0], log_rotation_camera_from_frame[1], log_rotation_camera_from_frame[2])),
37-
jcc::Vec3(
38-
log_translation_camera_from_frame[0], log_translation_camera_from_frame[1], log_translation_camera_from_frame[2]));
35+
jcc::Vec3(log_translation_camera_from_frame[0],
36+
log_translation_camera_from_frame[1],
37+
log_translation_camera_from_frame[2]));
3938
return result;
4039
}
4140

config/fiducial_map/read_fiducial_map.hh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
namespace jet {
99

1010

11-
struct fiducial_pose
11+
struct FiducialDescription
1212
{
1313
SE3 tag_from_world;
1414
int tag_size_squares;
1515
double arcode_width_mm;
1616
double arcode_gap_mm;
1717
};
1818

19-
struct camera_extrinsics_struct
19+
struct CameraExtrinsics
2020
{
2121
SE3 camera_from_frame;
2222
};
2323

24-
fiducial_pose get_fiducial_pose();
25-
camera_extrinsics_struct get_camera_extrinsics();
24+
FiducialDescription get_fiducial_pose();
25+
CameraExtrinsics get_camera_extrinsics();
2626

2727
} // namespace jet
2828

config/hoverjet/controller.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
k_proportional:
2+
- 0.2
3+
- 0.2
4+
- 0.4
5+
6+
k_derivative:
7+
- 0.2
8+
- 0.2
9+
- 0.4

config/hoverjet/filter.yaml

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
use_accelerometer: false
2+
use_gyro: true
3+
use_imus:
4+
- 78
5+
use_fiducial: true
6+
max_fiducial_latency_s: 0.4
7+
8+
transforms:
9+
- source: imu_36
10+
destination: camera
11+
source_from_destination:
12+
log_R_source_from_destination:
13+
- -1.616591025757221
14+
- 0.05134578843446101
15+
- 0.05091124055477719
16+
translation_source_from_destination:
17+
- -0.001292535846636506
18+
- -0.0009267741933531443
19+
- -0.0199366607203838
20+
- source_from_destination:
21+
log_R_source_from_destination:
22+
- -2.207252187700393
23+
- 2.221627059568664
24+
- 0.0729343244927283
25+
translation_source_from_destination:
26+
- -0.1457315425013999
27+
- 0.07004447260546187
28+
- -0.2286505835933628
29+
destination: camera
30+
source: imu_78
31+
- destination: camera
32+
source_from_destination:
33+
log_R_source_from_destination:
34+
- 1.209199576156145
35+
- 1.209199576156145
36+
- 1.209199576156145
37+
translation_source_from_destination:
38+
- 0.11
39+
- 0
40+
- 0.32
41+
source: vehicle
42+
imus:
43+
36:
44+
source_log: /jet/logs/calibration-log-jul6-7
45+
accelerometer_gains_p0:
46+
- 0
47+
- 0
48+
- 0
49+
magnetometer_gains_p0:
50+
- -79.29922702237944
51+
- -4.476413645049656
52+
- -46.83316633469963
53+
id: 36
54+
magnetometer_gains_scaling:
55+
- 32.1877202815169
56+
- 3.408923758371102
57+
- 10.62688468310214
58+
- 0
59+
- 33.17611158621461
60+
- -13.05820640963059
61+
- 0
62+
- 0
63+
- 34.80217509591158
64+
name: imu_36
65+
accelerometer_gains_scaling:
66+
- 9.480392053156724
67+
- -0.367804276102152
68+
- 0.1097718806953435
69+
- 0
70+
- 9.392748712511086
71+
- -0.223199776102899
72+
- 0
73+
- 0
74+
- 9.674406404535416
75+
78:
76+
magnetometer_gains_scaling:
77+
- 27.28940423457934
78+
- -8.791590927283378
79+
- 2.517804983200733
80+
- 0
81+
- 32.00283422687422
82+
- 2.359513709031368
83+
- 0
84+
- 0
85+
- 27.18480244848202
86+
name: imu_78
87+
accelerometer_gains_p0:
88+
- 0
89+
- 0
90+
- 0
91+
id: 78
92+
accelerometer_gains_scaling:
93+
- 9.699410372939981
94+
- -1.712699829531295
95+
- -0.3186110085605555
96+
- 0
97+
- 9.844189129580382
98+
- -0.1136357460553914
99+
- 0
100+
- 0
101+
- 8.810237581896597
102+
magnetometer_gains_p0:
103+
- 45.59041987760968
104+
- 53.1135550856215
105+
- 21.82576956097864
106+
source_log: /jet/logs/calibration-log-jul6-7

config/supervisor/supervisor.conf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,14 @@ stopsignal=INT
7676
priority=2
7777

7878
[program:pose_filter]
79-
command=/jet/bin/run/filter_balsaq_main
79+
command=/jet/bin/run/filter_balsaq_main /jet/config/hoverjet/filter.yaml
8080
stderr_logfile = /var/log/supervisord/filter-stderr.log
8181
stdout_logfile = /var/log/supervisord/filter-stdout.log
8282
stopsignal=INT
8383
priority=1
8484

8585
[program:controller]
86-
command=/jet/bin/run/controller_balsaq_main
86+
command=/jet/bin/run/controller_balsaq_main /jet/config/hoverjet/controller.yaml
8787
stderr_logfile = /var/log/supervisord/controller-stderr.log
8888
stdout_logfile = /var/log/supervisord/controller-stdout.log
8989
stopsignal=INT

control/controller_balsaq.cc

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,38 @@
77
#include "control/control_utilities.hh"
88
#include "control/jet_vane_mapper.hh"
99
#include "control/servo_interface.hh"
10+
1011
#include "filtering/pose_message.hh"
12+
#include "filtering/yaml_matrix.hh"
13+
1114
#include "infrastructure/balsa_queue/bq_main_macro.hh"
1215
#include "infrastructure/engine/turbine_state_message.hh"
1316

14-
#include "third_party/experiments/estimation/time_point.hh"
15-
1617
namespace jet {
1718
namespace control {
1819

1920
namespace {
2021

21-
estimation::TimePoint to_time_point(const Timestamp& ts) {
22-
const auto epoch_offset = std::chrono::nanoseconds(uint64_t(ts));
23-
const estimation::TimePoint time_point = estimation::TimePoint{} + epoch_offset;
24-
return time_point;
25-
}
26-
22+
/*
2723
jcc::Vec3 sigmoid(const jcc::Vec3& v) {
2824
const double v_nrm = v.norm();
2925
3026
const double interp_value = (1.0 / (1.0 + std::exp(-v_nrm)));
3127
3228
return interp_value * v.normalized();
3329
}
30+
*/
3431

35-
QuadraframeStatus generate_control(const SO3& world_from_target, const Pose& pose, const JetStatus& jet_status) {
32+
QuadraframeStatus generate_control(const SO3& world_from_target,
33+
const Pose& pose,
34+
const JetStatus& jet_status,
35+
const GainConfig& cfg) {
3636
JetVaneMapper mapper_;
3737

38-
const MatNd<3, 3> K = jcc::Vec3(0.3, 0.3, 0.4).asDiagonal();
38+
const jcc::Vec3 w_jet_frame = pose.world_from_jet.inverse() * pose.w_world_frame;
39+
40+
const MatNd<3, 3> Kp = cfg.k_proportional.asDiagonal();
41+
const MatNd<3, 3> Kd = cfg.k_derivative.asDiagonal();
3942

4043
//
4144
// Compute the current expected jet force (All servos zero'd)
@@ -53,7 +56,7 @@ QuadraframeStatus generate_control(const SO3& world_from_target, const Pose& pos
5356
const jcc::Vec3 desired_force_jet_frame = wrench_for_zero.force_N;
5457

5558
const SO3 target_from_jet = world_from_target.inverse() * pose.world_from_jet.so3();
56-
const jcc::Vec3 desired_torque_jet_frame = -K * target_from_jet.log();
59+
const jcc::Vec3 desired_torque_jet_frame = -(Kp * target_from_jet.log()) + -(Kd * w_jet_frame);
5760

5861
Wrench target_wrench;
5962
target_wrench.torque_Nm = desired_torque_jet_frame;
@@ -99,6 +102,9 @@ void ControllerBq::init(const Config& config) {
99102
std::cout << "Subscribing Turbine State" << std::endl;
100103
turbine_state_sub_ = make_subscriber("turbine_state");
101104

105+
read_matrix(config["k_proportional"], gain_cfg_.k_proportional);
106+
read_matrix(config["k_derivative"], gain_cfg_.k_derivative);
107+
102108
std::cout << "Controller starting" << std::endl;
103109
}
104110

@@ -125,7 +131,7 @@ void ControllerBq::loop() {
125131

126132
if (got_pose_msg && got_turbine_status_) {
127133
const Pose pose = pose_msg.to_pose();
128-
const auto target_qframe_status = generate_control(target_from_world, pose, jet_status_);
134+
const auto target_qframe_status = generate_control(target_from_world, pose, jet_status_, gain_cfg_);
129135
SetServoMessage servo_message = create_servo_command(target_qframe_status);
130136
servo_pub_->publish(servo_message);
131137
}

control/controller_balsaq.hh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@
88
namespace jet {
99
namespace control {
1010

11+
struct GainConfig {
12+
jcc::Vec3 k_proportional;
13+
jcc::Vec3 k_derivative;
14+
};
15+
1116
class ControllerBq : public BalsaQ {
1217
public:
1318
ControllerBq();
@@ -19,6 +24,8 @@ class ControllerBq : public BalsaQ {
1924
const static uint loop_delay_microseconds = 10000;
2025

2126
private:
27+
GainConfig gain_cfg_;
28+
2229
SubscriberPtr roll_sub_;
2330
SubscriberPtr pitch_sub_;
2431
SubscriberPtr yaw_sub_;

control/jet_vane_model.hh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ struct VaneConfiguration {
2424
SE3 T_vane_unit_from_vane_default = detail::compute_T_vane_unit_from_vane_default();
2525
double offset_vane_from_servo_rad = 0.0;
2626

27-
double gear_ratio_servo_from_vane = 5.33;
27+
// double gear_ratio_servo_from_vane = 5.33;
28+
double gear_ratio_servo_from_vane = 1.0;
2829
double max_servo_angle_rad = 1.116;
2930
double min_servo_angle_rad = -1.116;
3031

filtering/calibrate_camera_from_log.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ void calibrate_camera(const std::string& log_path) {
8181
break;
8282
}
8383

84-
const auto obj_pt_associations = obj_points_img_points_from_image(image->image);
84+
85+
const auto ids_corners = get_ids_and_corners(image->image);
86+
const auto obj_pt_associations = obj_points_img_points_from_image(ids_corners);
8587

8688
serial_number = image->serial_number;
8789
cols = image->image.cols;
@@ -130,13 +132,14 @@ void calibrate_camera(const std::string& log_path) {
130132
jcc::Warning() << "Calibrating camera, this might take a while..." << std::endl;
131133
int flag = 0;
132134
const auto t0 = jcc::now();
133-
cv::calibrateCamera(object_points, image_points, cv::Size(480, 270), K, D, rvecs, tvecs, flag);
135+
cv::Size resolution(480, 270);
136+
cv::calibrateCamera(object_points, image_points, resolution, K, D, rvecs, tvecs, flag);
134137
const auto t1 = jcc::now();
135138
jcc::Success() << "Done. Took: " << estimation::to_seconds(t1 - t0) << std::endl;
136139
jcc::Success() << "Generating yaml..." << std::endl;
137140

138-
YAML::Node node; // starts out as null
139-
node["serial_number"] = serial_number; // it now is a map node
141+
YAML::Node node;
142+
node["serial_number"] = serial_number;
140143

141144
{
142145
std::stringstream ss;

0 commit comments

Comments
 (0)