Skip to content
TheChatArchiveThe Chat Archive
DeepSeekdeepseek-v3-0324· DeepSeekHugging Face LMArena Human Preference 140K

void renderHaptics(void) { cMode state = IDLE; cGenericObject* selectedObject = NULL;…

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Qwenqwen3-30b-a3b’s answer.
  1. User

    void renderHaptics(void) { cMode state = IDLE; cGenericObject* selectedObject = NULL; cTransform tool_T_object;

    // simulation in now running
    simulationRunning = true;
    simulationFinished = false;
    
    // main haptic simulation loop
    while (simulationRunning)
    {
        /////////////////////////////////////////////////////////////////////////
        // HAPTIC RENDERING
        /////////////////////////////////////////////////////////////////////////
    
        // signal frequency counter
        freqCounterHaptics.signal(1);
    
        // compute global reference frames for each object
        world->computeGlobalPositions(true);
    
        // update position and orientation of tool
        tool->updateFromDevice();
    
        // compute interaction forces
        tool->computeInteractionForces();
    
        /////////////////////////////////////////////////////////////////////////
        // MANIPULATION
        /////////////////////////////////////////////////////////////////////////
    
        // compute transformation from world to tool (haptic device)
        cTransform world_T_tool = tool->getDeviceGlobalTransform();
    
        // get status of user switch
        bool button = tool->getUserSwitch(0);
    
        //
        // STATE 1:
        // Idle mode - user presses the user switch
        //
        if ((state == IDLE) && (button == true))
        {
            // check if at least one contact has occurred
            if (tool->m_hapticPoint->getNumCollisionEvents() > 0)
            {
                // get contact event
                cCollisionEvent* collisionEvent = tool->m_hapticPoint->getCollisionEvent(0);
    
                // get object from contact event
                selectedObject = collisionEvent->m_object;
            }
            else
            {
                selectedObject = NULL;
            }
    
            if (selectedObject != NULL)
            {
                // get transformation from object
                cTransform world_T_object = selectedObject->getGlobalTransform();
    
                // compute inverse transformation from contact point to object 
                cTransform tool_T_world = world_T_tool;
                tool_T_world.invert();
    
                // store current transformation tool
                tool_T_object = tool_T_world * world_T_object;
    
                // update state
                state = SELECTION;
            }
        }
    
        //
        // STATE 2:
        // Selection mode - operator maintains user switch enabled and moves object
        //
        else if ((state == SELECTION) && (button == true))
        {
            if (selectedObject != NULL)
            {
                // compute new transformation of object in global coordinates
                cTransform world_T_object = world_T_tool * tool_T_object;
    
                // compute new transformation of object in local coordinates
                cTransform parent_T_world = selectedObject->getParent()->getLocalTransform();
                parent_T_world.invert();
                cTransform parent_T_object = parent_T_world * world_T_object;
    
                // assign new local transformation to object
                selectedObject->setLocalTransform(parent_T_object);
    
                // set zero forces when manipulating objects
                tool->setDeviceGlobalForce(0.0, 0.0, 0.0);
    
                tool->initialize();
            }
        }
    
    
    
        //
        // STATE 3:
        // Finalize Selection mode - operator releases user switch.
        //
        else
        {
            state = IDLE;
        }
    
        /////////////////////////////////////////////////////////////////////////
        // FINALIZE
        /////////////////////////////////////////////////////////////////////////
    
        // send forces to haptic device
        tool->applyToDevice();
    }
    
    // exit haptics thread
    simulationFinished = true;
    

    Not applying collision or not applying vibration/effects

  2. DeepSeek Assistant

    Looking at your haptic rendering code, I notice a few potential issues regarding collision handling and haptic effects:

    Collision Issues:

    1. The code only checks for collisions when entering SELECTION state (when button is first pressed), but doesn't maintain continuous collision detection during manipulation. This could lead to objects passing through each other during manipulation.

    2. There's no explicit collision response handling - the code simply moves the selected object without checking if the new position would cause collisions.

    Haptic Feedback Issues:

    1. The code explicitly sets zero forces when manipulating objects (tool->setDeviceGlobalForce(0.0, 0.0, 0.0)), which means the user won't feel any haptic feedback during manipulation.

    2. There's no vibration or other effects being applied at any point in the code.

    Suggested Improvements:

    1. For better collision handling:
    // During manipulation (STATE 2), add collision checks:
    else if ((state == SELECTION) && (button == true))
    {
        if (selectedObject != NULL)
        {
            // First check if new position would cause collisions
            if (!wouldCollide(world_T_tool * tool_T_object)) 
            {
                // compute new transformation (existing code)
                // ...
            }
            else {
                // Apply resistive force or vibration
                tool->setDeviceGlobalForce(/* some resistance force */);
            }
        }
    }
    
    1. For better haptic feedback:
    // Instead of zeroing forces during manipulation, you could:
    // - Apply a slight vibration to indicate grasping
    // - Apply forces based on object weight
    // - Apply resistance if trying to move through other objects
    
    // Example vibration effect:
    double time = simClock.getCurrentTimeSeconds();
    double vibration = 0.5 * sin(2 * M_PI * 100 * time); // 100Hz vibration
    tool->setDeviceGlobalForce(vibration, vibration, vibration);
    
    1. You might want to add continuous collision checking even in IDLE state to provide proximity feedback before actual contact occurs.

    The current implementation provides basic object manipulation but lacks the rich haptic feedback that would make the interaction more realistic and intuitive.

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.