I want to use the Time provided by the Gps for my custom missions. Main objective is to allow the plane to arm only in specific time of the day. Since Pixhawk doesn’t have a clock it has to extract time from GPS. SO any suggestions on how to do this?
How do you plan to implement your time-check into the arming checks?
It sounds like you need to modify the firmware… and I think if you have the knowledge to do that successfully, you would be able to also get access to the GPS information. So perhaps you have some other idea?
Not specifically on arming check. I want to always have a check on time to determine whether the plane is flying in the specified time period only. If it has crossed the time period then it should probably return to landing zone or something. Till now I havent figured out on how to access the time from the GPS.
Ah, thank you for clarifying.
You will need to figure out more implementation details before folks can help. An important detail is: Where (exactly) will the logic to “check the time and then command the plane accordingly” be implemented? Is this something that you run on the Ground Control Station, or onboard the vehicle? If onboard the vehicle, will it be on a companion computer, or integrated directly into the firmware?
So here are the details:
I am sending a custom message from the GCS(mavproxy for now, later from Mission planner) containing the allowed time period i.e the time according to the local timezone for which it has a permission to fly. Now the checking has to be done inside the firmware as i dont want to add a companion computer to the pixhawk . As soon as the message is received from the GCS it should store the permission Time and run a time check throughout the flight run.
Now I am unable to obtain the GPS time. Any suggestions on how to use the GPS time inside the Firmware to check the time in certain interval.
Line 272 of AP_GPS.h provides the time_week_ms() function, and line 280 of AP_GPS.h provides the time_week() function.
Thank you very much for the help. I got this particular function : AP::rtc().get_utc_usec(tim); that gives the time from unix epoch. But the Problem I am facing is that , i am unable to use a correct data type. If I am storing it as a float value i get something like this: 1.530769e-15. Since I need to keep a check on time i need to see some changes in the value. If I use a double value I am getting the time as a negative value. Any Suggestions on how to solve this?
Thank you ,
Maybe try an unsigned 64-bit integer?
Using uint64_t i got the result. Thanks for helping
Now I am facing Problem In setting up the geofence. If you have any idea on how to set the geofence using MAVProxy that would be helpful. Basically I want to embed the geofence inside the firmware, i.e everytime the pixhawk boots A geo-fence is already set. SO any suggetions?