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

modifying pacmod3 ros2 driver to work with pacmod2 #22

Merged
merged 7 commits into from
Apr 26, 2023

Conversation

cullenstoneAS
Copy link

No description provided.

std::pair<std::shared_ptr<rclcpp::SubscriptionBase>,
std::shared_ptr<LockedData>>> can_subs_;

std::shared_ptr<std::thread> pub_thread_;
Copy link

@jilinzhouas jilinzhouas Apr 24, 2023

Choose a reason for hiding this comment

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

if this pub_thread_ is not shared with anyone else, use std::unique_ptr instead.

std::unique_ptr<std::thread> pub_thread_ = nullptr;

Copy link
Author

Choose a reason for hiding this comment

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

done

void publish_cmds();
//void set_enable(bool enable);

static constexpr auto SEND_CMD_INTERVAL = std::chrono::milliseconds(33);

Choose a reason for hiding this comment

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

If these two static variables are not referenced by other classes, we can move the definitions to its cpp file.

Copy link
Author

Choose a reason for hiding this comment

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

can't declare static constexpr without an initializer

this->create_subscription<pacmod2_msgs::msg::SystemCmdFloat>(
"accel_cmd", 20,
std::bind(&PACMod2Node::callback_accel_cmd, this, std::placeholders::_1)),
std::shared_ptr<LockedData>(new LockedData(AccelCmdMsg::DATA_LENGTH)));

Choose a reason for hiding this comment

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

In c++14, we can use std::make_shared<> to create a shared pointer. It is a preferred way.
https://learn.microsoft.com/en-us/cpp/cpp/how-to-create-and-use-shared-ptr-instances?view=msvc-170

Copy link
Author

Choose a reason for hiding this comment

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

don't want to make this change because of this:
https://stackoverflow.com/questions/70027525/undefined-reference-to-initialized-static-member-variable-with-make-shared

work around is std::make_shared<LockedData>(+AccelCmdMsg::DATA_LENGTH) but I think this is weird. I can make the change if others disagree.

Copy link
Member

@icolwell-as icolwell-as left a comment

Choose a reason for hiding this comment

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

Just a couple small things.

package.xml Outdated Show resolved Hide resolved
src/pacmod2_node.cpp Outdated Show resolved Hide resolved
src/pacmod2_node.cpp Outdated Show resolved Hide resolved
@cullenstoneAS cullenstoneAS merged commit f930c78 into ros2_master Apr 26, 2023
@cullenstoneAS cullenstoneAS deleted the ros2_devel branch April 26, 2023 21:24
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