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

Implement ISensorBridge python bindings #203

Merged
merged 2 commits into from
Feb 23, 2021

Conversation

GiulioRomualdi
Copy link
Member

@GiulioRomualdi GiulioRomualdi commented Feb 23, 2021

Similar to #200

The following example explains how to use bindings

import bipedal_locomotion_framework.bindings as blf
import time

if __name__ == "__main__":
    handler = blf.StdParametersHandler()
    handler.set_parameter_vector_string("joints_list", ["r_hip_pitch", "r_hip_roll", "r_hip_yaw", "r_knee", "r_ankle_pitch", "r_ankle_roll"])
    handler.set_parameter_vector_string("remote_control_boards", ["right_leg"])
    handler.set_parameter_string("robot_name", "icubSim")
    handler.set_parameter_string("local_prefix", "test_local")
    handler.set_parameter_float("positioning_duration", 3.0)
    handler.set_parameter_float("positioning_tolerance", 0.05)
    handler.set_parameter_float("position_direct_max_admissible_error", 0.1)
    handler.set_parameter_float("position_direct_max_admissible_error", 0.1)
    handler.set_parameter_bool("check_for_nan", False)
    handler.set_parameter_bool("stream_joint_states", True)
    
    # Create the control board
    control_board = blf.construct_remote_control_board_remapper(handler)
    time.sleep(1)

    # Create the robot control 
    robot_control = blf.YarpRobotControl()
    robot_control.initialize(handler)
    robot_control.set_driver(control_board.poly)

    # Create the sensor bridge
    sensor_bridge = blf.YarpSensorBridge()
    sensor_bridge.initialize(handler)
    sensor_bridge.set_drivers_list([control_board])
    
    # Move the robot
    robot_control.set_references([0.8, 0.5, 0.1, -0.8, 0.5, -0.4], \
                                 blf.IRobotControl.ControlMode.Position)
    
    while(1):
        sensor_bridge.advance()
        _, joints_values, _  = sensor_bridge.get_joint_positions()
        print("joint values = " + str(['%.4f' % elem for elem in joints_values]))
        
        time.sleep(0.01)
        

@paolo-viceconte

@GiulioRomualdi GiulioRomualdi merged commit 7bdbed8 into master Feb 23, 2021
@GiulioRomualdi GiulioRomualdi deleted the bindings/isensor_bridge branch February 23, 2021 14:45
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.

3 participants