-
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
Changes from 15 commits
ab5d62f
67c7c15
699cdf5
c372bb5
36daa51
f0b12c0
80eb33f
b34838d
f5a6aa7
60e5acc
3a6bea7
e378c75
df9aae2
c590e5b
f07ebda
212a982
07e9af8
9df35fd
acc7ef5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||||||||||
|
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 = 0, | ||
PITCH = 1, | ||
YAW = 2, | ||
}; | ||
|
||
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. No need to assign int values in enum |
||
double get_joint_angle(uint8_t quaternion_axis, std::vector<Joint> current_joints); | ||
}; | ||
} // namespace tachimawari::joint | ||
|
||
#endif // TACHIMAWARI__JOINT__TF2__FRAME_HPP_ |
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 = 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 | ||
}; | ||
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. ditto. |
||
|
||
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_ |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,56 @@ | ||||||
// 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(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
|
||||||
void update(std::vector<Joint> current_joints, keisan::Angle<double> imu_yaw); | ||||||
std::vector<Frame> get_frames() { return frames; } | ||||||
|
||||||
private: | ||||||
static const std::vector<std::pair<int, int>> tf2_joint_pairs; | ||||||
std::string config_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. cmiiw, i don't see this variable ever used |
||||||
std::vector<Frame> frames; | ||||||
}; | ||||||
} // namespace tachimawari::joint | ||||||
|
||||||
#endif // TACHIMAWARI__JOINT__TF2__TF2_MANAGER_HPP_ |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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); | ||||||
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
|
||||||
|
||||||
void run_imu_provider(); | ||||||
|
||||||
private: | ||||||
rclcpp::Node::SharedPtr node; | ||||||
rclcpp::TimerBase::SharedPtr node_timer; | ||||||
rclcpp::TimerBase::SharedPtr node_timer_tf; | ||||||
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. cmiiw, this also unused |
||||||
|
||||||
std::shared_ptr<control::ControlManager> control_manager; | ||||||
|
||||||
|
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