Skip to content

Commit ade76f3

Browse files
committed
remove car_assets.zip
1 parent b0bc591 commit ade76f3

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

AirLib/include/api/RpcLibAdapatorsBase.hpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,26 +57,30 @@ class RpcLibAdapatorsBase {
5757
Vector3r position;
5858
msr::airlib::real_T penetration_depth = 0;
5959
msr::airlib::TTimePoint time_stamp = 0;
60+
std::string object_name;
61+
int object_id = -1;
6062

61-
MSGPACK_DEFINE_MAP(has_collided, penetration_depth, time_stamp, normal, impact_point, position);
63+
MSGPACK_DEFINE_MAP(has_collided, penetration_depth, time_stamp, normal, impact_point, position, object_name, object_id);
6264

6365
CollisionInfo()
6466
{}
6567

6668
CollisionInfo(const msr::airlib::CollisionInfo& s)
6769
{
6870
has_collided = s.has_collided;
69-
penetration_depth = s.penetration_depth;
70-
time_stamp = s.time_stamp;
7171
normal = s.normal;
7272
impact_point = s.impact_point;
7373
position = s.position;
74+
penetration_depth = s.penetration_depth;
75+
time_stamp = s.time_stamp;
76+
object_name = s.object_name;
77+
object_id = s.object_id;
7478
}
7579

7680
msr::airlib::CollisionInfo to() const
7781
{
7882
return msr::airlib::CollisionInfo(has_collided, normal.to(), impact_point.to(), position.to(),
79-
penetration_depth, time_stamp);
83+
penetration_depth, time_stamp, object_name, object_id);
8084
}
8185
};
8286

AirLib/include/common/CommonStructs.hpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,16 +180,20 @@ struct CollisionInfo {
180180
real_T penetration_depth = 0;
181181
TTimePoint time_stamp = 0;
182182
unsigned int collision_count = 0;
183+
std::string object_name;
184+
int object_id = -1;
183185

184186
CollisionInfo()
185187
{}
186188

187189
CollisionInfo(bool has_collided_val, const Vector3r& normal_val,
188190
const Vector3r& impact_point_val, const Vector3r& position_val,
189-
real_T penetration_depth_val, TTimePoint time_stamp_val)
191+
real_T penetration_depth_val, TTimePoint time_stamp_val,
192+
const std::string& object_name_val, int object_id_val)
190193
: has_collided(has_collided_val), normal(normal_val),
191194
impact_point(impact_point_val), position(position_val),
192-
penetration_depth(penetration_depth_val), time_stamp(time_stamp_val)
195+
penetration_depth(penetration_depth_val), time_stamp(time_stamp_val),
196+
object_name(object_name_val), object_id(object_id_val)
193197
{
194198
}
195199
};

PythonClient/AirSimClient.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,8 @@ class CollisionInfo(MsgpackMixin):
7878
position = Vector3r()
7979
penetration_depth = np.float32(0)
8080
time_stamp = np.float32(0)
81+
object_name = ""
82+
object_id = -1
8183

8284
class GeoPoint(MsgpackMixin):
8385
latitude = 0.0

PythonClient/car_collision.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222
collision_info = client.getCollisionInfo()
2323

2424
if collision_info.has_collided:
25-
print("Collision at pos %s, normal %s, impact pt %s, penetration %f" % (
25+
print("Collision at pos %s, normal %s, impact pt %s, penetration %f, name %s, obj id %d" % (
2626
pprint.pformat(collision_info.position),
2727
pprint.pformat(collision_info.normal),
2828
pprint.pformat(collision_info.impact_point),
29-
collision_info.penetration_depth))
29+
collision_info.penetration_depth, collision_info.object_name, collision_info.object_id))
3030
break
3131

3232
time.sleep(0.1)

Unreal/Plugins/AirSim/Source/VehiclePawnWrapper.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,24 @@ void VehiclePawnWrapper::onCollision(class UPrimitiveComponent* MyComp, class AA
7171
//FRotator CurrentRotation = GetActorRotation(RootComponent);
7272
//SetActorRotation(FQuat::Slerp(CurrentRotation.Quaternion(), HitNormal.ToOrientationQuat(), 0.025f));
7373

74+
UPrimitiveComponent* comp = Other ? (Other->GetRootPrimitiveComponent() ? Other->GetRootPrimitiveComponent() : nullptr) : nullptr;
75+
7476
state_.collision_info.has_collided = true;
7577
state_.collision_info.normal = NedTransform::toVector3r(Hit.ImpactNormal, 1, true);
7678
state_.collision_info.impact_point = NedTransform::toNedMeters(Hit.ImpactPoint);
7779
state_.collision_info.position = NedTransform::toNedMeters(getPosition());
7880
state_.collision_info.penetration_depth = NedTransform::toNedMeters(Hit.PenetrationDepth);
7981
state_.collision_info.time_stamp = msr::airlib::ClockFactory::get()->nowNanos();
82+
state_.collision_info.object_name = std::string(Other ? TCHAR_TO_UTF8(*(Other->GetName())) : "(null)");
83+
state_.collision_info.object_id = comp ? comp->CustomDepthStencilValue : -1;
84+
8085
++state_.collision_info.collision_count;
8186

82-
UAirBlueprintLib::LogMessage(TEXT("Collision Count:"), FString::FromInt(
83-
state_.collision_info.collision_count), LogDebugLevel::Failure);
87+
88+
UAirBlueprintLib::LogMessageString("Collision", Utils::stringf("#%d with %s - ObjID %d",
89+
state_.collision_info.collision_count,
90+
state_.collision_info.object_name.c_str(), state_.collision_info.object_id),
91+
LogDebugLevel::Failure);
8492
}
8593

8694
APawn* VehiclePawnWrapper::getPawn()

0 commit comments

Comments
 (0)