diff --git a/pkg/rclgo/action.go b/pkg/rclgo/action.go index 4d72b82..d4cb063 100644 --- a/pkg/rclgo/action.go +++ b/pkg/rclgo/action.go @@ -11,7 +11,6 @@ import ( "crypto/rand" "errors" "fmt" - "reflect" "runtime" "strings" "sync" @@ -349,7 +348,7 @@ func (n *Node) NewActionServer( rclOpts := C.rcl_action_server_options_t{ allocator: *n.context.rcl_allocator_t, result_timeout: C.rcl_duration_t{ - nanoseconds: C.long(opts.ResultTimeout), + nanoseconds: C.int64_t(opts.ResultTimeout), }, } opts.GoalServiceQos.asCStruct(&rclOpts.goal_service_qos) @@ -526,7 +525,6 @@ func (s *ActionServer) scheduleRemoval() { func (s *ActionServer) expireGoals() error { var numExpired C.size_t expiredGoals := make([]C.rcl_action_goal_info_t, 10) - expiredGoalsHeader := (*reflect.SliceHeader)(unsafe.Pointer(&expiredGoals)) s.rclServerMu.Lock() defer s.rclServerMu.Unlock() s.goalsMu.Lock() @@ -534,8 +532,8 @@ func (s *ActionServer) expireGoals() error { for { rc := C.rcl_action_expire_goals( &s.rclServer, - (*C.rcl_action_goal_info_t)(unsafe.Pointer(expiredGoalsHeader.Data)), - C.ulong(expiredGoalsHeader.Len), + unsafe.SliceData(expiredGoals), + C.size_t(len(expiredGoals)), &numExpired, ) if rc != C.RCL_RET_OK { @@ -983,8 +981,8 @@ func (c *ActionClient) SendGoalRequest(ctx context.Context, request types.Messag return resp, err } -func (c *ActionClient) sendGoalRequest(req unsafe.Pointer) (C.long, error) { - var seqNum C.long +func (c *ActionClient) sendGoalRequest(req unsafe.Pointer) (C.int64_t, error) { + var seqNum C.int64_t rc := C.rcl_action_send_goal_request(&c.rclClient, req, &seqNum) if rc != C.RCL_RET_OK { return 0, errorsCastC(rc, "failed to send goal request") @@ -992,7 +990,7 @@ func (c *ActionClient) sendGoalRequest(req unsafe.Pointer) (C.long, error) { return seqNum, nil } -func (c *ActionClient) takeGoalResponse(resp unsafe.Pointer) (C.long, interface{}, error) { +func (c *ActionClient) takeGoalResponse(resp unsafe.Pointer) (C.int64_t, interface{}, error) { var header C.rmw_request_id_t switch rc := C.rcl_action_take_goal_response(&c.rclClient, &header, resp); rc { case C.RCL_RET_OK: @@ -1017,8 +1015,8 @@ func (c *ActionClient) GetResult(ctx context.Context, goalID *types.GoalID) (typ return resp, err } -func (c *ActionClient) sendResultRequest(req unsafe.Pointer) (C.long, error) { - var seqNum C.long +func (c *ActionClient) sendResultRequest(req unsafe.Pointer) (C.int64_t, error) { + var seqNum C.int64_t rc := C.rcl_action_send_result_request(&c.rclClient, req, &seqNum) if rc != C.RCL_RET_OK { return 0, errorsCastC(rc, "failed to send result request") @@ -1026,7 +1024,7 @@ func (c *ActionClient) sendResultRequest(req unsafe.Pointer) (C.long, error) { return seqNum, nil } -func (c *ActionClient) takeResultResponse(resp unsafe.Pointer) (C.long, interface{}, error) { +func (c *ActionClient) takeResultResponse(resp unsafe.Pointer) (C.int64_t, interface{}, error) { var header C.rmw_request_id_t switch rc := C.rcl_action_take_result_response(&c.rclClient, &header, resp); rc { case C.RCL_RET_OK: @@ -1060,8 +1058,8 @@ func (c *ActionClient) CancelGoal(ctx context.Context, request types.Message) (t return resp, err } -func (c *ActionClient) sendCancelRequest(req unsafe.Pointer) (C.long, error) { - var seqNum C.long +func (c *ActionClient) sendCancelRequest(req unsafe.Pointer) (C.int64_t, error) { + var seqNum C.int64_t rc := C.rcl_action_send_cancel_request(&c.rclClient, req, &seqNum) if rc != C.RCL_RET_OK { return 0, errorsCastC(rc, "failed to send cancel request") @@ -1069,7 +1067,7 @@ func (c *ActionClient) sendCancelRequest(req unsafe.Pointer) (C.long, error) { return seqNum, nil } -func (c *ActionClient) takeCancelResponse(resp unsafe.Pointer) (C.long, interface{}, error) { +func (c *ActionClient) takeCancelResponse(resp unsafe.Pointer) (C.int64_t, interface{}, error) { var header C.rmw_request_id_t switch rc := C.rcl_action_take_cancel_response(&c.rclClient, &header, resp); rc { case C.RCL_RET_OK: diff --git a/pkg/rclgo/logging.go b/pkg/rclgo/logging.go index 32824d8..5e2afda 100644 --- a/pkg/rclgo/logging.go +++ b/pkg/rclgo/logging.go @@ -144,7 +144,7 @@ func logNamed(level LogSeverity, name, msg string) error { } loc.file_name = C.CString(file) defer C.free(unsafe.Pointer(loc.file_name)) - loc.line_number = C.ulong(line) + loc.line_number = C.size_t(line) } cname := C.CString(name) defer C.free(unsafe.Pointer(cname)) diff --git a/pkg/rclgo/qos.go b/pkg/rclgo/qos.go index 28b7528..409b10b 100644 --- a/pkg/rclgo/qos.go +++ b/pkg/rclgo/qos.go @@ -95,13 +95,13 @@ func NewDefaultServiceQosProfile() QosProfile { func (p *QosProfile) asCStruct(dst *C.rmw_qos_profile_t) { dst.history = uint32(p.History) - dst.depth = C.ulong(p.Depth) + dst.depth = C.size_t(p.Depth) dst.reliability = uint32(p.Reliability) dst.durability = uint32(p.Durability) - dst.deadline = C.rmw_time_t{nsec: C.ulong(p.Deadline)} - dst.lifespan = C.rmw_time_t{nsec: C.ulong(p.Lifespan)} + dst.deadline = C.rmw_time_t{nsec: C.uint64_t(p.Deadline)} + dst.lifespan = C.rmw_time_t{nsec: C.uint64_t(p.Lifespan)} dst.liveliness = uint32(p.Liveliness) - dst.liveliness_lease_duration = C.rmw_time_t{nsec: C.ulong(p.LivelinessLeaseDuration)} + dst.liveliness_lease_duration = C.rmw_time_t{nsec: C.uint64_t(p.LivelinessLeaseDuration)} dst.avoid_ros_namespace_conventions = C.bool(p.AvoidRosNamespaceConventions) } diff --git a/pkg/rclgo/rcl.go b/pkg/rclgo/rcl.go index 9a55e14..f41feab 100644 --- a/pkg/rclgo/rcl.go +++ b/pkg/rclgo/rcl.go @@ -607,7 +607,7 @@ func (c *Context) NewTimer(timeout time.Duration, timer_callback func(*Timer)) ( timer.rcl_timer_t, c.Clock().rcl_clock_t, c.rcl_context_t, - (C.long)(timeout), + C.int64_t(timeout), nil, *c.rcl_allocator_t, ) @@ -1072,8 +1072,8 @@ func (c *Client) Send(ctx context.Context, req types.Message) (types.Message, *S return resp, nil, err } -func (c *Client) sendRequest(req unsafe.Pointer) (C.long, error) { - var seqNum C.long +func (c *Client) sendRequest(req unsafe.Pointer) (C.int64_t, error) { + var seqNum C.int64_t rc := C.rcl_send_request(c.rclClient, req, &seqNum) if rc != C.RCL_RET_OK { return 0, errorsCastC(rc, "failed to send request") @@ -1081,7 +1081,7 @@ func (c *Client) sendRequest(req unsafe.Pointer) (C.long, error) { return seqNum, nil } -func (c *Client) takeResponse(resp unsafe.Pointer) (C.long, interface{}, error) { +func (c *Client) takeResponse(resp unsafe.Pointer) (C.int64_t, interface{}, error) { var header C.rmw_service_info_t switch rc := C.rcl_take_response_with_info(c.rclClient, &header, resp); rc { case C.RCL_RET_OK: @@ -1105,22 +1105,22 @@ type sendResult struct { } type requestSenderTransport struct { - SendRequest func(unsafe.Pointer) (C.long, error) - TakeResponse func(unsafe.Pointer) (C.long, interface{}, error) + SendRequest func(unsafe.Pointer) (C.int64_t, error) + TakeResponse func(unsafe.Pointer) (C.int64_t, interface{}, error) TypeSupport types.ServiceTypeSupport Logger *Logger } type requestSender struct { transport requestSenderTransport - pendingRequests map[C.long]chan *sendResult + pendingRequests map[C.int64_t]chan *sendResult mutex sync.Mutex } func newRequestSender(transport requestSenderTransport) requestSender { return requestSender{ transport: transport, - pendingRequests: make(map[C.long]chan *sendResult), + pendingRequests: make(map[C.int64_t]chan *sendResult), } } @@ -1155,7 +1155,7 @@ func (s *requestSender) Send(ctx context.Context, req types.Message) (types.Mess } } -func (s *requestSender) addPendingRequest(req types.Message) (<-chan *sendResult, C.long, error) { +func (s *requestSender) addPendingRequest(req types.Message) (<-chan *sendResult, C.int64_t, error) { ts := s.transport.TypeSupport.Request() buf := ts.PrepareMemory() defer ts.ReleaseMemory(buf)