Skip to content
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

[Sprint 22/23 / PI-412] - [Feature] Implement TF2 Tree #61

Merged
merged 19 commits into from
Jun 15, 2024

Conversation

borednuna
Copy link
Contributor

Jira Link: https://ichiro-its.atlassian.net/browse/PD-412

Description

Implement TF2 to represent the robot's physical movements as transform frames and publish them.

Type of Change

  • Bugfix
  • Enhancement
  • New feature
  • Breaking change (fix or feature that would cause the existing functionality to not work as expected)

How Has This Been Tested?

  • New unit tests added.
  • Manual tested.

Checklist:

  • Using Branch Name Convention
    • feature/JIRA-ID-SHORT-DESCRIPTION if has a JIRA ticket
    • enhancement/SHORT-DESCRIPTION if has/has no JIRA ticket and contain enhancement
    • hotfix/SHORT-DESCRIPTION if the change doesn't need to be tested (urgent)
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have made the documentation for the corresponding changes.

Comment on lines 67 to 72
enum : uint8_t {
ROLL = 0,
PITCH = 1,
YAW = 2,
};

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to assign int values in enum

Comment on lines 35 to 47
enum : uint8_t {
ODOM = 0,
BASE_LINK = 1,
TORSO = 2,
HEAD = 3,
GAZE = 4,
RIGHT_THIGH = 5,
RIGHT_CALF = 6,
RIGHT_FOOT = 7,
LEFT_THIGH = 8,
LEFT_CALF = 9,
LEFT_FOOT = 10
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto.

@@ -39,13 +39,14 @@ class TachimawariNode
explicit TachimawariNode(
rclcpp::Node::SharedPtr node, std::shared_ptr<control::ControlManager> control_manager);

void run_joint_manager();
void run_joint_manager(std::string path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
void run_joint_manager(std::string path);
void run_joint_manager(const std::string & path);

public:
explicit Tf2Manager();

bool load_configuration(std::string path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool load_configuration(std::string path);
bool load_configuration(const std::string & path);

Comment on lines 61 to 64
} catch (nlohmann::json::parse_error & ex) {
std::cerr << "parse error at byte " << ex.byte << std::endl;
}
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to throw the exception instead of letting the program running with unknown behavior.

Suggested change
} catch (nlohmann::json::parse_error & ex) {
std::cerr << "parse error at byte " << ex.byte << std::endl;
}
}
} catch (nlohmann::json::parse_error & ex) {
std::cerr << "parse error at byte " << ex.byte << std::endl;
throw ex;
}
}


private:
static const std::vector<std::pair<int, int>> tf2_joint_pairs;
std::string config_path;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmiiw, i don't see this variable ever used


void run_imu_provider();

private:
rclcpp::Node::SharedPtr node;
rclcpp::TimerBase::SharedPtr node_timer;
rclcpp::TimerBase::SharedPtr node_timer_tf;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cmiiw, this also unused

Comment on lines 61 to 62
JointNode(
rclcpp::Node::SharedPtr node, std::shared_ptr<JointManager> joint_manager, std::string path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
JointNode(
rclcpp::Node::SharedPtr node, std::shared_ptr<JointManager> joint_manager, std::string path);
JointNode(
rclcpp::Node::SharedPtr node, std::shared_ptr<JointManager> joint_manager, const std::string & path);

quaternion_w = q.w();
}

void Frame::update_quaternion(keisan::Angle<double> imu_yaw)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

{
}

geometry_msgs::msg::TransformStamped Frame::get_transform_stamped(rclcpp::Time time_stamp)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If object is not modified in the function, can pass as const reference instead.

return t;
}

void Frame::update_quaternion(std::vector<Joint> current_joints)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

quaternion_w = q.w();
}

double Frame::get_joint_angle(uint8_t quaternion_axis, std::vector<Joint> current_joints)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

return true;
}

void Tf2Manager::update(std::vector<Joint> current_joints, keisan::Angle<double> imu_yaw)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -21,16 +21,23 @@
#ifndef TACHIMAWARI__JOINT__NODE__JOINT_NODE_HPP_
#define TACHIMAWARI__JOINT__NODE__JOINT_NODE_HPP_

#include <tf2_ros/buffer.h>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

library order, check another files too

@borednuna borednuna merged commit de1c57a into master Jun 15, 2024
1 check failed
@borednuna borednuna deleted the feature/create-tf2 branch June 15, 2024 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants