diff --git a/CHANGELOG.md b/CHANGELOG.md index f13ead6fb..e6805bfd3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ * API extension: waypoint's `junction_id` that returns de OpenDrive identifier of the current junction * API extension: add gamma value as attribute to RGB camera * API change: deprecated waypoint's `is_intersection`, now is `is_junction` + * API update: solve the problem of RuntimeError: std::bad_cast described here: #1125 (comment) * Removed deprecated code and content * New recorder features: - Added optional parameter to show more details about a recorder file (related to `show_recorder_file_info.py`) diff --git a/PythonAPI/carla/source/libcarla/Blueprint.cpp b/PythonAPI/carla/source/libcarla/Blueprint.cpp index b0f99b42c..132d3a0d3 100644 --- a/PythonAPI/carla/source/libcarla/Blueprint.cpp +++ b/PythonAPI/carla/source/libcarla/Blueprint.cpp @@ -17,10 +17,10 @@ namespace sensor { namespace data { std::ostream &operator<<(std::ostream &out, const Color &color) { - out << "Color(" << int(color.r) - << ',' << int(color.g) - << ',' << int(color.b) - << ',' << int(color.a) << ')'; + out << "Color(" << std::to_string(color.r) + << ',' << std::to_string(color.g) + << ',' << std::to_string(color.b) + << ',' << std::to_string(color.a) << ')'; return out; } diff --git a/PythonAPI/carla/source/libcarla/Control.cpp b/PythonAPI/carla/source/libcarla/Control.cpp index d2c985044..10f880cab 100644 --- a/PythonAPI/carla/source/libcarla/Control.cpp +++ b/PythonAPI/carla/source/libcarla/Control.cpp @@ -19,44 +19,44 @@ namespace rpc { }; std::ostream &operator<<(std::ostream &out, const VehicleControl &control) { - out << "VehicleControl(throttle=" << control.throttle - << ", steer=" << control.steer - << ", brake=" << control.brake + out << "VehicleControl(throttle=" << std::to_string(control.throttle) + << ", steer=" << std::to_string(control.steer) + << ", brake=" << std::to_string(control.brake) << ", hand_brake=" << boolalpha(control.hand_brake) << ", reverse=" << boolalpha(control.reverse) << ", manual_gear_shift=" << boolalpha(control.manual_gear_shift) - << ", gear=" << control.gear << ')'; + << ", gear=" << std::to_string(control.gear) << ')'; return out; } std::ostream &operator<<(std::ostream &out, const WalkerControl &control) { out << "WalkerControl(direction=" << control.direction - << ", speed=" << control.speed + << ", speed=" << std::to_string(control.speed) << ", jump=" << boolalpha(control.jump) << ')'; return out; } std::ostream &operator<<(std::ostream &out, const WheelPhysicsControl &control) { - out << "WheelPhysicsControl(tire_friction=" << control.tire_friction - << ", damping_rate=" << control.damping_rate - << ", max_steer_angle=" << control.max_steer_angle - << ", radius=" << control.radius + out << "WheelPhysicsControl(tire_friction=" << std::to_string(control.tire_friction) + << ", damping_rate=" << std::to_string(control.damping_rate) + << ", max_steer_angle=" << std::to_string(control.max_steer_angle) + << ", radius=" << std::to_string(control.radius) << ", position=" << control.position << ')'; return out; } std::ostream &operator<<(std::ostream &out, const VehiclePhysicsControl &control) { out << "VehiclePhysicsControl(torque_curve=" << control.torque_curve - << ", max_rpm=" << control.max_rpm - << ", moi=" << control.moi - << ", damping_rate_full_throttle=" << control.damping_rate_full_throttle - << ", damping_rate_zero_throttle_clutch_engaged=" << control.damping_rate_zero_throttle_clutch_engaged - << ", damping_rate_zero_throttle_clutch_disengaged=" << control.damping_rate_zero_throttle_clutch_disengaged + << ", max_rpm=" << std::to_string(control.max_rpm) + << ", moi=" << std::to_string(control.moi) + << ", damping_rate_full_throttle=" << std::to_string(control.damping_rate_full_throttle) + << ", damping_rate_zero_throttle_clutch_engaged=" << std::to_string(control.damping_rate_zero_throttle_clutch_engaged) + << ", damping_rate_zero_throttle_clutch_disengaged=" << std::to_string(control.damping_rate_zero_throttle_clutch_disengaged) << ", use_gear_autobox=" << boolalpha(control.use_gear_autobox) - << ", gear_switch_time=" << control.gear_switch_time - << ", clutch_strength=" << control.clutch_strength - << ", mass=" << control.mass - << ", drag_coefficient=" << control.drag_coefficient + << ", gear_switch_time=" << std::to_string(control.gear_switch_time) + << ", clutch_strength=" << std::to_string(control.clutch_strength) + << ", mass=" << std::to_string(control.mass) + << ", drag_coefficient=" << std::to_string(control.drag_coefficient) << ", center_of_mass=" << control.center_of_mass << ", steering_curve=" << control.steering_curve << ", wheels=" << control.wheels << ')'; diff --git a/PythonAPI/carla/source/libcarla/Geom.cpp b/PythonAPI/carla/source/libcarla/Geom.cpp index c56fad933..702ecd28b 100644 --- a/PythonAPI/carla/source/libcarla/Geom.cpp +++ b/PythonAPI/carla/source/libcarla/Geom.cpp @@ -23,16 +23,16 @@ namespace geom { template static void WriteVector2D(std::ostream &out, const char *name, const T &vector2D) { out << name - << "(x=" << vector2D.x - << ", y=" << vector2D.y << ')'; + << "(x=" << std::to_string(vector2D.x) + << ", y=" << std::to_string(vector2D.y) << ')'; } template static void WriteVector3D(std::ostream &out, const char *name, const T &vector3D) { out << name - << "(x=" << vector3D.x - << ", y=" << vector3D.y - << ", z=" << vector3D.z << ')'; + << "(x=" << std::to_string(vector3D.x) + << ", y=" << std::to_string(vector3D.y) + << ", z=" << std::to_string(vector3D.z) << ')'; } std::ostream &operator<<(std::ostream &out, const Vector2D &vector2D) { @@ -51,9 +51,9 @@ namespace geom { } std::ostream &operator<<(std::ostream &out, const Rotation &rotation) { - out << "Rotation(pitch=" << rotation.pitch - << ", yaw=" << rotation.yaw - << ", roll=" << rotation.roll << ')'; + out << "Rotation(pitch=" << std::to_string(rotation.pitch) + << ", yaw=" << std::to_string(rotation.yaw) + << ", roll=" << std::to_string(rotation.roll) << ')'; return out; } @@ -70,9 +70,9 @@ namespace geom { } std::ostream &operator<<(std::ostream &out, const GeoLocation &geo_location) { - out << "GeoLocation(latitude=" << geo_location.latitude - << ", longitude=" << geo_location.longitude - << ", altitude=" << geo_location.altitude << ')'; + out << "GeoLocation(latitude=" << std::to_string(geo_location.latitude) + << ", longitude=" << std::to_string(geo_location.longitude) + << ", altitude=" << std::to_string(geo_location.altitude) << ')'; return out; } diff --git a/PythonAPI/carla/source/libcarla/Weather.cpp b/PythonAPI/carla/source/libcarla/Weather.cpp index 623911bec..547d2fd21 100644 --- a/PythonAPI/carla/source/libcarla/Weather.cpp +++ b/PythonAPI/carla/source/libcarla/Weather.cpp @@ -12,12 +12,12 @@ namespace carla { namespace rpc { std::ostream &operator<<(std::ostream &out, const WeatherParameters &weather) { - out << "WeatherParameters(cloudyness=" << weather.cloudyness - << ", precipitation=" << weather.precipitation - << ", precipitation_deposits=" << weather.precipitation_deposits - << ", wind_intensity=" << weather.wind_intensity - << ", sun_azimuth_angle=" << weather.sun_azimuth_angle - << ", sun_altitude_angle=" << weather.sun_altitude_angle << ')'; + out << "WeatherParameters(cloudyness=" << std::to_string(weather.cloudyness) + << ", precipitation=" << std::to_string(weather.precipitation) + << ", precipitation_deposits=" << std::to_string(weather.precipitation_deposits) + << ", wind_intensity=" << std::to_string(weather.wind_intensity) + << ", sun_azimuth_angle=" << std::to_string(weather.sun_azimuth_angle) + << ", sun_altitude_angle=" << std::to_string(weather.sun_altitude_angle) << ')'; return out; } diff --git a/PythonAPI/carla/source/libcarla/World.cpp b/PythonAPI/carla/source/libcarla/World.cpp index 114031299..20a1cd8b8 100644 --- a/PythonAPI/carla/source/libcarla/World.cpp +++ b/PythonAPI/carla/source/libcarla/World.cpp @@ -19,10 +19,10 @@ namespace client { } std::ostream &operator<<(std::ostream &out, const Timestamp ×tamp) { - out << "Timestamp(frame_count=" << timestamp.frame_count - << ",elapsed_seconds=" << timestamp.elapsed_seconds - << ",delta_seconds=" << timestamp.delta_seconds - << ",platform_timestamp=" << timestamp.platform_timestamp << ')'; + out << "Timestamp(frame_count=" << std::to_string(timestamp.frame_count) + << ",elapsed_seconds=" << std::to_string(timestamp.elapsed_seconds) + << ",delta_seconds=" << std::to_string(timestamp.delta_seconds) + << ",platform_timestamp=" << std::to_string(timestamp.platform_timestamp) << ')'; return out; } diff --git a/PythonAPI/test/unit/test_transform.py b/PythonAPI/test/unit/test_transform.py index b7f75f04f..54ab634f8 100644 --- a/PythonAPI/test/unit/test_transform.py +++ b/PythonAPI/test/unit/test_transform.py @@ -113,7 +113,7 @@ class TestTransform(unittest.TestCase): t = carla.Transform( carla.Location(x=1.0, y=2.0, z=3.0), carla.Rotation(pitch=4.0, yaw=5.0, roll=6.0)) - s = 'Transform(Location(x=1, y=2, z=3), Rotation(pitch=4, yaw=5, roll=6))' + s = 'Transform(Location(x=1.000000, y=2.000000, z=3.000000), Rotation(pitch=4.000000, yaw=5.000000, roll=6.000000))' self.assertEqual(str(t), s) def test_translation(self):