-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from 16 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ab5d62f
feat: add tf2 implementation in joint node
borednuna 67c7c15
feat: add torso-base link to child parent mapping
borednuna 699cdf5
fix: fix frame and joint mapping errors
borednuna c372bb5
feat: rename variable
borednuna 36daa51
feat: follow rep-120 for frames names
borednuna f0b12c0
fix: use quaternion from tf2
borednuna 80eb33f
feat: create new walltimer for tf to avoid time disrepancy
borednuna b34838d
feat: use imu from kansei for odom frame
borednuna f5a6aa7
fix: fix topic name for imu subscriber
borednuna 60e5acc
fix: add tf2_ros to target install cmakelist
borednuna 3a6bea7
fix: fix tf light calculation
borednuna e378c75
fix: add head and gaze rotation to optimize accuracy, fix error tf va…
borednuna df9aae2
fix: fix wrong measurements
borednuna c590e5b
feat: change load configuration path, remove unused lines, tidy some …
borednuna f07ebda
feat: tidy codes
borednuna 212a982
feat: remove unused codes, simplify enums, and const parameters
borednuna 07e9af8
feat: use const for path variable
borednuna 9df35fd
feat: use const for path variable
borednuna acc7ef5
feat: library order
borednuna File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -21,16 +21,23 @@ | |||||||||
#ifndef TACHIMAWARI__JOINT__NODE__JOINT_NODE_HPP_ | ||||||||||
#define TACHIMAWARI__JOINT__NODE__JOINT_NODE_HPP_ | ||||||||||
|
||||||||||
#include <tf2_ros/buffer.h> | ||||||||||
|
||||||||||
#include <memory> | ||||||||||
#include <string> | ||||||||||
|
||||||||||
#include "kansei_interfaces/msg/status.hpp" | ||||||||||
#include "keisan/angle/angle.hpp" | ||||||||||
#include "rclcpp/rclcpp.hpp" | ||||||||||
#include "rclcpp/time.hpp" | ||||||||||
#include "tachimawari/joint/node/joint_manager.hpp" | ||||||||||
#include "tachimawari/joint/tf2/tf2_manager.hpp" | ||||||||||
#include "tachimawari/joint/utils/middleware.hpp" | ||||||||||
#include "tachimawari_interfaces/msg/control_joints.hpp" | ||||||||||
#include "tachimawari_interfaces/msg/current_joints.hpp" | ||||||||||
#include "tachimawari_interfaces/msg/set_joints.hpp" | ||||||||||
#include "tachimawari_interfaces/msg/set_torques.hpp" | ||||||||||
#include "tf2_ros/transform_broadcaster.h" | ||||||||||
|
||||||||||
namespace tachimawari::joint | ||||||||||
{ | ||||||||||
|
@@ -42,16 +49,21 @@ class JointNode | |||||||||
using CurrentJoints = tachimawari_interfaces::msg::CurrentJoints; | ||||||||||
using SetJoints = tachimawari_interfaces::msg::SetJoints; | ||||||||||
using SetTorques = tachimawari_interfaces::msg::SetTorques; | ||||||||||
using Status = kansei_interfaces::msg::Status; | ||||||||||
|
||||||||||
static std::string get_node_prefix(); | ||||||||||
static std::string control_joints_topic(); | ||||||||||
static std::string set_joints_topic(); | ||||||||||
static std::string set_torques_topic(); | ||||||||||
static std::string current_joints_topic(); | ||||||||||
static std::string status_topic(); | ||||||||||
|
||||||||||
JointNode(rclcpp::Node::SharedPtr node, std::shared_ptr<JointManager> joint_manager); | ||||||||||
JointNode( | ||||||||||
rclcpp::Node::SharedPtr node, std::shared_ptr<JointManager> joint_manager, std::string path); | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
keisan::Angle<double> imu_yaw; | ||||||||||
|
||||||||||
void publish_current_joints(); | ||||||||||
void publish_frame_tree(); | ||||||||||
void update(); | ||||||||||
|
||||||||||
private: | ||||||||||
|
@@ -63,8 +75,13 @@ class JointNode | |||||||||
|
||||||||||
rclcpp::Subscription<SetTorques>::SharedPtr set_torques_subscriber; | ||||||||||
|
||||||||||
rclcpp::Subscription<Status>::SharedPtr status_subscriber; | ||||||||||
|
||||||||||
Middleware middleware; | ||||||||||
rclcpp::Subscription<ControlJoints>::SharedPtr control_joints_subscriber; | ||||||||||
|
||||||||||
std::shared_ptr<tf2_ros::TransformBroadcaster> tf2_broadcaster; | ||||||||||
std::shared_ptr<Tf2Manager> tf2_manager; | ||||||||||
}; | ||||||||||
|
||||||||||
} // namespace tachimawari::joint | ||||||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// Copyright (c) 2021-2023 Ichiro ITS | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#ifndef TACHIMAWARI__JOINT__TF2__FRAME_HPP_ | ||
#define TACHIMAWARI__JOINT__TF2__FRAME_HPP_ | ||
|
||
#include <memory> | ||
#include <nlohmann/json.hpp> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "geometry_msgs/msg/transform_stamped.hpp" | ||
#include "keisan/angle/angle.hpp" | ||
#include "rclcpp/time.hpp" | ||
#include "tachimawari/joint/node/joint_manager.hpp" | ||
#include "tachimawari/joint/tf2/frame_id.hpp" | ||
#include "tf2/LinearMath/Quaternion.h" | ||
|
||
namespace tachimawari::joint | ||
{ | ||
|
||
class Frame | ||
{ | ||
public: | ||
Frame( | ||
const uint8_t id, const double translation_x, const double translation_y, | ||
const double translation_z, const double const_roll, const double const_pitch, | ||
const double const_yaw); | ||
|
||
void update_quaternion(std::vector<Joint> current_joints); | ||
void update_quaternion(keisan::Angle<double> imu_yaw); | ||
geometry_msgs::msg::TransformStamped get_transform_stamped(rclcpp::Time time_stamp); | ||
|
||
uint8_t id; | ||
|
||
double translation_x; | ||
double translation_y; | ||
double translation_z; | ||
|
||
double quaternion_x; | ||
double quaternion_y; | ||
double quaternion_z; | ||
double quaternion_w; | ||
|
||
double const_roll; | ||
double const_pitch; | ||
double const_yaw; | ||
|
||
private: | ||
enum : uint8_t { | ||
ROLL, | ||
PITCH, | ||
YAW, | ||
}; | ||
|
||
double get_joint_angle(uint8_t quaternion_axis, std::vector<Joint> current_joints); | ||
}; | ||
} // namespace tachimawari::joint | ||
|
||
#endif // TACHIMAWARI__JOINT__TF2__FRAME_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
// Copyright (c) 2021-2023 Ichiro ITS | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#ifndef TACHIMAWARI__JOINT_TF2__FRAME_ID_HPP_ | ||
#define TACHIMAWARI__JOINT_TF2__FRAME_ID_HPP_ | ||
|
||
#include <array> | ||
#include <map> | ||
#include <string> | ||
#include <vector> | ||
|
||
namespace tachimawari::joint | ||
{ | ||
|
||
class FrameId | ||
{ | ||
public: | ||
enum : uint8_t { | ||
ODOM, | ||
BASE_LINK, | ||
TORSO, | ||
HEAD, | ||
GAZE, | ||
RIGHT_THIGH, | ||
RIGHT_CALF, | ||
RIGHT_FOOT, | ||
LEFT_THIGH, | ||
LEFT_CALF, | ||
LEFT_FOOT | ||
}; | ||
|
||
static const std::array<uint8_t, 10> frame_ids; | ||
static const std::map<uint8_t, std::string> frame_id_string; | ||
static const std::map<std::string, uint8_t> frame_string_id; | ||
static const std::map<uint8_t, std::vector<uint8_t>> frame_joint_map; | ||
static const std::map<uint8_t, std::string> parent_frame; | ||
}; | ||
|
||
} // namespace tachimawari::joint | ||
|
||
#endif // TACHIMAWARI__JOINT_TF2__FRAME_ID_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2021-2023 Ichiro ITS | ||
// | ||
// Permission is hereby granted, free of charge, to any person obtaining a copy | ||
// of this software and associated documentation files (the "Software"), to deal | ||
// in the Software without restriction, including without limitation the rights | ||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
// copies of the Software, and to permit persons to whom the Software is | ||
// furnished to do so, subject to the following conditions: | ||
// | ||
// The above copyright notice and this permission notice shall be included in all | ||
// copies or substantial portions of the Software. | ||
// | ||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
// SOFTWARE. | ||
|
||
#ifndef TACHIMAWARI__JOINT__TF2__TF2_MANAGER_HPP_ | ||
#define TACHIMAWARI__JOINT__TF2__TF2_MANAGER_HPP_ | ||
|
||
#include <memory> | ||
#include <string> | ||
#include <vector> | ||
|
||
#include "keisan/angle/angle.hpp" | ||
#include "rclcpp/time.hpp" | ||
#include "tachimawari/joint/model/joint.hpp" | ||
#include "tachimawari/joint/model/joint_id.hpp" | ||
#include "tachimawari/joint/node/joint_manager.hpp" | ||
#include "tachimawari/joint/tf2/frame.hpp" | ||
#include "tachimawari/joint/tf2/frame_id.hpp" | ||
#include "tf2_ros/transform_broadcaster.h" | ||
|
||
namespace tachimawari::joint | ||
{ | ||
|
||
class Tf2Manager | ||
{ | ||
public: | ||
explicit Tf2Manager(); | ||
|
||
bool load_configuration(const std::string & path); | ||
void update(std::vector<Joint> current_joints, keisan::Angle<double> imu_yaw); | ||
std::vector<Frame> get_frames() { return frames; } | ||
|
||
private: | ||
std::vector<Frame> frames; | ||
}; | ||
} // namespace tachimawari::joint | ||
|
||
#endif // TACHIMAWARI__JOINT__TF2__TF2_MANAGER_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
library order, check another files too