KontrolSystem2
KontrolSystem2 copied to clipboard
Waypoint created by the game
Hi,
Is it possible to have access to waypoint created by the game? For example, the signal mission creates a waypoint on the Mun and you have to land near this waypoint.
I did not had much time for testing (mostly because I do not have that many waypoints to play around with), but this pre-release should have basic support: https://github.com/untoldwind/KontrolSystem2/releases/tag/v0.5.7.4
There is:
ksp::orbit::find_waypoint(name: string)to find a waypoint by is (display) namebody.waypointsto get a list of all waypoints on a celestial body- Waypoint itself has a
.global_positionals well as.geo_coordinates
This is great. Exactly what I wanted. Thanks.
I really liked this addition too, it was just what I needed for a rover script I was working on.
const body = vessel.main_body
// assume the first waypoint is the target and that there are waypoints
let target_global_pos = body.waypoints[0].global_position
// Calculate direction vector to the target
let direction_to_target = target_global_pos - vessel.global_position
let distance = target_global_pos.distance(vessel.global_position)
// accuracy of 100m
while(distance > 100){
CONSOLE.clear()
direction_to_target = target_global_pos - vessel.global_position
distance = target_global_pos.distance(vessel.global_position)
// Calculate the heading to the target, ignoring the vertical component
const local_vector = direction_to_target.to_local(vessel.body_frame)
const heading = atan2_deg(local_vector.x, local_vector.y)
const steering_angle = clamp((heading / 180.0),-1,1) // Simple normalization
const current_speed = vessel.horizontal_surface_speed
vessel.set_wheel_steering(steering_angle)
CONSOLE.print_line("Distance " + distance.to_string())
CONSOLE.print_line("Steering Angle: " + steering_angle.to_string())
if(current_speed > 10.0) {
const manager = vessel.set_wheel_throttle(-1.0)
CONSOLE.print_line("Throttle: " + manager.wheel_throttle.to_string())
}
else if(current_speed < 8.0) {
const manager = vessel.set_wheel_throttle(1.0)
CONSOLE.print_line("Throttle: " + manager.wheel_throttle.to_string())
} else {
const manager = vessel.set_wheel_throttle(0)
CONSOLE.print_line("Throttle: " + manager.wheel_throttle.to_string())
}
sleep(0.25)
}
vessel.set_wheel_throttle(0.0)
vessel.set_wheel_steering(0.0)
vessel.actions.brakes = true
CONSOLE.print_line("Arrived at waypoint")
This issue is stale because it has been open for 60 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.