GCC Code Coverage Report


Directory: ./
File: src/problem-target/state.cc
Date: 2025-03-07 11:10:46
Exec Total Coverage
Lines: 0 18 0.0%
Branches: 0 18 0.0%

Line Branch Exec Source
1 // Copyright (c) 2017, Joseph Mirabel
2 // Authors: Joseph Mirabel (joseph.mirabel@laas.fr)
3 //
4
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are
7 // met:
8 //
9 // 1. Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer.
11 //
12 // 2. Redistributions in binary form must reproduce the above copyright
13 // notice, this list of conditions and the following disclaimer in the
14 // documentation and/or other materials provided with the distribution.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
27 // DAMAGE.
28
29 #include <hpp/core/connected-component.hh>
30 #include <hpp/core/node.hh>
31 #include <hpp/core/problem.hh>
32 #include <hpp/core/roadmap.hh>
33 #include <hpp/manipulation/problem-target/state.hh>
34 #include <hpp/util/debug.hh>
35 #include <stdexcept>
36
37 #include "astar.hh"
38
39 namespace hpp {
40 namespace manipulation {
41 namespace problemTarget {
42 StatePtr_t State::create(const core::ProblemPtr_t& problem) {
43 State* tt = new State(problem);
44 StatePtr_t shPtr(tt);
45 tt->init(shPtr);
46 return shPtr;
47 }
48
49 void State::check(const core::RoadmapPtr_t&) const {
50 if (!state_) {
51 HPP_THROW(std::runtime_error, "No state: task not specified.");
52 }
53 }
54
55 bool State::reached(const core::RoadmapPtr_t& roadmap) const {
56 const core::ConnectedComponentPtr_t& _cc =
57 roadmap->initNode()->connectedComponent();
58 const ConnectedComponentPtr_t cc =
59 HPP_DYNAMIC_PTR_CAST(ConnectedComponent, _cc);
60 assert(cc);
61 return !cc->getRoadmapNodes(state_).empty();
62 }
63
64 core::PathVectorPtr_t State::computePath(
65 const core::RoadmapPtr_t& roadmap) const {
66 core::ProblemPtr_t p = problem_.lock();
67 assert(p);
68 Astar astar(roadmap, p->distance(), state_);
69 return astar.solution();
70 }
71 } // namespace problemTarget
72 } // namespace manipulation
73 } // namespace hpp
74