Skip to content

Commit

Permalink
Add -Werror and add "unsed" attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
quinnmp committed Jan 20, 2024
1 parent 285cfa4 commit c8cf70a
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 21 deletions.
14 changes: 9 additions & 5 deletions src/CAN/FakeCANBoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ using namespace std::chrono_literals;
using can::motor::motormode_t;
using namespace robot::types;

enum class TestMode {
enum class TestMode
{
ModeSet,
PWM,
PID,
Expand Down Expand Up @@ -160,11 +161,13 @@ int main() {
robot::types::datatime_t currTime = robot::types::dataclock::now();

// get y data: set point (target vel * time since set velocity call) + initial pos
double setPoint = (targetVel * util::durationToSec(currTime - startTime)) +
initialMotorPos.getData();
__attribute__((unused)) double setPoint =
(targetVel * util::durationToSec(currTime - startTime)) +
initialMotorPos.getData();

// get y data: motor position
robot::types::DataPoint<int32_t> motorPos = motor->getMotorPos();
__attribute__((unused)) robot::types::DataPoint<int32_t> motorPos =
motor->getMotorPos();

// check if time is up
double elapsedTime = util::durationToSec(currTime - startTime);
Expand Down Expand Up @@ -224,7 +227,8 @@ int main() {
can::deviceid_t id = std::make_pair(can::devicegroup_t::motor, serial);
can::addDeviceTelemetryCallback(
id, can::telemtype_t::limit_switch,
[](can::deviceid_t id, can::telemtype_t telemType,
[](can::deviceid_t id,
__attribute__((unused)) can::telemtype_t telemType,
DataPoint<can::telemetry_t> data) {
std::cout << "Motor Limit: serial=" << std::hex
<< static_cast<int>(id.second)
Expand Down
4 changes: 2 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -354,10 +354,10 @@ if (WORLD_INTERFACE STREQUAL "REAL")
endif()

add_compile_options(
-Wno-dev
-Wall
-Wextra
# -Wconversion
-Wno-deprecated-copy
-Werror
)

add_subdirectory(ar)
Expand Down
4 changes: 2 additions & 2 deletions src/ar/ARTester.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../camera/Camera.h"
#include "../camera/CameraParams.h"
#include "../camera/CameraConfig.h"
#include "../camera/CameraParams.h"
#include "Detector.h"

#include <chrono>
Expand Down Expand Up @@ -109,7 +109,7 @@ int main(int argc, char* argv[]) {
cam_config.release();

cv::Mat frame;
uint32_t fnum = 0;
__attribute__((unused)) uint32_t fnum = 0;

std::cout << "Opening camera..." << std::endl;
bool open_success = false;
Expand Down
22 changes: 12 additions & 10 deletions src/camera/CameraParams.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#include "CameraParams.h"
#include "../../src/camera/CameraConfig.h"

#include "../../src/Constants.h"
#include <opencv2/core.hpp>
#include "../../src/camera/CameraConfig.h"

#include <vector>

#include <opencv2/core.hpp>

namespace cam {

////////////// CONSTRUCTORS //////////////

CameraParams::CameraParams() {
}
CameraParams::CameraParams() {}

void CameraParams::init(const cv::Mat& camera_matrix, const cv::Mat& dist_coeff,
cv::Size image_size) {
Expand Down Expand Up @@ -66,11 +66,11 @@ cv::Size CameraParams::getImageSize() const {
return _image_size;
}

std::vector<double> CameraParams::getIntrinsicList(){
std::vector<double> CameraParams::getIntrinsicList() {
std::vector<double> intrinsic_list1D;
for (int i = 0; i < 3; i++){
for (int j = 0; j < 3; j++){
double x = _camera_matrix.at<double>(i,j);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
double x = _camera_matrix.at<double>(i, j);
intrinsic_list1D.push_back(x);
}
}
Expand Down Expand Up @@ -99,15 +99,17 @@ void CameraParams::writeToFileStorage(cv::FileStorage& file_storage) const {
file_storage << "}";
}

void read(const cv::FileNode& node, cam::CameraParams& params, const cam::CameraParams& default_value) {
void read(const cv::FileNode& node, cam::CameraParams& params,
const cam::CameraParams& default_value) {
if (node.empty()) {
params = default_value;
} else {
params.readFromFileNode(node);
}
}

void write(cv::FileStorage& fs, const std::string& name, const cam::CameraParams& params) {
void write(cv::FileStorage& fs, __attribute__((unused)) const std::string& name,
const cam::CameraParams& params) {
params.writeToFileStorage(fs);
}

Expand Down
4 changes: 2 additions & 2 deletions src/network/MissionControlProtocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ static bool validateJointPositionRequest(const json& j) {
static void handleJointPositionRequest(const json& j) {
// TODO: ignore this message if we are in autonomous mode.
std::string motor = j["joint"];
double position_deg = j["position"];
int32_t position_mdeg = std::round(position_deg * 1000);
__attribute__((unused)) double position_deg = j["position"];
__attribute__((unused)) int32_t position_mdeg = std::round(position_deg * 1000);
// TODO: actually implement joint position requests
// setMotorPos(motor, position_mdeg);
}
Expand Down

0 comments on commit c8cf70a

Please sign in to comment.