Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review the collisionMask passed to rayCastClosest(..) #35

Open
gavanderhoorn opened this issue Jun 8, 2021 · 6 comments
Open

Review the collisionMask passed to rayCastClosest(..) #35

gavanderhoorn opened this issue Jun 8, 2021 · 6 comments
Labels
help wanted lua Issues requiring changes/fixes to the Lua code nice-to-have A nice feature, but not a priority right now

Comments

@gavanderhoorn
Copy link
Member

gavanderhoorn commented Jun 8, 2021

The current collision mask is set to:

FS19_modROS/modROS.lua

Lines 92 to 98 in 5e8d484

-- set a raycast mask for a camera node which enables bits 5(unkown), 6(tractors), 7(combines), 8(trailers), 12(dynamic_objects)
local RC_MASK_UNKNOWN5 = math.pow(2, 5)
local RC_MASK_TRACTORS = math.pow(2, 6)
local RC_MASK_COMBINES = math.pow(2, 7)
local RC_MASK_TRAILERS = math.pow(2, 8)
local RC_MASK_DYN_OBJS = math.pow(2, 12)
self.raycastMask = RC_MASK_UNKNOWN5 + RC_MASK_TRACTORS + RC_MASK_COMBINES + RC_MASK_TRAILERS + RC_MASK_DYN_OBJS

IIRC, we've not been able to really find any documentation for those bit positions, except in this article/tutorial: How to Set Correct Collisions in Your Farming Simulator Mod:

Bit Feature
1 non_pushable1
2 non_pushable2
3 static_world1
4 static_world2
6 tractors
7 combines
8 trailers
12 dynamic_objects
13 dynamic_objects_machines
20 trigger_player
21 trigger_tractors
22 trigger_combines
23 trigger_fillables
24 trigger_dynamic_objects
25 trigger_trafficVehicles
26 trigger_cutters
30 kinematic_objects_without_collision

I suspect these are documented somewhere, I just haven't searched for it.

Whether the current value of the collisionMask is the optimal value for our purposes would be something to discuss.


Edit: from the same page: some example collision masks for various objects/vehicles:

Collision Type Bits Hex Value Decimal Value
Tractor 1, 6, 13, 21 0x202042 2105410
Combine 1, 7, 13, 22 0x402082 4202626
Fillable 1, 8, 13, 23 0x802102 8397058
Cutter 1, 12, 13, 24, 26 0x5003002 83898370
Tools 1, 13 0x2002 8194
@gavanderhoorn gavanderhoorn added help wanted lua Issues requiring changes/fixes to the Lua code nice-to-have A nice feature, but not a priority right now labels Jun 8, 2021
@gavanderhoorn
Copy link
Member Author

@Sagexs: it would be very helpful if you could experiment a bit and see whether any of these bits (or perhaps some of the undocumented ones) make raycastClosest(..) also detect vegetation.

I do expect there to be a rather large performance penalty if it would be possible, but at least then we'd know.

@tckarenchiang: perhaps we could see whether we'd want to make the collisionMask configurable, so users who have a need could tweak it for their specific use-case.

@gavanderhoorn
Copy link
Member Author

Oh, and AFAIU: if collsionMask is not set, it will default to hitting everything.

@tckarenchiang
Copy link
Contributor

tckarenchiang commented Jun 8, 2021

Oh, and AFAIU: if collsionMask is not set, it will default to hitting everything.

I've tested: if collisionMask is not set, crops still can't be detected (with laser scanner pointing down)

@gavanderhoorn
Copy link
Member Author

And just to make sure: if you set all bits of the collisionMask, does that change anything? So set it to 0xFFFFFFFF.

I'm not sure where I read that not providing collisionMask equates to a fully enabled collisionMask.

@tckarenchiang
Copy link
Contributor

And just to make sure: if you set all bits of the collisionMask, does that change anything? So set it to 0xFFFFFFFF.

It doesn't seem to change anything.

@gavanderhoorn
Copy link
Member Author

gavanderhoorn commented Jun 8, 2021

Ok, then it seems we can close #10 for now with the unfortunate conclusion that raycastClosest(..) cannot be used for detection crops/vegetation.


Edit: perhaps if we make some progress with #22, depthimage_to_laserscan could work for that instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted lua Issues requiring changes/fixes to the Lua code nice-to-have A nice feature, but not a priority right now
Development

No branches or pull requests

2 participants