I have been working with python and pybox2d on a little race car project. What i have been trying to do is give the car some sensors so that a computer bot can sense the environment it has to drive through. So for the sensors i thought ray casting would be the way to go, which means using b2Segment and b2Shape.TestSegment. However i am stuck after spending alot of time trying to get b2Segment and b2Shape.TestSegment to work. That is, i can't get TestSegment to return true.
It's either my comprehension/implementation of how b2Segment/TestSegment works or its pybox2d. I was just wondering if anyone has managed to get b2Segment and b2Shape.TestSegment to work with pybox2d? My code is a little entangled and dependant on the framework so i won't try and past huge chunks of code, however i will go through my reasoning and hopefully someone can shed some light on my dilemma.
1. Create a b2Segment with p1 and p2 in world coordinates (attached to the body of the car)
2. Create a AABB in world coordinates around the b2Segment to detect shapes that intersect with the AABB (also attached to the car)
3. Check to see if those shapes found in step 2 intersect the b2Segment, e.g detectedShapes[i].TestSegment( ..., ..., ..., b2Segment from step 1, ...)
4. If a shape does intersect with b2Segment then TestSegment returns true, otherwise false
I can currently detect those shapes that intersect with the AABB, however i can not get step 3/4 to work. The funny thing is, i ported my entire project from pymunk to pybox2d because it had the ray cast functionality
Any help will be greatly appreciated.