Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setpoint srv #127

Closed
wants to merge 5 commits into from
Closed

Setpoint srv #127

wants to merge 5 commits into from

Conversation

TSC21
Copy link
Member

@TSC21 TSC21 commented Aug 17, 2014

Right now is working but there's a strange behaviour: when, for example, I issue the command rosrun mavros mavsetp local -vel 1 0 0, having the mavros_node running, I get Mavros not started, nobody subcsribes to /mavros/setpoint/local/vel/set.
But if I do rostopic echo /mavros/setpoint/local/vel/set, it doesn't reply with the above. Any explanation for this based on the code I wrote?
Thanks!

@TSC21
Copy link
Member Author

TSC21 commented Aug 17, 2014

Ok I've checked that the same happens with the mavsafety safetyarea command. It actually subscribes, 'cause I can see the info being showed on the mavros_node terminal, but in the terminal where I have launched the command it issues Mavros not started, nobody subcsribes to /mavros/safety_area/set.
So it seems that the topic is subscribed for a short time so it can get the info and then it unsubscribes the topic, where the node launched from the srv automatically responds that there is no subscription.

Update: solved by adding the printf_if inside the delay routine:

# stick around long enough for others to grab
    timeout_t = rospy.get_time() + _ONCE_DELAY
    while not rospy.is_shutdown() and rospy.get_time() < timeout_t:
        rospy.sleep(0.2)
        print_if(pub.get_num_connections() < 1,
             "Mavros not started, nobody subcsribes to ",
             args.mavros_ns + "/safety_area/set")

@TSC21
Copy link
Member Author

TSC21 commented Aug 17, 2014

Ok I'm already adding setpoint position also. But I'm stuck on the argparser part. As I said, I want to be able to have mavsetp as the primary parser, then give the option to choose between local and global and then, inside those, have args to -pos, -vel, etc with the corresponding metavar. This is the code I have right now on main:

parser = argparse.ArgumentParser(description="Commad line tool for control the device by setpoints.")
    parser.add_argument('-n', '--mavros-ns', help="ROS node namespace", default="/mavros")
    parser.add_argument('-v', '--verbose', action='store_true', help="verbose output")
    subarg = parser.add_subparsers()


    setp_local_pos_args = subarg.add_parser('local', help="Send local setpoint")
    setp_local_pos_args.set_defaults(func=do_setp_local_vel)
    setp_local_pos_args.add_argument('-pos', type=float, nargs=3, metavar=('x', 'y', 'z'),
                                  required=True, help="Local position")

    setp_local_vel_args = subarg.add_parser('local', help="Send local setpoint")
    setp_local_vel_args.set_defaults(func=do_setp_local_vel)
    setp_local_vel_args.add_argument('-vel', type=float, nargs=3, metavar=('vx', 'vy', 'vz'),
                                  required=True, help="Linear velocity")

    setp_global_pos_args = subarg.add_parser('global', help="Send global setpoint")
    setp_global_pos_args.set_defaults(func=do_setp_global_vel)
    setp_global_pos_args.add_argument('-pos', type=float, nargs=3, metavar=('x', 'y', 'z'),
                                  required=True, help="Global position")

    setp_global_vel_args = subarg.add_parser('global', help="Send global setpoint")
    setp_global_vel_args.set_defaults(func=do_setp_global_vel)
    setp_global_vel_args.add_argument('-vel', type=float, nargs=3, metavar=('vx', 'vy', 'vz'),
                                  required=True, help="Linear velocity")

    args = parser.parse_args(rospy.myargv(argv=sys.argv)[1:])
    args.func(args)

Need help to figure this out since the above doesn't work. (For example, rosrun mavros mavset local -h just offers me the option to use -pos and it's metavars).
Thanks in advance!

@TSC21 TSC21 changed the title Setpoint srv - velocity Setpoint srv Aug 17, 2014
@vooon
Copy link
Member

vooon commented Aug 18, 2014

I don't understand why you added duplicate topics?

Also i think it's not handy to control using cmdline (some time ago, I tried to control the rover, and realized that it is very inconvenient).

@TSC21
Copy link
Member Author

TSC21 commented Aug 18, 2014

I don't understand why you added duplicate topics?

That's why I need your help to use the same topic to do different commands. Please right here a piece of code that will do the job and then I'll implement it in the rest.

Also i think it's not handy to control using cmdline

It can be handy some times. Probably to test purposes first.

@TSC21 TSC21 closed this Aug 18, 2014
@TSC21 TSC21 deleted the setpoint_srv branch August 18, 2014 10:50
nmichael pushed a commit to rislab/mavros that referenced this pull request Mar 19, 2016
Fix template bug that occurs when variable is used at the end of a repetition
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants