Replies: 1 comment
-
Hello, you can receive feedback at any time, without sending a goal, by subscribing to the dedicated action topic, that should be package main
import (
"fmt"
"reflect"
"github.com/aler9/goroslib"
"github.com/aler9/goroslib/pkg/actionproc"
"github.com/aler9/goroslib/pkg/msg"
)
type DoSomethingActionGoal struct {
Input uint32
}
type DoSomethingActionResult struct {
Output uint32
}
type DoSomethingActionFeedback struct {
PercentComplete float32
}
type DoSomethingAction struct {
msg.Package `ros:"shared_actions"`
DoSomethingActionGoal
DoSomethingActionResult
DoSomethingActionFeedback
}
func main() {
node, err := goroslib.NewNode(goroslib.NodeConf{
Namespace: "/myns",
Name: "goroslib-server",
MasterAddress: "mymaster:11311",
})
if err != nil {
panic(err)
}
defer node.Close()
_, _, fbAction, err := actionproc.Messages(&DoSomethingActionGoal{})
if err != nil {
panic(err)
}
sub, err := goroslib.NewSubscriber(goroslib.SubscriberConf{
Node: node,
Topic: "actionname/feedback",
Callback: reflect.MakeFunc(
reflect.FuncOf([]reflect.Type{reflect.PtrTo(reflect.TypeOf(fbAction))}, []reflect.Type{}, false),
onFeedback,
).Interface(),
})
if err != nil {
panic(err)
}
defer sub.Close()
select {}
}
func onFeedback(in []reflect.Value) []reflect.Value {
fbAction := in[0]
reflect.ValueOf(onFeedback2).Call([]reflect.Value{
fbAction.Elem().FieldByName("Feedback").Addr(),
})
return []reflect.Value{}
}
func onFeedback2(fb *DoSomethingActionFeedback) {
fmt.Println("FEEDBACK", fb)
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello!
I would like to ask if there is a way to access feedback of an Action Server without sending a Goal ( without using SendGoal function.) I created a NewSimpleActionClient and I was trying to use actionproc.Messages function, but all returned values are empty. Is there a correct way to do it ? Thank you for help!
Cheers,
Beril
Beta Was this translation helpful? Give feedback.
All reactions