kine_romeo.py
Go to the documentation of this file.
1 # -*- coding: utf-8 -*-
2 # Copyright 2011, Florent Lamiraux, Thomas Moulard, JRL, CNRS/AIST
3 # flake8: noqa
4 
5 # Binds with ROS. assert that roscore is running.
6 from dynamic_graph.ros import *
7 
8 # Create a simple kinematic solver.
9 from dynamic_graph.sot.application.velocity.precomputed_tasks import initialize
11  matrixToRPY,
12  matrixToTuple,
13  rotate,
14  vectorToTuple,
15 )
17 
18 # -------------------------------------------------------------------------------
19 # ----- MAIN LOOP ---------------------------------------------------------------
20 # -------------------------------------------------------------------------------
21 # define the macro allowing to run the simulation.
23  loopInThread,
24  loopShortcuts,
25 )
26 
27 # Create the robot romeo.
29 from numpy import *
30 
31 robot = Robot("romeo", device=RobotSimu("romeo"))
32 
33 ros = Ros(robot)
34 
35 solver = initialize(robot)
36 
37 dt = 5e-3
38 
39 
40 @loopInThread
41 def inc():
42  robot.device.increment(dt)
43 
44 
45 runner = inc()
46 [go, stop, next, n] = loopShortcuts(runner)
47 
48 # ---- TASKS -------------------------------------------------------------------
49 # ---- TASKS -------------------------------------------------------------------
50 # ---- TASKS -------------------------------------------------------------------
51 
52 # ---- TASK GRIP ---
53 # Defines a task for the right hand.
54 taskRH = MetaTaskKine6d("rh", robot.dynamic, "right-wrist", "right-wrist")
55 # Move the operational point.
56 handMgrip = eye(4)
57 handMgrip[0:3, 3] = (0.1, 0, 0)
58 taskRH.opmodif = matrixToTuple(handMgrip)
59 taskRH.feature.frame("desired")
60 # robot.tasks['right-wrist'].add(taskRH.feature.name)
61 
62 # --- STATIC COM (if not walking)
63 # create the com task and feature tasks.
64 solver = initialize(robot)
65 # remove the tasks from the sot (they've been automatically added by previous method).
66 solver.sot.clear()
67 
68 # --- CONTACTS
69 # define contactLF and contactRF
70 for name, joint in [["LF", "left-ankle"], ["RF", "right-ankle"]]:
71  contact = MetaTaskKine6d("contact" + name, robot.dynamic, name, joint)
72  contact.feature.frame("desired")
73  contact.gain.setConstant(10)
74  contact.keep()
75  locals()["contact" + name] = contact
76 
77 # --- RUN ----------------------------------------------------------------------
78 
79 # Move the desired position of the right hand
80 # 1st param: task concerned
81 # 2st param: objective
82 # 3rd param: selected parameters
83 # 4th param: gain
84 target = (0.5, -0.2, 0.8)
85 gotoNd(taskRH, target, "111", (4.9, 0.9, 0.01, 0.9))
86 
87 # Fill the stack with some tasks.
88 solver.push(contactRF.task)
89 solver.push(contactLF.task)
90 solver.push(robot.tasks["com"])
91 
92 solver.push(taskRH.task)
93 
94 # type inc to run one iteration, or go to run indefinitely.
95 # go()
dynamic_graph::sot::core::meta_tasks_kine
dynamic_pinocchio.kine_romeo.inc
def inc()
Definition: kine_romeo.py:41
ros
initialize
void initialize(bool ownStorage, Vec3f *points_, unsigned int num_points_)
dynamic_graph::sot::core::matrix_util
dynamic_graph::sot::core::utils::thread_interruptible_loop
robot


sot-dynamic-pinocchio
Author(s): Olivier Stasse
autogenerated on Fri Jul 28 2023 02:10:01