Directory: | ./ |
---|---|
File: | include/hpp/core/configuration-shooter/uniform-tpl.hxx |
Date: | 2024-08-10 11:29:48 |
Exec | Total | Coverage | |
---|---|---|---|
Lines: | 11 | 14 | 78.6% |
Branches: | 9 | 28 | 32.1% |
Line | Branch | Exec | Source |
---|---|---|---|
1 | // Copyright (c) 2023 Eureka Robotics | ||
2 | // Authors: Joseph Mirabel | ||
3 | |||
4 | #ifndef HPP_CORE_CONFIGURATION_SHOOTER_UNIFORM_TPL_HXX | ||
5 | #define HPP_CORE_CONFIGURATION_SHOOTER_UNIFORM_TPL_HXX | ||
6 | |||
7 | #include <hpp/core/configuration-shooter/uniform-tpl.hh> | ||
8 | #include <hpp/pinocchio/liegroup-space.hh> | ||
9 | #include <pinocchio/multibody/model.hpp> | ||
10 | |||
11 | namespace hpp { | ||
12 | namespace core { | ||
13 | namespace configurationShooter { | ||
14 | |||
15 | template <class generator_t> | ||
16 | 210 | void UniformTpl<generator_t>::impl_shoot(Configuration_t& config) const { | |
17 | typedef std::uniform_real_distribution<value_type> distribution_t; | ||
18 | |||
19 |
1/2✗ Branch 4 not taken.
✓ Branch 5 taken 210 times.
|
210 | if (!robot_->configSpace()->isVectorSpace()) { |
20 | ✗ | throw std::invalid_argument( | |
21 | "The device config space must be a vector space" | ||
22 | " to use UniformTpl"); | ||
23 | } | ||
24 | |||
25 | 210 | config.resize(robot_->configSize()); | |
26 | 210 | auto const& model = robot_->model(); | |
27 | |||
28 |
2/2✓ Branch 0 taken 210 times.
✓ Branch 1 taken 210 times.
|
420 | for (size_type i = 0; i < model.nq; ++i) { |
29 |
2/4✓ Branch 1 taken 210 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 210 times.
✗ Branch 5 not taken.
|
210 | distribution_t distrib(model.lowerPositionLimit[i], |
30 |
1/2✓ Branch 1 taken 210 times.
✗ Branch 2 not taken.
|
210 | model.upperPositionLimit[i]); |
31 |
2/4✓ Branch 1 taken 210 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 210 times.
✗ Branch 5 not taken.
|
210 | config[i] = distrib(generator_); |
32 | } | ||
33 | 210 | auto const& ecs = robot_->extraConfigSpace(); | |
34 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 210 times.
|
210 | for (size_type i = 0; i < ecs.dimension(); ++i) { |
35 | ✗ | distribution_t distrib(ecs.lower(i), ecs.upper(i)); | |
36 | ✗ | config[model.nq + i] = distrib(generator_); | |
37 | } | ||
38 | 210 | } | |
39 | |||
40 | } // namespace configurationShooter | ||
41 | } // namespace core | ||
42 | } // namespace hpp | ||
43 | |||
44 | #endif // HPP_CORE_CONFIGURATION_SHOOTER_UNIFORM_TPL_HXX | ||
45 |