|
1 | | -using Pkg; Pkg.activate("VMRobotControlEnv"; shared=true) |
2 | | - |
3 | 1 | using Printf |
4 | 2 | using Sockets |
5 | 3 | using StaticArrays |
@@ -397,78 +395,3 @@ function ros_vm_controller( |
397 | 395 | (E = stored_energy(control_cache)) > E_max && error("Initial stored energy exceeds $(E_max)J, was $(E)J") |
398 | 396 | warmup_and_activate(connection, control_func!; ) |
399 | 397 | end |
400 | | - |
401 | | -#= |
402 | | -# Enable debug logging |
403 | | -using Logging |
404 | | -debuglogger = ConsoleLogger(stderr, Logging.Debug) |
405 | | -global_logger(debuglogger) |
406 | | -=# |
407 | | - |
408 | | -#= |
409 | | -# Test connection with python only |
410 | | -with_rospy_connection(Sockets.localhost, ROSPY_LISTEN_PORT+1, 7, 14) do connection |
411 | | - warmup_and_activate(connection, test_control_func; ) |
412 | | -end |
413 | | -=# |
414 | | - |
415 | | -#= |
416 | | -# Test on franka |
417 | | -module_path = joinpath(splitpath(splitdir(pathof(VMRobotControl))[1])[1:end-1]) |
418 | | -using FileIO, UUIDs |
419 | | -try |
420 | | - FileIO.add_format(format"DAE", (), ".dae", [:DigitalAssetExchangeFormatIO => UUID("43182933-f65b-495a-9e05-4d939cea427d")]) |
421 | | -catch |
422 | | -end |
423 | | -robot = parseRSON(joinpath(module_path, "RSONs/rsons/franka_panda/pandaSurgicalV2.rson")) |
424 | | -add_gravity_compensation!(robot, 1.1*DEFAULT_GRAVITY) |
425 | | -
|
426 | | -vms = compile(VirtualMechanismSystem("franka", robot)) |
427 | | -qᵛ = Float64[] |
428 | | -
|
429 | | -with_rospy_connection(Sockets.localhost, ROSPY_LISTEN_PORT, 7, 14) do connection |
430 | | - ros_vm_controller(connection, vms, qᵛ) |
431 | | -end |
432 | | -=# |
433 | | - |
434 | | -# Test on sciurus |
435 | | -# Test on franka |
436 | | -module_path = joinpath(splitpath(splitdir(pathof(VMRobotControl))[1])[1:end-1]) |
437 | | -robot = parseURDF(joinpath(module_path, "URDFs/sciurus17_description/urdf/sciurus17.urdf")) |
438 | | -add_gravity_compensation!(robot, DEFAULT_GRAVITY) |
439 | | - |
440 | | -vms = VirtualMechanismSystem("sciurus", robot) |
441 | | -# add_gravity_compensation!(vms, -0.2*DEFAULT_GRAVITY) |
442 | | -add_coordinate!(vms, ReferenceCoord(Ref(SVector(.3, 0.1, 0.2))); id="l_tgt") |
443 | | -add_coordinate!(vms, FramePoint(".robot.l_link7", SVector(0., 0., 0.)); id="l_hand") |
444 | | -add_coordinate!(vms, CoordDifference("l_tgt", "l_hand"), id="l_err") |
445 | | -add_component!(vms, TanhSpring("l_err"; stiffness=200.0, max_force=5.0); id="l_spring") |
446 | | -add_component!(vms, LinearDamper(5., "l_err"); id="l_damper") |
447 | | - |
448 | | -add_coordinate!(vms, ReferenceCoord(Ref(SVector(.3, 0.1, 0.2))); id="r_tgt") |
449 | | -add_coordinate!(vms, FramePoint(".robot.r_link7", SVector(0., 0., 0.)); id="r_hand") |
450 | | -add_coordinate!(vms, CoordDifference("r_tgt", "r_hand"), id="r_err") |
451 | | -add_component!(vms, TanhSpring("r_err"; stiffness=200.0, max_force=5.0); id="r_spring") |
452 | | -add_component!(vms, LinearDamper(5., "r_err"); id="r_damper") |
453 | | - |
454 | | - |
455 | | - |
456 | | -function f_setup(cache) |
457 | | - l_ref_coord_id = get_compiled_coordID(cache, "l_tgt") |
458 | | - r_ref_coord_id = get_compiled_coordID(cache, "r_tgt") |
459 | | - return (l_ref_coord_id, r_ref_coord_id) |
460 | | -end |
461 | | - |
462 | | -function f_control(cache, t, setup_ret, extra) |
463 | | - l_ref_coord_id, r_ref_coord_id = setup_ret |
464 | | - coord = cache[l_ref_coord_id].coord_data.val[] = SVector(0.3, .1 + 0.1*sin(t), 0.2) |
465 | | - coord = cache[r_ref_coord_id].coord_data.val[] = SVector(0.3 + 0.1*cos(t), -.1, 0.2 + 0.1*sin(t)) |
466 | | - nothing |
467 | | -end |
468 | | - |
469 | | -cvms = compile(vms) |
470 | | - |
471 | | -qᵛ = Float64[] |
472 | | -with_rospy_connection(Sockets.localhost, ROSPY_LISTEN_PORT, 21, 42) do connection |
473 | | - ros_vm_controller(connection, cvms, qᵛ; f_control, f_setup, E_max=2.0) |
474 | | -end |
0 commit comments