-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10cf71f
commit c5d5c1f
Showing
6 changed files
with
127 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import numpy as np | ||
import RobotDART as rd | ||
import dartpy # OSX breaks if this is imported before RobotDART | ||
|
||
# Create custom controller | ||
class MyController(rd.RobotControl): | ||
def __init__(self, ctrl, full_control): | ||
rd.RobotControl.__init__(self, ctrl, full_control) | ||
def __init__(self, ctrl, controllable_dofs): | ||
rd.RobotControl.__init__(self, ctrl, controllable_dofs) | ||
|
||
def configure(self): | ||
self._active = True | ||
|
||
def calculate(self, t): | ||
target = np.array([self._ctrl]) | ||
cmd = 100*(target-self.robot().positions(self._controllable_dofs)) | ||
return cmd[0] | ||
|
||
# TO-DO: This is NOT working at the moment! | ||
def clone(self): | ||
return MyController(self._ctrl, self._controllable_dofs) | ||
|
||
# Load robot from URDF | ||
robot = rd.Robot("arm.urdf", "arm", False) | ||
robot.fix_to_world() | ||
|
||
# Initiate custom controller | ||
control = MyController([0.0, 1.57, -0.5, 0.7], False) | ||
# Add it to the robot | ||
robot.add_controller(control, 1.) | ||
|
||
# Print initial positions of the robot | ||
print(robot.positions()) | ||
|
||
# Create simulator object | ||
simu = rd.RobotDARTSimu(0.001) | ||
|
||
# Add robot and floor to the simulation | ||
simu.add_robot(robot) | ||
simu.add_checkerboard_floor() | ||
|
||
simu.run(5.) | ||
|
||
print(robot.positions()) |