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

Don't hardcode int64_t for duration type representations #648

Merged
merged 1 commit into from Mar 12, 2019

Conversation

4 participants
@emersonknapp
Copy link
Contributor

commented Mar 4, 2019

In LLVM's libcxx, int64_t doesn't match chrono literals. See example below. To compile, run clang++-6.0 -stdlib=libc++ -std=c++14 TEST.cpp

TEST.cpp

using namespace std::chrono_literals;

template<typename RatioT = std::milli>
bool
wait_for_service(
   std::chrono::duration<int64_t, RatioT> timeout
)
{
   return timeout == std::chrono::nanoseconds(0);
}

int main() {
   wait_for_service(2s);
   return 0;
}

Result of compilation

TEST.cpp:14:4: error: no matching function for call to 'wait_for_service'
   wait_for_service(2s);
   ^~~~~~~~~~~~~~~~
TEST.cpp:6:1: note: candidate template ignored: could not match 'long' against 'long long'
wait_for_service(
^
1 error generated.

Related to ros2/ros2#664

@tfoote tfoote added the in review label Mar 4, 2019

@emersonknapp emersonknapp force-pushed the emersonknapp:durationtype branch from 8154fe1 to c5ad3d1 Mar 4, 2019

@thomas-moulard

This comment has been minimized.

Copy link

commented Mar 4, 2019

Thanks @emersonknapp, this LGTM.

@thomas-moulard thomas-moulard added this to In progress in AWS Robotics Mar 4, 2019

@thomas-moulard thomas-moulard moved this from In progress to Needs review in AWS Robotics Mar 4, 2019

@thomas-moulard

This comment has been minimized.

Copy link

commented Mar 5, 2019

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@emersonknapp emersonknapp force-pushed the emersonknapp:durationtype branch from c5ad3d1 to 81976c7 Mar 5, 2019

@emersonknapp

This comment has been minimized.

@thomas-moulard

This comment has been minimized.

Copy link

commented Mar 5, 2019

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status
@thomas-moulard

This comment has been minimized.

Copy link

commented Mar 5, 2019

Windows and OS X builds are currently unstable due to #646 - safe to ignore until the root cause has been fixed.

@thomas-moulard

This comment has been minimized.

Copy link

commented Mar 5, 2019

@emersonknapp #646 is actually fixing the problems you're seeing so IIUC this PR is OK, we should rebase though.

Don't hardcode int64_t for duration type representations
In LLVM's `libcxx`, `int64_t` doesn't match chrono literals. See example below. To compile, run  `clang++-6.0 -stdlib=libc++ -std=c++14 TEST.cpp`

```
using namespace std::chrono_literals;

template<typename RatioT = std::milli>
bool
wait_for_service(
   std::chrono::duration<int64_t, RatioT> timeout
)
{
   return timeout == std::chrono::nanoseconds(0);
}

int main() {
   wait_for_service(2s);
   return 0;
}

```

Result of compilation
```
TEST.cpp:6:1: note: candidate template ignored: could not match 'long' against 'long long'
wait_for_service(
```

Signed-off-by: Emerson Knapp <eknapp@amazon.com>

@emersonknapp emersonknapp force-pushed the emersonknapp:durationtype branch from 81976c7 to c871c47 Mar 5, 2019

@emersonknapp

This comment has been minimized.

Copy link
Contributor Author

commented Mar 5, 2019

@thomas-moulard Nice! Rebased - the same gist works.

@thomas-moulard

This comment has been minimized.

Copy link

commented Mar 5, 2019

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status
@nuclearsandwich

This comment has been minimized.

Copy link
Member

commented Mar 7, 2019

Full CI with all of the libcxx PRs together + a clang+libcxx on Linux run

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status
  • Linux Clang+libcxx Build Status
@thomas-moulard

This comment has been minimized.

Copy link

commented Mar 7, 2019

@nuclearsandwich I don't think it makes sense to gate merging this one on having all of TSA related PRs green. Arguably, rclcpp makes an assumption about std::chrono types which just does not seem to hold so IMHO this PR is a step in the right direction - what prevents us from merging this now?

@nuclearsandwich

This comment has been minimized.

Copy link
Member

commented Mar 7, 2019

I don't think it makes sense to gate merging this one on having all of TSA related PRs green.

No, I agree. My apologies if linking the CI gave the impression I expected it all to light up 📗 before this merged. I linked the above CI across all PRs that were listed in colcon/colcon-mixin-repository#16 as the results are hopefully informational for @emersonknapp.

what prevents us from merging this now?

I couldn't say. I'm not the right Open Robotics reviewer for this PR as I'm not confident that my knowledge of C++ standards is sufficient.

@emersonknapp

This comment has been minimized.

Copy link
Contributor Author

commented Mar 7, 2019

@nuclearsandwich do you know who is the right reviewer for this, and can we assign them to the PR?

AWS Robotics automation moved this from Needs review to Reviewer approved Mar 7, 2019

@tfoote

tfoote approved these changes Mar 7, 2019

Copy link
Contributor

left a comment

lgtm. This is just exposing the internal template element slightly higher making the functions slightly more generic.

@emersonknapp

This comment has been minimized.

Copy link
Contributor Author

commented Mar 12, 2019

@tfoote Is anything stopping us from merging?

@emersonknapp emersonknapp referenced this pull request Mar 12, 2019

Closed

[ROS2 QA] Implement PoC for Thread-Safety annotation #664

0 of 3 tasks complete

@nuclearsandwich nuclearsandwich merged commit 83beaf8 into ros2:master Mar 12, 2019

1 check passed

DCO DCO
Details

AWS Robotics automation moved this from Reviewer approved to Done Mar 12, 2019

mm318 added a commit to aws-ros-dev/rclcpp that referenced this pull request Mar 29, 2019

rclcpp QoS implementation (#2)
* Add interfaces for events in memory_strategy

Signed-off-by: Miaofei <miaofei@amazon.com>

* refactor waitables

Signed-off-by: Miaofei <miaofei@amazon.com>

* Attempt to fix cppcheck (ros2#646)

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* add event callbacks to publisher, subscriber, client, service

Signed-off-by: Miaofei <miaofei@amazon.com>

* fix some ros2 build issues

Signed-off-by: Miaofei <miaofei@amazon.com>

* Add a method to the LifecycleNode class to get the logging interface (ros2#652)

There are getters for the other interfaces, but the logging interface
appears to have been overlooked.

Signed-off-by: Michael Jeronimo <michael.jeronimo@intel.com>

* Add Doxyfile for rclcpp_action

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add documentation to rclcpp_action

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* update to use separated action types (ros2#601)

* match renamed action types

* fix action type casting

* rename type/field to use correct term

* rename custom GoalID type to avoid naming collision, update types using unique_identifier_msgs

* remove obsolete comments

* change signature of set_succeeded / set_canceled

* change signature of     on_terminal_state_(uuid_, result_msg);set_succeeded / set_canceled

* change signature of set_aborted

* change signature of publish_feedback

* update another test

Signed-off-by: Miaofei <miaofei@amazon.com>

* update client-facing API

Signed-off-by: Miaofei <miaofei@amazon.com>

* Don't hardcode int64_t for duration type representations (ros2#648)

In LLVM's `libcxx`, `int64_t` doesn't match chrono literals. See example below. To compile, run  `clang++-6.0 -stdlib=libc++ -std=c++14 TEST.cpp`

```
using namespace std::chrono_literals;

template<typename RatioT = std::milli>
bool
wait_for_service(
   std::chrono::duration<int64_t, RatioT> timeout
)
{
   return timeout == std::chrono::nanoseconds(0);
}

int main() {
   wait_for_service(2s);
   return 0;
}

```

Result of compilation
```
TEST.cpp:6:1: note: candidate template ignored: could not match 'long' against 'long long'
wait_for_service(
```

Signed-off-by: Emerson Knapp <eknapp@amazon.com>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* improve usability of the SubscriptionOptions and PublisherOptions classes

Signed-off-by: Miaofei <miaofei@amazon.com>

* Fix test_time_source test (ros2#639)

* Fix flakey test

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* Fix lint and uncrustify issues

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* fix lint errors

Signed-off-by: Miaofei <miaofei@amazon.com>

* apply uncrustify

Signed-off-by: Miaofei <miaofei@amazon.com>

* add section about DCO to CONTRIBUTING.md

* update for rcl API changes

Signed-off-by: Miaofei <miaofei@amazon.com>

* Fix lint and build warnings and API inconsistency

Signed-off-by: Emerson Knapp <eknapp@amazon.com>

* Avoid race that triggers timer too often (ros2#621)

The two distinct operations of acquiring and subsequent checking of a
timer have to be protected by one lock_guard against races with other
threads. The releasing of a timer has to be protected by the same lock.

Given this requirement there is no use for a second mutex.

Signed-off-by: Marko Durkovic <marko@ternaris.com>

* Back out Waitable and GraphEvent-related changes

Signed-off-by: Emerson Knapp <eknapp@amazon.com>

* add publisher and subscription events to AllocatorMemoryStrategy

* Add stub API for assert_liveliness

* Fix use_sim_time issue on LifeCycleNode (ros2#651)

Signed-off-by: vinnamkim <vinnam.kim@gmail.com>

* revert changes to client and services
address PR comments

Signed-off-by: Miaofei <miaofei@amazon.com>

* Add parameter-related templates to LifecycleNode (ros2#645)

* Add parameter-related templates to LifecycleNode

Signed-off-by: vinnamkim <vinnam.kim@gmail.com>

* Update rclcpp_lifecycle/include/rclcpp_lifecycle/lifecycle_node.hpp

Co-Authored-By: vinnamkim <vinnam.kim@gmail.com>

* Update rclcpp_lifecycle/include/rclcpp_lifecycle/lifecycle_node.hpp

* update API calls into rcl

* fix linter errors in rclcpp_lifecycle (ros2#672)

Signed-off-by: Karsten Knese <karsten@openrobotics.org>

mm318 added a commit to aws-ros-dev/rclcpp that referenced this pull request Apr 2, 2019

Update rclcpp functionality to use new interfaces (#4)
* New interfaces for incoming QoS features

Adds new PublisherOptions and SubscriptionOptions classes, with new Publisher and Subscriber constructors
to accept them. Adds the liveliness assertion callbacks that will be needed for the new Liveliness QoS policy

Signed-off-by: Emerson Knapp <eknapp@amazon.com>

* Fix options usage in implementation, and add test to catch that code path.

Signed-off-by: Emerson Knapp <eknapp@amazon.com>

* rclcpp QoS implementation (#2)

* Add interfaces for events in memory_strategy

Signed-off-by: Miaofei <miaofei@amazon.com>

* refactor waitables

Signed-off-by: Miaofei <miaofei@amazon.com>

* Attempt to fix cppcheck (ros2#646)

Signed-off-by: Shane Loretz <sloretz@osrfoundation.org>

* add event callbacks to publisher, subscriber, client, service

Signed-off-by: Miaofei <miaofei@amazon.com>

* fix some ros2 build issues

Signed-off-by: Miaofei <miaofei@amazon.com>

* Add a method to the LifecycleNode class to get the logging interface (ros2#652)

There are getters for the other interfaces, but the logging interface
appears to have been overlooked.

Signed-off-by: Michael Jeronimo <michael.jeronimo@intel.com>

* Add Doxyfile for rclcpp_action

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* Add documentation to rclcpp_action

Signed-off-by: Jacob Perron <jacob@openrobotics.org>

* update to use separated action types (ros2#601)

* match renamed action types

* fix action type casting

* rename type/field to use correct term

* rename custom GoalID type to avoid naming collision, update types using unique_identifier_msgs

* remove obsolete comments

* change signature of set_succeeded / set_canceled

* change signature of     on_terminal_state_(uuid_, result_msg);set_succeeded / set_canceled

* change signature of set_aborted

* change signature of publish_feedback

* update another test

Signed-off-by: Miaofei <miaofei@amazon.com>

* update client-facing API

Signed-off-by: Miaofei <miaofei@amazon.com>

* Don't hardcode int64_t for duration type representations (ros2#648)

In LLVM's `libcxx`, `int64_t` doesn't match chrono literals. See example below. To compile, run  `clang++-6.0 -stdlib=libc++ -std=c++14 TEST.cpp`

```
using namespace std::chrono_literals;

template<typename RatioT = std::milli>
bool
wait_for_service(
   std::chrono::duration<int64_t, RatioT> timeout
)
{
   return timeout == std::chrono::nanoseconds(0);
}

int main() {
   wait_for_service(2s);
   return 0;
}

```

Result of compilation
```
TEST.cpp:6:1: note: candidate template ignored: could not match 'long' against 'long long'
wait_for_service(
```

Signed-off-by: Emerson Knapp <eknapp@amazon.com>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>

* improve usability of the SubscriptionOptions and PublisherOptions classes

Signed-off-by: Miaofei <miaofei@amazon.com>

* Fix test_time_source test (ros2#639)

* Fix flakey test

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* Fix lint and uncrustify issues

Signed-off-by: Pete Baughman <pete.baughman@apex.ai>

* fix lint errors

Signed-off-by: Miaofei <miaofei@amazon.com>

* apply uncrustify

Signed-off-by: Miaofei <miaofei@amazon.com>

* add section about DCO to CONTRIBUTING.md

* update for rcl API changes

Signed-off-by: Miaofei <miaofei@amazon.com>

* Fix lint and build warnings and API inconsistency

Signed-off-by: Emerson Knapp <eknapp@amazon.com>

* Avoid race that triggers timer too often (ros2#621)

The two distinct operations of acquiring and subsequent checking of a
timer have to be protected by one lock_guard against races with other
threads. The releasing of a timer has to be protected by the same lock.

Given this requirement there is no use for a second mutex.

Signed-off-by: Marko Durkovic <marko@ternaris.com>

* Back out Waitable and GraphEvent-related changes

Signed-off-by: Emerson Knapp <eknapp@amazon.com>

* add publisher and subscription events to AllocatorMemoryStrategy

* Add stub API for assert_liveliness

* Fix use_sim_time issue on LifeCycleNode (ros2#651)

Signed-off-by: vinnamkim <vinnam.kim@gmail.com>

* revert changes to client and services
address PR comments

Signed-off-by: Miaofei <miaofei@amazon.com>

* Add parameter-related templates to LifecycleNode (ros2#645)

* Add parameter-related templates to LifecycleNode

Signed-off-by: vinnamkim <vinnam.kim@gmail.com>

* Update rclcpp_lifecycle/include/rclcpp_lifecycle/lifecycle_node.hpp

Co-Authored-By: vinnamkim <vinnam.kim@gmail.com>

* Update rclcpp_lifecycle/include/rclcpp_lifecycle/lifecycle_node.hpp

* update API calls into rcl

* fix linter errors in rclcpp_lifecycle (ros2#672)

Signed-off-by: Karsten Knese <karsten@openrobotics.org>

* Update to use the new interface definitions

Signed-off-by: Emerson Knapp <eknapp@amazon.com>

* Remove duplicate event_handlers_

cho3 pushed a commit to cho3/rclcpp that referenced this pull request Jun 3, 2019

Don't hardcode int64_t for duration type representations (ros2#648)
In LLVM's `libcxx`, `int64_t` doesn't match chrono literals. See example below. To compile, run  `clang++-6.0 -stdlib=libc++ -std=c++14 TEST.cpp`

```
using namespace std::chrono_literals;

template<typename RatioT = std::milli>
bool
wait_for_service(
   std::chrono::duration<int64_t, RatioT> timeout
)
{
   return timeout == std::chrono::nanoseconds(0);
}

int main() {
   wait_for_service(2s);
   return 0;
}

```

Result of compilation
```
TEST.cpp:6:1: note: candidate template ignored: could not match 'long' against 'long long'
wait_for_service(
```

Signed-off-by: Emerson Knapp <eknapp@amazon.com>
Signed-off-by: Steven! Ragnarök <steven@nuclearsandwich.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.