Community Forum
ANVEL Licensing Options

Lower-level Control with ANVEL API



  • I see that the API supports sending throttle, braking, and steering commands via the SetVehicleInput service. Is there any service that enables lower level control such as position/velocity commands to individual motors?



  • @samxchandler,

    Can you provide a little bit more information on what you'd like to achieve here? It's possible to define your motor controller to drive each motor individually. It's also possible to set the position of the vehicle directly through commands, which would circumvent having to send vehicle control commands - but knowing a little bit more about your goals would help us provide direction here.

    Thanks,
    ANVEL Support



  • @anvel-team I want to use the ANVEL API to enable the use of software outside of ANVEL to independently control the steering and drive motors of an ANVEL vehicle. I don't see a way to this with the current ANVEL service functionality. Specifically, the SetVehicleInput function takes the VehicleInputRecord struct defined:

    struct VehicleInputRecord
    {
    1:double steering,
    2:double throttle,
    3:double brake
    }

    I'm looking for an input function that accepts a struct with position/velocity commands to each motor at the minimum. Maybe something like this:

    struct wheel_assembly
    {
    1:double drive_motor_velocity,
    2:double steer_motor_position
    }
    struct NewVehicleInputRecord
    {
    1:wheel_assembly left_front,
    2:wheel_assembly left_rear,
    3:wheel_assembly right_front,
    4:wheel_assembly right_rear
    }

    Any advice on how to do this is appreciated.



  • @anvel-team Do you have any suggestions?



  • @samxchandler,

    Sorry it's taken so long to respond! You should be able to achieve individual motor control with the following External API commands. We have an example on this wiki page, but admittedly it's quite buried far down on the page: https://wiki.anvelsim.com/3/index.php/Python_Example_Vehicle_Control

    You can modify the command to control each individual input in your control.xml file.

    #Initialize the vehicles with multiple motors
    vehicle = anv.CreateObject('CRSI', 'Test', 0, Point3(0,0,0), Euler(0, 0, 10), True)
    
    #run the simulation
    anv.SetSimulationState(SimulationState.RUNNING_REALTIME)
    
    #Control the individual throttles for each motor (spin in a circle)
    anv.SendStringCommand("AnvelAPIVehicleController.ControlVehicle", str(vehicle.objectKey) + ";ThrottleR:float64:-1.0|ThrottleL:float64:1.0")
    

    Let us know if this works for you.

    Regards,
    ANVEL Support



  • @anvel-team No problem. Thanks for getting back to me. I think this solves the problem of talking to multiple motors. How do I convert throttle to target drive velocities at this level?