-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DO NOT MERGE: Changes from CIRC competition #335
Conversation
calib_info: | ||
calibration_time: "Sat 01 May 2021 01:54:16 PM PDT" | ||
board_width: 11 | ||
board_height: 8 | ||
square_size: 20. | ||
flags: 0 | ||
avg_reprojection_error: 4.5744250014767379e-01 | ||
intrinsic_params: | ||
image_width: 640 | ||
image_height: 480 | ||
camera_matrix: !!opencv-matrix | ||
rows: 3 | ||
cols: 3 | ||
dt: d | ||
data: [ 6.4936764773277400e+02, 0., 3.3546152305967058e+02, 0., | ||
6.4776804982533793e+02, 2.4785660889077488e+02, 0., 0., 1. ] | ||
distortion_coefficients: !!opencv-matrix | ||
rows: 5 | ||
cols: 1 | ||
dt: d | ||
data: [ -4.5670452858419575e-01, 2.1512832208218641e-01, | ||
-1.1179480533495888e-03, -5.7450430930239835e-04, 0. ] | ||
extrinsic_params: !!opencv-matrix | ||
rows: 4 | ||
cols: 4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are all unused. We should redo how we handle camera configuration, especially considering the changes in Camera.cpp
calib_info: | ||
calibration_time: "Sat 01 May 2021 01:54:16 PM PDT" | ||
board_width: 11 | ||
board_height: 8 | ||
square_size: 20. | ||
flags: 0 | ||
avg_reprojection_error: 4.5744250014767379e-01 | ||
intrinsic_params: | ||
image_width: 640 | ||
image_height: 480 | ||
camera_matrix: !!opencv-matrix | ||
rows: 3 | ||
cols: 3 | ||
dt: d | ||
data: [ 6.4936764773277400e+02, 0., 3.3546152305967058e+02, 0., | ||
6.4776804982533793e+02, 2.4785660889077488e+02, 0., 0., 1. ] | ||
distortion_coefficients: !!opencv-matrix | ||
rows: 5 | ||
cols: 1 | ||
dt: d | ||
data: [ -4.5670452858419575e-01, 2.1512832208218641e-01, | ||
-1.1179480533495888e-03, -5.7450430930239835e-04, 0. ] | ||
extrinsic_params: !!opencv-matrix | ||
rows: 4 | ||
cols: 4 | ||
dt: d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as other camera, unused. See note on other camera config file.
@@ -136,6 +136,8 @@ void setMotorPower(deviceserial_t serial, int16_t power); | |||
*/ | |||
void setMotorPIDTarget(deviceserial_t serial, int32_t target); | |||
|
|||
void setMotorPIDMaxPower(deviceserial_t serial, uint16_t maxPower); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This method restricts the maximum power that the motor is allowed to apply when running PID. Add documentation! Also, maybe add an overload with a double parameter for power in the range [0,1]
?
SEGMENT_LENGTHS{{robot::types::motorid_t::shoulder, 0.3848608}, | ||
{robot::types::motorid_t::elbow, 0.461264}}; | ||
SEGMENT_LENGTHS{{robot::types::motorid_t::shoulder, 0.394}, | ||
{robot::types::motorid_t::elbow, 0.749}}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the elbow measurement goes all the way from the elbow joint to the tip of the fingers of the hand.
can::motor::setLimitSwitchLimits(serial, mDegToPulses(enc_params.limitSwitchLow), | ||
mDegToPulses(enc_params.limitSwitchHigh)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameters to setLimitSwitchLimits()
should be in encoder ticks, not mdegs. This used to work before, only because it was incorrect on both sides (firmware and software) but disagreed with documentation. This has been updated on both sides.
@@ -53,7 +53,7 @@ const kinematics::DiffDriveKinematics& driveKinematics() { | |||
|
|||
namespace { | |||
// map that associates camera id to the camera object | |||
std::unordered_map<CameraID, std::shared_ptr<cam::Camera>> cameraMap; | |||
std::unordered_map<CameraID, std::weak_ptr<cam::Camera>> cameraMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maintain a weak pointer here so reference counting works. When the number of strong references (all held by client code) drops to 0 , the camera will be cleaned up.
// inverted because of weirdness | ||
can::motor::setLimitSwitchLimits(serial, mDegToPulses(-enc_params.limitSwitchLow), | ||
mDegToPulses(-enc_params.limitSwitchHigh)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is due to some quaddec inversion weirdness in firmware that I don't fully understand. Ask Casey and/or Michael. This should be fixed in firmware and we shouldn't have to negate the parameters.
@@ -96,33 +100,35 @@ void initMotors() { | |||
} | |||
} | |||
|
|||
void openCamera(CameraID camID, const char* cameraPath) { | |||
std::shared_ptr<cam::Camera> openCamera(CameraID camID, const std::string& cameraPath) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I said, the Jetson can only open 2 cameras, so we're opening cameras as necessary (instead of at the beginning) and using reference counting to figure out when to close it. This involves weak and shared pointers, which should be pretty intuitive.
class CameraHandle { | ||
public: | ||
CameraHandle(std::shared_ptr<cam::Camera> cam) : camera(cam) {} | ||
private: | ||
std::shared_ptr<cam::Camera> camera; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a dumb class that is used for reference counting without letting client code have access to the actual camera object. Is this the right place for it?
@@ -87,6 +92,8 @@ bool isEmergencyStopped(); | |||
*/ | |||
std::unordered_set<types::CameraID> getCameras(); | |||
|
|||
std::shared_ptr<types::CameraHandle> openCamera(types::CameraID camera); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document!
const std::unordered_map<robot::types::CameraID, std::string> CAMERA_CONFIG_PATHS = { | ||
{MAST_CAMERA_ID, "../camera-config/MastCameraCalibration.yml"}, | ||
{FOREARM_CAMERA_ID, "../camera-config/WristCameraCalibration.yml"}, | ||
{HAND_CAMERA_ID, "../camera-config/HandCameraCalibration.yml"}, | ||
{PANO_CAMERA_ID, "../camera-config/PanoCameraCalibration.yml"}, | ||
{DRILL_CAMERA_ID, "../camera-config/DrillCameraCalibration.yml"} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Useless, as mentioned for PanoCameraCalibration.yml
std::shared_ptr<types::CameraHandle> openCamera(CameraID cameraID) { | ||
return nullptr; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is the old openCamera function returning nullptr?
closing for abhays mental health |
This PR consists of hotfixes and changes implemented during the CIRC 2024 competition. As a result, much of this code consists of quick fixes/hacks that shouldn't be merged, but should rather be evaluated if we need it, and should be cleaned up and merged as a separate PR.
I will go through the code noting why sections of code were fixed, to help with the cleaning up process.