|
| 1 | +// Copyright (c) 2017 Computer Vision Center (CVC) at the Universitat Autonoma |
| 2 | +// de Barcelona (UAB). |
| 3 | +// |
| 4 | +// This work is licensed under the terms of the MIT license. |
| 5 | +// For a copy, see <https://opensource.org/licenses/MIT>. |
| 6 | + |
| 7 | +#include <carla/client/Transform.h> |
| 8 | + |
| 9 | +#include <boost/python.hpp> |
| 10 | + |
| 11 | +#include <ostream> |
| 12 | + |
| 13 | +namespace carla { |
| 14 | +namespace rpc { |
| 15 | + |
| 16 | + std::ostream &operator<<(std::ostream &out, const Location &location) { |
| 17 | + out << "Location(x=" << location.x |
| 18 | + << ", y=" << location.y |
| 19 | + << ", z=" << location.z << ')'; |
| 20 | + return out; |
| 21 | + } |
| 22 | + |
| 23 | + std::ostream &operator<<(std::ostream &out, const Rotation &rotation) { |
| 24 | + out << "Rotation(pitch=" << rotation.pitch |
| 25 | + << ", yaw=" << rotation.yaw |
| 26 | + << ", roll=" << rotation.roll << ')'; |
| 27 | + return out; |
| 28 | + } |
| 29 | + |
| 30 | + std::ostream &operator<<(std::ostream &out, const Transform &transform) { |
| 31 | + out << "Transform(" << transform.location << ", " << transform.rotation << ')'; |
| 32 | + return out; |
| 33 | + } |
| 34 | + |
| 35 | +} // namespace rpc |
| 36 | +} // namespace carla |
| 37 | + |
| 38 | +void export_transform() { |
| 39 | + using namespace boost::python; |
| 40 | + namespace cc = carla::client; |
| 41 | + |
| 42 | + class_<cc::Location>("Location") |
| 43 | + .def(init<float, float, float>((arg("x")=0.0f, arg("y")=0.0f, arg("z")=0.0f))) |
| 44 | + .def_readwrite("x", &cc::Location::x) |
| 45 | + .def_readwrite("y", &cc::Location::y) |
| 46 | + .def_readwrite("z", &cc::Location::z) |
| 47 | + .def(self_ns::str(self_ns::self)) |
| 48 | + ; |
| 49 | + |
| 50 | + class_<cc::Rotation>("Rotation") |
| 51 | + .def(init<float, float, float>((arg("pitch")=0.0f, arg("yaw")=0.0f, arg("roll")=0.0f))) |
| 52 | + .def_readwrite("pitch", &cc::Rotation::pitch) |
| 53 | + .def_readwrite("yaw", &cc::Rotation::yaw) |
| 54 | + .def_readwrite("roll", &cc::Rotation::roll) |
| 55 | + .def(self_ns::str(self_ns::self)) |
| 56 | + ; |
| 57 | + |
| 58 | + class_<cc::Transform>("Transform") |
| 59 | + .def(init<cc::Location, cc::Rotation>( |
| 60 | + (arg("location")=cc::Location(), arg("rotation")=cc::Rotation()))) |
| 61 | + .def_readwrite("location", &cc::Transform::location) |
| 62 | + .def_readwrite("rotation", &cc::Transform::rotation) |
| 63 | + .def(self_ns::str(self_ns::self)) |
| 64 | + ; |
| 65 | +} |
0 commit comments