|
| 1 | +/* |
| 2 | + * Copyright (C) 2015-2018 Vrije Universiteit Amsterdam |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + * Description: TODO: <Add brief description about file purpose> |
| 17 | + * Author: Milan Jelisavcic |
| 18 | + * Date: December 23, 2018 |
| 19 | + * |
| 20 | + */ |
| 21 | + |
| 22 | +#include <revolve/gazebo/brains/BrainFactory.h> |
| 23 | +#include <revolve/gazebo/brains/Brains.h> |
| 24 | + |
| 25 | +namespace gz = gazebo; |
| 26 | + |
| 27 | +using namespace revolve::gazebo; |
| 28 | + |
| 29 | +///////////////////////////////////////////////// |
| 30 | +BrainFactory::BrainFactory(::gazebo::physics::ModelPtr _model) |
| 31 | + : model_(_model) |
| 32 | +{ |
| 33 | +} |
| 34 | + |
| 35 | +///////////////////////////////////////////////// |
| 36 | +BrainFactory::~BrainFactory() = default; |
| 37 | + |
| 38 | +/////////////////////////////////////////////////// |
| 39 | +//BrainPtr BrainFactory::Brain( |
| 40 | +// sdf::ElementPtr _brainSdf, |
| 41 | +// const std::vector< MotorPtr > &_motors, |
| 42 | +// const std::vector< SensorPtr > &_sensors) |
| 43 | +//{ |
| 44 | +// BrainPtr brain = nullptr; |
| 45 | +//// if ("ann" == _type) |
| 46 | +//// { |
| 47 | +//// brain.reset(new NeuralNetwork(model_, _brainSdf, _motors, _sensors)); |
| 48 | +//// } |
| 49 | +//// else if ("rlpower" == _type) |
| 50 | +//// { |
| 51 | +//// brain.reset(new RLPower(model_, _brainSdf, _motors, _sensors)); |
| 52 | +//// } |
| 53 | +//// else if ("diff_cpg" == type) |
| 54 | +//// { |
| 55 | +//// brain.reset(new ); |
| 56 | +//// } |
| 57 | +// |
| 58 | +// return brain; |
| 59 | +//} |
| 60 | +// |
| 61 | +/////////////////////////////////////////////////// |
| 62 | +//BrainPtr BrainFactory::Create( |
| 63 | +// sdf::ElementPtr _brainSdf, |
| 64 | +// const std::vector< MotorPtr > &_motors, |
| 65 | +// const std::vector< SensorPtr > &_sensors) |
| 66 | +//{ |
| 67 | +//// auto typeParam = _motorSdf->GetAttribute("type"); |
| 68 | +//// auto partIdParam = _motorSdf->GetAttribute("part_id"); |
| 69 | +//// auto idParam = _motorSdf->GetAttribute("id"); |
| 70 | +//// |
| 71 | +//// if (not typeParam or not partIdParam or not idParam) |
| 72 | +//// { |
| 73 | +//// std::cerr << "Motor is missing required attributes (`id`, `type` or " |
| 74 | +//// "`part_id`)." << std::endl; |
| 75 | +//// throw std::runtime_error("Motor error"); |
| 76 | +//// } |
| 77 | +//// |
| 78 | +//// auto partId = partIdParam->GetAsString(); |
| 79 | +//// auto type = typeParam->GetAsString(); |
| 80 | +//// auto id = idParam->GetAsString(); |
| 81 | +// |
| 82 | +// BrainPtr brain = nullptr; |
| 83 | +//// this->Brain(_brainSdf, _motors, _sensors); |
| 84 | +//// assert(not brain || "[BrainFactory::Create] Brain type is unknown."); |
| 85 | +// |
| 86 | +// return brain; |
| 87 | +//} |
0 commit comments