1

I am trying to perform trajectory optimization for a robot arm attached to a free-floating base (to simulate a spacecraft-robot arm scenario).

For the base-torque actuation, I had previously tried attaching pseudo-links with actuators to the base CoM but these approaches did not work (see this). In the end, I decided to use the generalized forces to control the system instead of actuators as they seem to better represent my use of space-robots (see here). For linearization, I manually change the B (actuation) matrix to include the base torque actuators (reaction wheels).

With this background, I am trying to perform trajectory optimization using Direct Transcription where I aim to find u(t) which in my case is generalized forces instead of actuator forces. I add constraints that make certain generalized forces zero (translation forces on Base CoM) to better represent the real system (reaction wheels).

Now, when I use DirectTransciption function for the input_port_index parameter I provide input_port_index=plant.get_applied_generalized_force_input_port().get_index() to find trajectory using generalized forces instead of actuation forces.

However, when running Solve(), I get the following error:

RuntimeError: Actuation input port for model instance planarSC must be connected.

The error makes sense as indeed I do not connect the actuation input port. But the error still stays after I use plant.get_actuation_input_port().FixValue(plant.CreateDefaultContext(), np.zeros((plant.num_actuators(),1))) to set the actuation input port to zero.

Is there a way to perform DirectTranscription on generalized forces as u(t) instead of the actuation forces?

Update: I've corrected the context being provided to DirectTranscription. The python script now has the following code but still gives the same error about not having the actuation port connected:

trajOptContext = plant.CreateDefaultContext()
jointAcutation =  np.zeros((plant.num_actuators(),1))
plant.get_actuation_input_port().FixValue(trajOptContext, jointAcutation)

prog = DirectTranscription(plant, trajOptContext, N,
                           input_port_index=plant.get_applied_generalized_force_input_port().get_index())
Shubham Vyas
  • 163
  • 10
  • I still think your original approach (pseudo-links with actuators) should work fine. Using generalized forces can also work fine, and it certainly more general! But the generalized forces input port is not vector valued -- it is expecting a data structure that is a list of forces/body/locations. To use this with direct transcription, you would want to make another small system that takes a vector valued input and produces the generalized forces, then pass the diagram to direct transcription. – Russ Tedrake Jan 08 '21 at 11:53
  • Using floating pseudo-links with floating base poses the problem that when I attach an actuator in between, the pseudo-link has infinite acceleration due to zero mass. As for the generalized forces input port, I thought it was indeed a vector valued port as the documentation states: `Returns a constant reference to the vector-valued input port for applied generalized forces, and the vector will be added directly into tau (see System dynamics).` I have been using it until now by using a NumPy array to the port (`port.FixValue()`) for testing. – Shubham Vyas Jan 08 '21 at 13:24
  • 2
    Oops. You are correct. I responded too quickly (and incorrectly), thinking you were using the spatial forces port. The problem is your line `plant.get_actuation_input_port().FixValue(plant.CreateDefaultContext(), np.zeros((plant.num_actuators(),1)))`. This will only assign the values in a newly allocated Context, which you then throw away. You need the values to be assigned in whatever Context you pass to the optimization routine. – Russ Tedrake Jan 09 '21 at 00:59
  • Ah. Indeed @Russ Tedrake. I did not see that. I tried now running the trajectory optimization while passing the same context to `DirectTransciption` that I use to fix actuation port value. However, the error saying that the actuation port must be connected is still there. – Shubham Vyas Jan 10 '21 at 20:42

0 Answers0