Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
franka-connexion.py
1import argparse
2import math
3import sys
4
5from visp.robot import RobotFranka, Robot
6
7def main():
8 parser = argparse.ArgumentParser(description='Python wrapper example over vpRobotFranka ViSP class')
9 parser.add_argument('--ip', type=str, default="192.168.30.10", dest='robot_ip', help='Robot IP address like 192.168.30.10')
10
11 args, unknown_args = parser.parse_known_args()
12 if unknown_args:
13 print(f"The following args are not recognized and will not be used: {unknown_args}")
14 print('Exiting...')
15 sys.exit()
16
17 print(f"Use robot IP: {args.robot_ip}")
18
19 robot = RobotFranka()
20 robot.connect(args.robot_ip, RobotFranka.RealtimeConfig.kEnforce)
21 pos = robot.getPosition(Robot.JOINT_STATE)
22 print(f"Initial joint position: \n{pos}")
23
24 print("\nWARNING: This example will move the robot!")
25 print("Please make sure to have the user stop button at hand!")
26 print("Press Enter to continue...")
27 input()
28
29 print("Move to home position")
30 pos[0] = 0
31 pos[1] = 0
32 pos[2] = 0
33 pos[3] = -math.pi / 2
34 pos[4] = 0
35 pos[5] = math.pi / 2
36 pos[6] = math.pi / 4
37 robot.setRobotState(Robot.STATE_POSITION_CONTROL)
38 robot.setPosition(Robot.JOINT_STATE, pos)
39
40if __name__ == "__main__":
41 main()