blob: 59acba0abf5ef11b7ec394abe065982d3d8c33e0 [file] [log] [blame]
Jim Ostrowskiba2edd12022-12-03 15:44:37 -08001#include "frc971/vision/visualize_robot.h"
2
3#include "aos/init.h"
4#include "aos/logging/logging.h"
5#include "glog/logging.h"
6
7#include "Eigen/Dense"
8
9#include <math.h>
10#include <opencv2/aruco.hpp>
11#include <opencv2/aruco/charuco.hpp>
12#include <opencv2/calib3d.hpp>
13#include <opencv2/core/eigen.hpp>
14#include <opencv2/highgui/highgui.hpp>
15#include <opencv2/imgproc.hpp>
16#include "aos/time/time.h"
17
18namespace frc971 {
19namespace vision {
20
21// Show / test the basics of visualizing the robot frames
22void Main(int /*argc*/, char ** /* argv */) {
23 VisualizeRobot vis_robot;
24
25 int image_width = 500;
26 cv::Mat image_mat =
27 cv::Mat::zeros(cv::Size(image_width, image_width), CV_8UC3);
28 vis_robot.SetImage(image_mat);
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080029 double focal_length = 1000.0;
Jim Ostrowski49be8232023-03-23 01:00:14 -070030 vis_robot.SetDefaultViewpoint(image_width, focal_length);
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080031
32 // Go around the clock and plot the coordinate frame at different rotations
33 for (int i = 0; i < 12; i++) {
34 double angle = M_PI * double(i) / 6.0;
35 Eigen::Vector3d trans;
36 trans << 1.0 * cos(angle), 1.0 * sin(angle), 0.0;
37
Jim Ostrowski49be8232023-03-23 01:00:14 -070038 Eigen::Affine3d offset_rotate_origin =
39 Eigen::Translation3d(trans) *
40 Eigen::AngleAxisd(angle, Eigen::Vector3d::UnitX());
Jim Ostrowskiba2edd12022-12-03 15:44:37 -080041
42 vis_robot.DrawFrameAxes(offset_rotate_origin, std::to_string(i));
43 }
44
45 // Display the result
46 cv::imshow("Display", image_mat);
47 cv::waitKey();
48}
49} // namespace vision
50} // namespace frc971
51
52int main(int argc, char **argv) {
53 aos::InitGoogle(&argc, &argv);
54
55 frc971::vision::Main(argc, argv);
56}