Im trying to use the math.h sin function but i keep getting a syntax error. Im trying to use trig to figure out how far away our bot is from the target light. Heres what’s not working:
You seem to be missing some closing parentheses for those bolded open parentheses. Try using a text editor that has parentheses highlighting like notepad2. Also it might be easier to read if you split it up over multiple lines (it’s not really more efficient code if you write it all on one line.)
Radicalnerd told you at least part of your problem. You have a different number of open parenthesis than you have close parenthesis. You also seem to be attempting a type cast of float without the required parenthesis.
If you’re trying to get the horizontal distance between you and the rack, and you have the angle measure from the camera, and you have the height of the light, wouldn’t you use tan to find the distance?
I would suggest dividing those numbers and rounding at whatever number of digits you feel comfortable at. That will eliminate 5 pairs of parentheses. Also, you could do some of that math in earlier steps and use a final, easy to read line for the distance.
Assuming you want the horizontal distance to the rack from your robot, maybe…this (I’m assuming TILT_SERVO is an angle measure):